Questions tagged [ninject-2]

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

209 questions
52
votes
1 answer

Ninject: Registering an already created instance with Ninject?

Can anyone tell me if i can register an already created instance of a class with Ninject so that it will use this instance everytime it needs injecting? I suppose you can call it a singleton but I have the instance already created. All the…
Martin
  • 23,844
  • 55
  • 201
  • 327
50
votes
3 answers

MVC 3: How to learn how to test with NUnit, Ninject, and Moq?

Short version of my questions: Can anyone point me toward some good, detailed sources from which I can learn how to implement testing in my MVC 3 application, using NUnit, Ninject 2, and Moq? Can anyone here help clarify for me how…
campbelt
  • 1,573
  • 5
  • 27
  • 43
34
votes
3 answers

Ninject InRequestScope missing

Have a couple of questions regarding the latest version (2.2.1.4) of ninject. Was trying to Bind a Linq2sql DataContext to a concrete implementation InRequestScope (in a class library project) Bind().To() but…
Raghu
  • 2,678
  • 2
  • 31
  • 38
24
votes
1 answer

Ninject: How to bind an open generic with more than one type argument?

I'm using Ninject 2.2, and I'm trying to setup a binding for an open generic that takes two type arguments. According to this answer by qes, the correct syntax to bind IRepository to Repository is…
Daniel Liuzzi
  • 16,807
  • 8
  • 52
  • 57
23
votes
2 answers

Ninject WithConstructorArgument : No matching bindings are available, and the type is not self-bindable

My understanding of WithConstructorArgument is probably erroneous, because the following is not working: I have a service, lets call it MyService, whose constructor is taking multiple objects, and a string parameter called testEmail. For this string…
18
votes
5 answers

ASP.NET MVC 3: DefaultModelBinder with inheritance/polymorphism

First, sorry for the big post (I've tried to do some research first) and for the mix of technologies on the same question (ASP.NET MVC 3, Ninject and MvcContrib). I'm developing a project with ASP.NET MVC 3 to handle some client orders. In short: I…
jmpcm
  • 1,814
  • 2
  • 19
  • 27
17
votes
1 answer

Need a simple example of using nhibernate + unit of work + repository pattern + service layer + ninject

I am using nhibernate + fluent nhibernate asp.net mvc 3 ninject Currently I am using nhibernate, ninject with the repository pattern and service layers. So I have this ninject public class NhibernateSessionFactory { public…
chobo2
  • 83,322
  • 195
  • 530
  • 832
17
votes
4 answers

Inject repository to custom membership provider with Ninject

I'm trying to inject a repository to a custom membership provider with ninject in MVC 3. In MembershipProvider I have tried the following: [Inject] public ICustomerRepository _customerRepository{ get; set; } And [Inject] public…
Luticka
  • 639
  • 2
  • 6
  • 17
14
votes
2 answers

MVC 3 Dependency Resolver or Ninject MVC plugin?

In MVC 3 they added a Dependency Resolver what I been using. While answering someone question someone commented on you should use the Ninject MVC 3 plugin. So my question is why use it over the built in one? If it is the way to go how do you setup…
chobo2
  • 83,322
  • 195
  • 530
  • 832
14
votes
1 answer

How do I use Common Service Locator in Ninject 2

Changes in Ninject 2 say that Ninject support Common Service Locator, but how do I use it? I don't find any manual or sample.
13
votes
1 answer

ASP.Net MVC 3, Ninject and Quartz.Net - How to?

I am now using Ninject 2.2.1.4, with my MVC3, i'm success to config Ninject run with it, but i don't know how to make Ninject run with Quartz.Net in my MVC3 Can anyone help?
Hieu Nguyen Trung
  • 1,624
  • 5
  • 21
  • 32
12
votes
1 answer

Ninject, Bind should be .InRequestScope() OR .InSingletonScope()

I have Below code One is bindable to my User Repository and another for Cache. What scope should I use for UserRepository and Cache. Should Scope on UserRepository be Singleton? …
Pirzada
  • 4,685
  • 18
  • 60
  • 113
11
votes
1 answer

Injecting multiple constructor parameters of the same type with Ninject 2.0

I'm using Ninject 2.0 to handle DI in one of my apps and I've come across something that's confusing me. Having zero documentation doesn't help too much either to be honest. Say I have a constructor with the signature - ctor(IServiceFactory…
EightyOne Unite
  • 11,665
  • 14
  • 79
  • 105
11
votes
3 answers

How does Ninject create controller in ASP.NET MVC?

This may be stupid question, but I am looking at Ninject sources and don't see NInject registering its own controller factory. I also don't see any IControllerFactory class in Ninject.Web.Mvc assembly. Am I missing something? How does Ninject create…
LukLed
  • 31,452
  • 17
  • 82
  • 107
11
votes
4 answers

Dependency Injection with Custom Membership Provider

I have an ASP.NET MVC web application that implements a custom membership provider. The custom membership provider takes a UserRepository to its constructor that provides an interface between the membership provider and NHibernate. The…
alastairs
  • 6,697
  • 8
  • 50
  • 64
1
2 3
13 14