Utilizzo di Visual Studio 2013, ho migrato un'applicazione Web Asp.Net Webforms/MVC 3/Framework 4.0 ibrida in Asp.Net Webforms/MVC 5.2.2/Framework 4.5 .1.MethodAccessException in System.Web.WebPages migrazione mvc 3 in mvc 5
Ho seguito la procedura descritta in questi link:
Quando eseguo l'applicazione in Visual Studio ottengo questo errore:
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.
ho provato questi suggerimenti che ho trovato su StackOverflow, ma nessuno risolve il problema:
- chiara la cartella bin e ricostruire
- Installare Nuget Microsoft.Aspnet.WebHelpers pacchetto.
- Assicurarsi che tutti i riferimenti web.config di System.Web.Mvc e System.Web.WebPages puntino alla versione corretta (rispettivamente 5.2.2.0 e 3.0.0.0).
Qualsiasi consiglio su come trovare la causa di questo errore sarebbe molto apprezzato.
L'analisi dello stack completo dell'errore:
[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
Hai provato a installare il pacchetto Microsoft.AspNet.WebPages.Data? – Carl
Sì, il pacchetto Microsoft.AspNet.WebPages.Data è installato. –