tag for questions related to ninject -2 version of ninject dependency injector
Questions tagged [ninject-2]
209 questions
10
votes
2 answers
Is Kernel.Get() threadsafe + good pattern to share the kernel among components
Is Kernel.Get() threadsafe? My goal is share an instance of my kernel among all my componenets and they may all very well call Kernel.Get() at the same time on different threads.
Is Kernel.Get() thread safe?
What is the best pattern to share the…

iCode
- 4,308
- 10
- 44
- 77
10
votes
1 answer
Ninject.MVC3, Pass DependencyResolver to service-layer?
In a MVC3-application with Ninject.MVC 2.2.0.3 (after merge), instead of injecting repostories directly into controllers I'm trying to make a service-layer that contain the businesslogic and inject the repostories there. I pass the…

Grastveit
- 15,770
- 3
- 27
- 36
10
votes
3 answers
Ninject 2.0: Property Injection without attribute
Is there a way to use Property Injection in Ninject 2 without using the [Inject] attribute? This creates a dependency to Ninject in the class that will be wired using it and I prefer to avoid having unneeded dependencies to my IoC container, that's…

t3mujin
- 1,272
- 1
- 9
- 22
9
votes
3 answers
Binding singleton to multiple services in Ninject
I have a problem which seems very similar to the one described in http://markmail.org/message/6rlrzkgyx3pspmnf which is about the singleton actually creating more than a single instance if you're accessing it using different service types.
I'm using…

Michał Drozdowicz
- 1,232
- 11
- 30
9
votes
1 answer
Using ASP.NET MVC 2 with Ninject 2 from scratch
I just did File -> New Project last night on a new project. Ah, the
smell of green fields.
I am using the just released ASP.NET MVC 2 (i.e. no preview or release
candidate, the real thing), and thought I'd get off to a good start
using Ninject 2…

Rune Jacobsen
- 9,907
- 11
- 58
- 75
8
votes
1 answer
Ninject, passing constructor argument to the kernel
Here is my problem:
I want to pass in one of the values to the constructor every time I request an instance form the kernel. I written some code below to illustrate the problem. The test is not failing so I guess that this works, but it does look…

Pelle
- 2,755
- 7
- 42
- 49
8
votes
2 answers
Recommended Pattern for Lazy-loading Portions of Object Graph from Cache
I'm using memcache behind a web app to minimize the hits to our SQL database. I'm storing C# objects into this cache by marking them with SerializableAttribute. We make heavy use of dependency injection via Ninject in our app.
Some of these…

FMM
- 4,289
- 1
- 25
- 44
8
votes
2 answers
I need more Ninject practical examples
In the past, I used swiftsuspenders that is an actionscript 3 IoC controller. Basically the first version of switfsuspender had something similar to the Ninject kernel that was called injector.
If I wanted to create an application injector (with…

sebas
- 1,045
- 12
- 27
8
votes
1 answer
In Ninject 2.0, how do I have both a general binding and a binding for a specific case?
I have a situation where I want to dependency inject my user object, but also place the current user in the IoC container. I want the following lines to work:
kernel.Get(); // Should return a new User()
kernel.Get("Current"); // Should…

Jeff Walker Code Ranger
- 4,634
- 1
- 43
- 62
7
votes
2 answers
ASP.NET MVC 3 Ninject Custom Membership and Role Provider
Hi i got some problems enabling custom Membership and Role Provider, i got following error:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and…

Nozi
- 71
- 1
- 2
7
votes
2 answers
How to use Ninject to inject services into an authorization filter?
I am using asp.net mvc 3, ninject 2.0 and the ninject mvc 3 plugin.
I am wondering how do I get service layers into my filter(in this case an authorization filter?).
I like to do constructor inject so is this possible or do I have to property…

chobo2
- 83,322
- 195
- 530
- 832
7
votes
1 answer
Mocking an object with Moq, using Ninject when doing UnitTesting
I'm having trouble using Moq in a UnitTesting project with Ninject.
First a few lines about my solution. It contains several projects (BussinesLogic, DAL, Infrastructure...). My goal is to UnitTest the logic i'm using in BussinessLogic project.
The…

Alex Dee
- 129
- 2
- 7
7
votes
2 answers
Ninject exception in Parallel.Foreach
I have a piece of code that runs a Parallel.Foreach on a list of items to process. Each iteration creates a couple of objects with each object instantiating and disposing it's own instance of the Ninject IKernel. The IKernel is disposed when the…

e36M3
- 5,952
- 6
- 36
- 47
7
votes
3 answers
Getting started with Ninject
I watched the first 2 beginner tutorials for Ninject on dimecasts.net. Now, I want to use Ninject 2.2 in ASP.NET MVC 3. I want a view with a mocked out Model. I get object reference not set to an instance of an object when calling my service;
…

P.Brian.Mackey
- 43,228
- 68
- 238
- 348
7
votes
1 answer
Should I create an interface for each Model?
I'm just getting started with Dependency Injection (DI) using Ninject and am working through my controllers looking to decouple them from my models a bit more.
At the moment, inside of my controllers I am creating an instance of some given model…

Jamie Dixon
- 53,019
- 19
- 125
- 162