Questions tagged [ninject-extensions]

Ninject Extensions are a collection of open-source projects designed to extend the functionality of the Ninject open-source dependency injector for the .NET framework.

Ninject Extensions are a collection of open-source projects designed to extend the functionality of the Ninject open-source dependency injector for the .NET framework.

Extension projects include, among others, those targeted at situations involving specific technologies such as MVC and WCF, as well as situations involving design patterns, such as Factories and Conventions.

207 questions
6
votes
1 answer

MoqMockingKernel: System.TypeLoadException: Inheritance security rules violated by type

I try to use the MoqMockingKernel class. (Ninject.MockingKernel.Moq) from the Ninject.MockingKernel Extension for a unit test. At initializing the MoqMockingKernel I'm getting the following error: System.TypeLoadException: System.TypeLoadException:…
bitsmuggler
  • 1,689
  • 2
  • 17
  • 30
6
votes
3 answers

Get ninject factory extension to allow factory parameters be passed to dependencies

Using the Ninject Factory extension, you can automatically generate factories, and let the factory pass parameters to the class' constructor. The following test passes: public interface IBar { int Foo { get; } } public class Bar : IBar { …
Pete
  • 12,206
  • 8
  • 54
  • 70
6
votes
1 answer

ActivationException when using ToFactory in Ninject

When I try to use the ToFactory in Ninject, I get Ninject.ActivationException var test = new StandardKernel(); test.Bind().To(); test.Bind().ToFactory(); var factory = test.Get(); var foo = factory.GetFoo(); …
magol
  • 6,135
  • 17
  • 65
  • 120
6
votes
2 answers

Composing polymorphic objects in ASP.NET MVC3 project

The essence of my question is how to compose these objects (see below) in a sensible way with MVC3 and Ninject (though I am not sure DI should be playing a role in the solution). I can't disclose the real details of my project but here is an…
5
votes
2 answers

Ninject dynamically bind to implementation

There are several questions on Stack Overflow that are similar but not exactly what I'm looking for. I would like to do Ninject binding based on a runtime condition, that isn't pre-known on startup. The other questions on Stack Overflow for dynamic…
DiskJunky
  • 4,750
  • 3
  • 37
  • 66
5
votes
1 answer

Ninject 3, WCF Service and parameterized constructor

I have a WCF Service hosted in IIS. This solution is composed of 2 projects: Service and Data. Service depends on Data, like so: Service -> Data I've been trying to invert the dependency, like so: Service <- Data Which is quite a headache using…
5
votes
1 answer

how to use Ninject intercept using InterceptAttribute

I have a NinjectWebCommon as follow. I am unable to get the TimingInterceptor to trigger on the method that has "Timing" attribute set. It works fine if the intercetor is defined at the class level where all method call is going to be intercepted,…
Eatdoku
  • 6,569
  • 13
  • 63
  • 98
5
votes
3 answers

Ninject throws Activation Exception in a WebApi project with multiple assemblies

My asp.net WebApi project comprises of multiple assemblies for Services, Core and Data Access. In an attempt to use Ninject as my DI container in the project, I added Ninject.Web.Common package from NuGet. Then, I Implemented IDependencyResolver…
5
votes
1 answer

Interception with Ninject. Fails to load IProxyRequestFactory

I'm learning to use Ninject and Interceptor pattern. I have the following interceptor. public class MyInterceptor:IInterceptor { public void Intercept(IInvocation invocation) { Console.WriteLine("Pre Execute: " +…
5
votes
2 answers

Ninject Interception - breaking changes when porting to Ninject 3.0

I will describe my environment: I have Ninject + Ninject Interception Extension working to enable auto registration of interceptors for all methods, marked with a special attribute. It is a common AoP + attributes + DI container scenario. My problem…
Cortlendt
  • 2,190
  • 4
  • 29
  • 50
4
votes
1 answer

Stability of Ninject.Mvc and Ninject.Wcf extensions

I'm planning to start using Ninject 2.2 in enterprise-like project after playing with it for some time. Can anyone confirm no issues with these extensions in production use? I especially worry about IDisposable scenarios (client WCF proxies in MVC…
UserControl
  • 14,766
  • 20
  • 100
  • 187
4
votes
1 answer

Intercept interface methods in Ninject Interception Extension

I'm playing around with the Ninject Interception extension. Ian Davis's blog post about it indicates that interception is always based on the actual service type, rather than the interface. For example, the following code will have no effect because…
StriplingWarrior
  • 151,543
  • 27
  • 246
  • 315
4
votes
2 answers

Ninject, how inject a generic Logger by calling LoggerFactory.CreateLogger

I am working on an ASP.NET MVC application. I have initialized my LoggerFactory in a static class which is called from Global.asax using Microsoft.Extensions.Logging; using Serilog; using System.IO; namespace web { public static class…
Hooman Bahreini
  • 14,480
  • 11
  • 70
  • 137
4
votes
1 answer

Ninject Conditional Self bind to change scope (For Task-scheduler) not working properly?

Within MVC Web Application DbContext binding work properly with InRequestScope() kernel.Bind().ToSelf().InRequestScope(); kernel.Bind>().To>(); But from a Task Scheduler call DbContext in…
4
votes
1 answer

Unable to find NinjectWcfApplication reference when try to install nInject for WCF

I want to add nInject into WCF service and i followed below steps. http://www.aaronstannard.com/post/2011/08/16/dependency-injection-ninject-wcf-service.aspx Problem: I am not able to find NinjectWcfApplication class to inherit for…
1
2
3
13 14