Ninject WCF extension does not work in MVC3 Ninject Website
-
13-04-2021 - |
题
We need to add a service to our website, I've added the MVC extension and added
Factory="Ninject.Extensions.Wcf.NinjectServiceHostFactory"
To the markup, i've also added
KernelContainer.Kernel = kernel;
To the CreateKernel method to get rid of the root null problem, but now I get
The service type provided could not be loaded as a service because it does not have a default (parameter-less) constructor. To fix the problem, add a default constructor to the type, or pass an instance of the type to the host.
The type in the constructor is binded in the kernel
Thanks
edit: This works
kernel.Bind<ServiceHost>().To<NinjectServiceHost>();
解决方案
I recommend using Ninject 3.0.0-rc2 available from Nuget. The new WCF and MVC extensions allow to run side a side.
不隶属于 StackOverflow