解决Autofac问题重写成员GetService时违反了继承安全性规则 [英] Solving Autofac issue Inheritance security rules violated while overriding member GetService
问题描述
我有一个使用Autofac的ASP.NET MVC应用程序.
I've got an ASP.NET MVC application using Autofac.
我通过以下方式添加了相应的软件包:
I've added the appropriate packages via:
Install-Package Autofac
Install-Package Autofac.Mvc4
当我运行Web应用程序时,抛出了此错误:
When I ran the web application, this error was throw:
重写成员时违反了继承安全性规则:"Autofac.Integration.Mvc.AutofacDependencyResolver.GetService(System.Type)".覆盖方法的安全可访问性必须与被覆盖方法的安全可访问性相匹配.
Inheritance security rules violated while overriding member: 'Autofac.Integration.Mvc.AutofacDependencyResolver.GetService(System.Type)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
如何解决?
推荐答案
当项目类型实际上是MVC 5时,我已经为MVC 4安装了Autofac.
I had installed Autofac for MVC 4 when the project type was actually MVC 5.
为解决此问题,我运行了Uninstall-Package Autofac.Mvc4
和
To solve this, I ran Uninstall-Package Autofac.Mvc4
and
Install-Package Autofac.Mvc5
这篇关于解决Autofac问题重写成员GetService时违反了继承安全性规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!