What is the main purpose of the NinjectServiceHost class?

At first, I thought that using the NinjectServiceHost class was the only way to create, for example, an instance of a non-standard implementation class. (Out of the box, you can only call the new ServiceHost (typeof (SomeClass)), where SomeClass will be created using a constructor without parameters, which does not allow dependency injection).

But now I see that I can simply use the Ninject core to retrieve singleton instances of easily validated classes (which do not implement singleton explicitly, and I would use the InSingletonScope binding for Ninject) from my service class.

What is the main use of NinjectServiceHost? What features does it provide?

+4
source share
1 answer

The answer will look like this:

If I do not use NinjectServiceHost to host the WCF service, my service class must be Ninject-aware in order to resolve its dependencies in the code.

Using NinjectServiceHost allows you to pass constructor parameters to the service class, which allows it to be independent of Ninject.

+4
source

All Articles