Przy użyciu Visual Studio 2013 zmigrowałem hybrydową aplikację sieci Web Asp.Net Webforms/MVC 3/Framework 4.0 do Asp.Net Webforms/MVC 5.2.2/Framework 4.5 .1.MethodAccessException wewnątrz System.Web.WebPages migracja mvc 3 do mvc 5
I następnie wykonać czynności opisane w tych linków:
Kiedy uruchomić aplikację w visual studio I ten błąd:
Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed.
próbowałem te sugestie, które znalazłem na StackOverflow, ale żaden nie rozwiązuje problemu:
- wyczyść folder bin i odbuduj
- Zainstaluj pakiet Nuget Microsoft.Aspnet.WebHelpers.
- Upewnij się, że wszystkie odwołania do pliku web.config System.Web.Mvc i System.Web.WebPages wskazują poprawną wersję (odpowiednio 5.2.2.0 i 3.0.0.0).
Wszelkie porady dotyczące sposobu znalezienia przyczyny tego błędu będą mile widziane.
Pełne ślad stosu błędu:
[MethodAccessException: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed.]
System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule() +96
System.Web.WebPages.Administration.PreApplicationStartCode.Start() +41
[InvalidOperationException: The pre-application start initialization method Start on type System.Web.WebPages.Administration.PreApplicationStartCode threw an exception with the following error message: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +559
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516
[HttpException (0x80004005): The pre-application start initialization method Start on type System.Web.WebPages.Administration.PreApplicationStartCode threw an exception with the following error message: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9913572
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Czy próbowałeś już zainstalować pakiet Microsoft.AspNet.WebPages.Data? – Carl
Tak, pakiet Microsoft.AspNet.WebPages.Data jest zainstalowany. –