I've just upgraded a (very) old MVC project to .net 4.7.2 along with all of my nuget packages. Upon running my application, I am getting this error:
Attempt by security transparent method 'AutofacContrib.DynamicProxy2.RegistrationExtensions.EnableClassInterceptors(Autofac.Builder.IRegistrationBuilder
3<!!0,Autofac.Features.Scanning.ScanningActivatorData,!!1>)' to access security critical type 'Autofac.Builder.IRegistrationBuilder
3' failed.Assembly 'AutofacContrib.DynamicProxy2, Version=2.4.5.724, 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.
Stack Trace:
[TypeAccessException: Attempt by security transparent method 'AutofacContrib.DynamicProxy2.RegistrationExtensions.EnableClassInterceptors(Autofac.Builder.IRegistrationBuilder
3<!!0,Autofac.Features.Scanning.ScanningActivatorData,!!1>)' to access security critical type 'Autofac.Builder.IRegistrationBuilder
3' failed.Assembly 'AutofacContrib.DynamicProxy2, Version=2.6.1.841, 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.] AutofacContrib.DynamicProxy2.RegistrationExtensions.EnableClassInterceptors(IRegistrationBuilder`3 registration) +0
[HttpException (0x80004005): Attempt by security transparent method 'AutofacContrib.DynamicProxy2.RegistrationExtensions.EnableClassInterceptors(Autofac.Builder.IRegistrationBuilder
3<!!0,Autofac.Features.Scanning.ScanningActivatorData,!!1>)' to access security critical type 'Autofac.Builder.IRegistrationBuilder
3' failed.Assembly 'AutofacContrib.DynamicProxy2, Version=2.6.1.841, 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.] System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +10093561 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +173 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +218 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Attempt by security transparent method 'AutofacContrib.DynamicProxy2.RegistrationExtensions.EnableClassInterceptors(Autofac.Builder.IRegistrationBuilder
3<!!0,Autofac.Features.Scanning.ScanningActivatorData,!!1>)' to access security critical type 'Autofac.Builder.IRegistrationBuilder
3' failed.Assembly 'AutofacContrib.DynamicProxy2, Version=2.6.1.841, 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.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10074760 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
I've tried changing my AssemblyInfo.cs file to include: [assembly: SecurityTransparent()] or [assembly: SecurityRules(SecurityRuleSet.Level2)] or [assembly: SecurityRules(SecurityRuleSet.Level1)] as per other Stack Overflow articles and none of those seems to help. Here is my packages.config file:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net472" />
<package id="Autofac" version="4.8.1" targetFramework="net472" />
<package id="Autofac.Mvc5" version="4.0.2" targetFramework="net472" />
<package id="bootstrap" version="4.1.3" targetFramework="net472" />
<package id="Castle.Core" version="4.3.1" targetFramework="net472" />
<package id="DataAnnotationsExtensions" version="5.0.1.27" targetFramework="net472" />
<package id="EntityFramework" version="6.2.0" targetFramework="net472" />
<package id="Exceptionless" version="4.3.2012" targetFramework="net472" />
<package id="Exceptionless.Mvc" version="4.3.2012" targetFramework="net472" />
<package id="Exceptionless.Portable" version="4.3.2012" targetFramework="net472" />
<package id="Font.Awesome" version="5.3.1" targetFramework="net472" />
<package id="jQuery" version="3.3.1" targetFramework="net472" />
<package id="Microsoft.AspNet.Mvc" version="5.2.6" targetFramework="net472" />
<package id="Microsoft.AspNet.Razor" version="3.2.6" targetFramework="net472" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi" version="5.2.6" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.6" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.6" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.6" targetFramework="net472" />
<package id="Microsoft.AspNet.WebPages" version="3.2.6" targetFramework="net472" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net472" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net472" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net472" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net472" />
<package id="MvcDiagnostics" version="5.2.6" targetFramework="net472" />
<package id="MvcMailer" version="4.5" targetFramework="net472" />
<package id="MvcScaffolding" version="1.0.9" targetFramework="net472" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net472" />
<package id="OctoPack" version="3.6.3" targetFramework="net472" developmentDependency="true" />
<package id="odp.net.x86" version="112.3.20" targetFramework="net472" />
<package id="PagedList" version="1.17.0.0" targetFramework="net472" />
<package id="PagedList.Mvc" version="4.5.0.0" targetFramework="net472" />
<package id="popper.js" version="1.14.3" targetFramework="net472" />
<package id="T4Scaffolding" version="1.0.8" targetFramework="net472" />
<package id="T4Scaffolding.Core" version="1.0.0" targetFramework="net472" />
<package id="WebGrease" version="1.6.0" targetFramework="net472" />
</packages>
Any help is greatly appreciated.
User contributions licensed under CC BY-SA 3.0