C# 设置Autofac依赖项解析程序导致';访问安全关键型ILifeTimeScope失败';例外

C# 设置Autofac依赖项解析程序导致';访问安全关键型ILifeTimeScope失败';例外,c#,.net,security,dependency-injection,autofac,C#,.net,Security,Dependency Injection,Autofac,我正在尝试将我的解决方案的某些组件自动注入到web api控制器中,并使用autofac来实现这一点 为此,我在Global.asax.cs中执行以下操作: DependencyResolver.SetResolver(new AutofacDependencyResolver(ModuleFramework.Container)); GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependenc

我正在尝试将我的解决方案的某些组件自动注入到web api控制器中,并使用autofac来实现这一点

为此,我在Global.asax.cs中执行以下操作:

DependencyResolver.SetResolver(new AutofacDependencyResolver(ModuleFramework.Container));
GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(ModuleFramework.Container);
但是,当我尝试设置autofac依赖项解析程序时,出现以下错误:

Attempt by security transparent method 

'Autofac.Integration.Mvc.RequestLifetimeScopeProvider..ctor(Autofac.ILifetimeScope)' to access security critical type 'Autofac.ILifetimeScope' failed.

Assembly 'Autofac.Integration.Mvc, Version=3.3.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model.  Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.
在线搜索之后,我看到一些帖子,他们建议重新安装
Microsoft.AspNet.WebApi.WebHost
,但不幸的是,这在我的情况下不起作用。有谁能向我解释一下这里的核心问题是什么,以及应该采取哪些步骤来解决这个问题