Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ninject WCF Extension ArgumentNullException using NET.TCP Binding

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.

like image 432
Cragly Avatar asked Mar 27 '11 19:03

Cragly


2 Answers

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

like image 140
Daniel Marbach Avatar answered Nov 04 '22 10:11

Daniel Marbach


See the answers to the identical question in the google news group: http://groups.google.com/group/ninject/browse_thread/thread/54108ef9e848b8f0

like image 44
Remo Gloor Avatar answered Nov 04 '22 11:11

Remo Gloor