问题
I have a WCF 4 service with 2 endpoints configured to use wsHttpBinding and netTcpBinding. I am hosting the service within IIS 7.5 using WAS and am using the Ninject WCF extension to DI into my service. My service works fine when I use the wsHttpBinding endpoint to call my service but fails when I use the netTcpBinding. When I look in my Application Event Log I get the following error outlined below.
I have tried debugging the problem in VS2010 but am getting nowhere fast with this. I don’t want to have to remove Ninject from my WCF service if at all possible. I understand that I could just use wsHttpBinding but I this is an internal service and I want to get the performance gains that netTcpBindings provide.
WebHost failed to process a request.
Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/30180123
Exception: System.ServiceModel.ServiceActivationException: The service '/ProfileService.svc' cannot be activated due to an exception during compilation. The exception message is: Cannot be null
Parameter name: root. ---> System.ArgumentNullException: Cannot be null
Parameter name: root
at Ninject.Infrastructure.Ensure.ArgumentNotNull(Object argument, String name) in c:\Projects\Ninject\ninject\src\Ninject\Infrastructure\Ensure.cs:line 20
at Ninject.ResolutionExtensions.Get[T](IResolutionRoot root, IParameter[] parameters) in c:\Projects\Ninject\ninject\src\Ninject\Syntax\ResolutionExtensions.cs:line 37
at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
--- End of inner exception stack trace ---
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)
Process Name: w3wp
Process ID: 8656
Is there anybody out there that may be able to help with this problem? Any help on this one would be much appreciated.
回答1:
If I'm correct, I reckon you may be using an older version which uses the KernelContainer
. You need to set the Kernel
on the KernelContainer
. See:
https://github.com/ninject/ninject.extensions.wcf/blob/52bb83728774701ec42b5f76b096bec934dfe419/src/Ninject.Extensions.Wcf/KernelContainer.cs
回答2:
See the answers to the identical question in the google news group: http://groups.google.com/group/ninject/browse_thread/thread/54108ef9e848b8f0
来源:https://stackoverflow.com/questions/5451580/ninject-wcf-extension-argumentnullexception-using-net-tcp-binding