Questions tagged [ninject-2]

tag for questions related to ninject -2 version of ninject dependency injector

209 questions
7
votes
1 answer

Contextual bindings with Ninject 2.0

In Ninject 1.0 I had following binding definitions: Bind().To().Only(When.Context.Variable("variable").EqualTo(true)); Bind().To(); Given such bindings I had calls: ITarget target =…
7
votes
2 answers

Ninject + Web ApI 2: Error activating IFilterProvider using binding from IFilterProvider to DefaultFilterProvider

I originally had used some custom code I found to handle the dependency resolution in Web API and it worked fine. The issue I ran into was that I wanted to bind a filter to my controller scopes just like you can with MVC. For example,…
oliwa
  • 1,834
  • 1
  • 16
  • 19
6
votes
2 answers

Error activating HttpContext - More than one matching binding is available

I have an ASP.NET MVC app with a simple NinjectModule: public class MainModule : NinjectModule { public override void Load() { Bind().ToSelf().InSingletonScope(); Bind().ToMethod(context =>…
devuxer
  • 41,681
  • 47
  • 180
  • 292
6
votes
1 answer

Ninject binding with WhenInjectedInto extension method

I feel I am missing something obvious. I've read several related questions on here and I've read the updated contextual bindings page on Ninject's wiki but alas it still doesn't work. I am trying to retrofit a legacy application that used a factory…
oliwa
  • 1,834
  • 1
  • 16
  • 19
6
votes
2 answers

Ninject.Extensions.Logging.Log4net unexpected behavior

I am having a problem using Log4Net (1.2.10) through Ninject's (2.2.1.4) Extensions.Logging.Log4net (2.2.0.4), as installed through NuGet. When I access Log4Net directly: var logger =…
6
votes
1 answer

Ninject: Resolve dependency by name only

I have a WPF view\view-model binding pattern where I would like to resolve dependencies from Ninject by name only, rather than by type or type+name. I want to bind my view-models by name with Ninject, and then refer to the view-models in views by…
Tim Lloyd
  • 37,954
  • 10
  • 100
  • 130
6
votes
1 answer

Ninject: Default & specific bindings for a Generic class

I have an abstract class: public abstract class Validator : IValidator and a couple of classes that implement this class for specific purposes, e.g. public sealed class NewsValidator : Validator Now using Ninject i want to do Dependency…
Oliver
  • 63
  • 3
6
votes
1 answer

ASP.NET MVC 3 and Global Filter Injection

Hello am an trying to implement a global filter with injection. The filter looks like this. public class WikiFilter : IActionFilter { private IWikiService service; public WikiFilter(IWikiService service) { this.service =…
Androme
  • 2,399
  • 4
  • 43
  • 82
6
votes
2 answers

Calling all ISomething instances in Ninject

I have an interface ISomething with a method Start. I want to get all implementations of this interface (in multiple assemblies, the main one and all referenced ones) and call the Start method on application start. How can I do this with Ninject…
Paul
  • 93
  • 6
6
votes
1 answer

Can you make use of AOP with Ninject 2?

I'm trying to find examples on the web of how to use AOP via Ninject. Can someone confirm if AOP is available in Ninject 2 without using external libraries (i.e. Castle Windsor?). If it can be done, could you post a link to resources that would help…
Jason Evans
  • 28,906
  • 14
  • 90
  • 154
6
votes
1 answer

Ninject InThreadScope Binding

I have a Windows service that contains a file watcher that raises events when a file arrives. When an event is raised I will be using Ninject to create business layer objects that inside of them have a reference to an Entity Framework context which…
e36M3
  • 5,952
  • 6
  • 36
  • 47
6
votes
1 answer

Ninject Intermittent exception thrown related to OnePerRequestModule

I just upgraded an existing implementation of Ninject from 1.5 to 2.0. I'm now seeing an intermittent exception getting thrown when many requests are happening in a short period of time. Here's the exception that is being thrown. Type:…
reifnir
  • 143
  • 1
  • 5
6
votes
1 answer

Ninject giving NullReferenceException

I'm using asp.net MVC 2 and Ninject 2. The setup is very simple. Controller calls service that calls repository. In my controller I use inject to instantiate the service classes with no problem. But the service classes don't instantiate the…
Eyeslandic
  • 14,553
  • 13
  • 41
  • 54
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
5
votes
1 answer

Ninject Pass Delegate into WithConstructorArgument

I have a need to point to a method in Ninject bindings as part of a constructor argument. The constructor for the class looks like this: MyObject(Func param1, TimeSpan time) I have been looking and haven't been able to find a way to bind…
Iron Ninja
  • 434
  • 1
  • 3
  • 13
1 2
3
13 14