使用 NET.TCP 绑定的 Ninject WCF 扩展 ArgumentNullException
我有一个 WCF 4 服务,有 2 个端点配置为使用 wsHttpBinding 和 netTcpBinding。我使用 WAS 在 IIS 7.5 中托管该服务,并使用 Ninject WCF 扩展来 DI 到我的服务中。当我使用 wsHttpBinding 端点调用我的服务时,我的服务工作正常,但当我使用 netTcpBinding 时失败。当我查看应用程序事件日志时,出现下面概述的错误。
我尝试在 VS2010 中调试该问题,但进展缓慢。如果可能的话,我不想从我的 WCF 服务中删除 Ninject。我知道我可以只使用 wsHttpBinding,但这是一项内部服务,我希望获得 netTcpBindings 提供的性能提升。
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
有没有人可以帮助解决这个问题?对此的任何帮助将不胜感激。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我是正确的,我认为您可能使用的是使用
KernelContainer
的旧版本。您需要在KernelContainer
上设置Kernel
。请参阅:https://github .com/ninject/ninject.extensions.wcf/blob/52bb83728774701ec42b5f76b096bec934dfe419/src/Ninject.Extensions.Wcf/KernelContainer.cs
If I'm correct, I reckon you may be using an older version which uses the
KernelContainer
. You need to set theKernel
on theKernelContainer
. See:https://github.com/ninject/ninject.extensions.wcf/blob/52bb83728774701ec42b5f76b096bec934dfe419/src/Ninject.Extensions.Wcf/KernelContainer.cs
请参阅 Google 新闻组中同一问题的答案:http://groups .google.com/group/ninject/browse_thread/thread/54108ef9e848b8f0
See the answers to the identical question in the google news group: http://groups.google.com/group/ninject/browse_thread/thread/54108ef9e848b8f0