我已将我的 Web Api 应用程序移植到 Web Api 2 并安装了 ninject web api 包。但是现在我收到一个错误:
Error activating ModelValidatorProvider using binding from ModelValidatorProvider to NinjectDefaultModelValidatorProvider
A cyclical dependency was detected between the constructors of two services.
最佳答案
我遇到了同样的问题。当我将 Ninject.Web.WebApi 添加为 Nuget 包时,我得到了它。
为解决该问题,我不得不删除之前实现的解决方法。
在之前的解决方法中,我将 NinjectWebCommon 中的依赖项解析器设置为实现了 IDependencyResolver 的自定义类。
简而言之,如果您在 NinjectWebCommon 的 CreateKernel()
中有类似于 GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel);
的行,请将其删除。
关于c# - 移植到 web api 2 后 NinjectHttpApplication 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23504390/