ninject

Use Rhino Service Bus on ASP.NET website with Ninject

I will like to add Rhino Service Bus to my ASP.NET web application but using Ninject as the DI Container. So far all examples I keep seeing use Castle Windsor which I don't want to use since we already use Ninject. Are there any tutorials out there which show how to add Rhino Service Bus to an ASP.NET web application without a direct de...

Binding Nhibernate.Burrow's ISession using Ninject

I am trying use NHibenate, Burrow and Ninject. I cannot seem to be able to bind the Burrow ISession using ninject. I currently have Bind<ISession>().ToProvider( new BurrowFramework().GetSession()).InRequestScope(); I get the errors " cannot convert from 'NHibernate.ISession' to 'System.Type' The best overloaded method match f...

ASP.NET MVC2 + Ninject + NLog (+ shared hosting?) = NullReferenceException

I have an MVC2 app that's based on the Tekpub Starter Site, so it uses Ninject for dependency injection, NLog for logging, and a bunch of other libraries in various places. As far as I can tell though, it's these that are causing my problem. Everything works beautifully on my PC using the ASP.NET dev server (Cassini) but when I deploy ...

Norm.MongoException: Connection timeout trying to get connection from connection pool

Hi, I'm using Rob's mvc startesite http://mvcstarter.codeplex.com/ with ASP.Net MVC 2, Ninject2, NoRM (http://github.com/atheken/NoRM) and MongoDB. It works so fast and the developpement is even faster but I'm facing a big problem, I at some points, get connection timeout. I can't figure out what I'm doing wrong. I already asked a que...

Using Ninject WCF Extension with WCF Web Service

I have a WCF web service in which I want to use my Repositories and Services which I wish to dependency inject into my WCF web service, however the Ninject WCF Extension example pretty much has a ctor which is instantiating an instance of each dependency, which I don't want, I wanted a purer dependency injection. Has anyone had any succ...

Ninject Asp.net mvc 2 404 errors?

When I debug my asp.net mvc 2 application and I put a break point on my action that is called when a 404 error occurs every time I invoke any action my error action gets called but the view does not get displayed. This is in my web.config (copied from nerddinner): <customErrors mode="RemoteOnly" defaultRedirect="/Home/Trouble"> <err...

ASP.NET MVC SiteMap with Ninject controller factory error

I am trying to use the ASP.NET MVC Codeplex Sitemap project with Custom Dynamic Node provider. This is my node provider code. It uses some repository to access the DB. I actually don't use DI in this class but the application inherits NinjectHttpApplication and the Sitemap has problems acquiring controller. public class ContentPageDynam...

Ninject with Windows Application

I want to use Ninject in my Windows application and I want to know if there is best practices that I can do; strategies to find a balance between performance and maintenance. The problem with Windows application and Web application is that in Web application, there is a scope easy to define that is the context but with Windows applicati...

Why doesn't the following mocking with Ninject.Moq work?

I'm trying to run the following code with Ninject.Moq: [TestMethod] public void TestMethod1() { var kernel = new MockingKernel(); var engine = kernel.Get<ABC>(); //as I don't need to actually use the interfaces, I don't want //to even have to bother about them. Assert.AreEqual<string>("abc", engine.ToString()); } A...

Resolve Array with Ninject

In Ninject there's automatic implicit self-binding for concrete types. So without further configuration I can resolve every type in my application, like: Foo foo = Kernel.Get(typeof(Foo)); Now if I need an Array of Foo, how would I do that? Foo[] foos = Kernel.Get(typeof(Foo[])); // does not work EDIT: For clarification, here is, ...

How, for example, to make a binding with constructor arguments to a Bitmap with Ninject?

I currently have a class of this form: class Abc { private readonly IDisposable disposable; public Abc(IDisposable disposable) { this.disposable = disposable; } ... } Now, I'd like to know how can I make a binding of IDisposable to Bitmap using the Bitmap(int widht, int height) constructor. I've tried w...

What is the best practice for WinForms dialogs with ninject?

I try to create aplication with Ninject. I have one MainForm and dialog form for settings. How should i implement this? Should MainForm have a Kernel instance and then create SettingsForm with Get() method? Or should MainForm constructor have parameter with SettingsForm instance? I tried find some example of WinForm application with nin...

Cyclic dependency with ninject

I'm trying to figure out correct way how to bind something like this with ninject. interface IMainService { void DoStuff(); } interface IOtherService { void DoSomeMagic(); } abstract class BaseClass { //many stuff here } class MainClass : BaseClass, IMainService { public MainClass(IOtherService s) { } pub...

Help with Ninject in asp.net mvc 2

Im trying to add Ninject to my app so that (maybe) I can try creating/running tests in it... so I need a little help setting this up here's my controller public class CompaniesController : Controller { private ICompaniesServices _service; public CompaniesController() { ...

Find what class an abstract class is bound to in Ninject

Hi, How do I find what class is currently bound to the abstract class with Ninject in the following example: if(conditional) Bind<IProducts>().To<Products>(); else Bind<IProducts>().To<SqlProducts>(); Type currentType = 'Type based upon current binding of IProducts' How can I get the value of currentType. ...

"Multiple bindings" error when calling ninject2.Get<ConcreteClass>()

I'd like to do something like this: ConcreteClass foo = ninject2.Get<ConcreteClass>( new ConstructorArgument("bar", "qux")); ninject2.Bind<ConcreteClass>().ToConstant(foo); ... ConcreteClass foo = ninject2.Get<ConcreteClass>(); // fail! When I try, I get the error Error activating ConcreteClass. More than one matching bindings ...

Ninject property injection returns null

I'm sure I'm doing something stupid but this is what we're here for! I've got a WinForms app with the following code: static void Main() { IKernel kernel = new StandardKernel(new MyModule()); TestInterface test = kernel.Get<TestInterface>(); } For the Module.Load() event: Bind<TestClass>().ToSelf().InSingletonScope(); Bind<T...

How can I inject a ModelState with ninject?

Say I have CompaniesController which uses a CompaniesService. And the Companies Service is where I do all my Business Validation so it requires I pass it the ModelState (Im using a ModelState Wrapper following this... But since I added Ninject to my project I cant figure out how to inject the ModelStateWrapper into the CompaniesService.....

Ninject - how to inject during object lifetime?

Hi, I'm just getting started with dependency injection. I've read the Ninject wiki and its very clear on how to inject dependencies where a single instance of the dependency is required, using constructor, property or method injection. But how do you handle the case where your class needs to construct objects during its lifetime (after ...

Getting AsyncController to work with Ninject

I am trying to convert some actions within a controller to run asynchronously in an mvc project that is using ninject for dependency injection. I'm following the steps by inheriting AsyncController and changing the methods that correspond to the 'X' action to 'XAsync' and 'XCompleted' but the async action is not getting resolved. I'm con...