views:

135

answers:

1

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.

+2  A: 

The Ninject2 download contains a CommonServiceLocator.NinjectAdapter.dll (in the 'extensions' folder of the zip file). Add this dll and the Ninject.dll to your project.

In the startup path of your application (after configuring the Ninject kernel), you can use the following code:

IKernel ninject = ...; 

var locator = new NinjectServiceLocator(ninject);

ServiceLocator.SetLocatorProvider(() => locator);
Steven