Attempt by security transparent method 'System.Web.Mvc.PreApplicationStartCode.Start()' to access security critical method 'System.Web.WebPages.PreApplicationStartCode.Start()' failed.

Oct 2, 2014 at 4:47 PM
Hello,
I'm running IIS 8.5 with .Net 4.5 fully patched. When installing BlogEngine.Net I get the following error. I'm an IIS newb. I have tried downloading the source and installing the latest MVC 5.2.2 using NuGet, and that works on the local host, but not on the hosting server.

Below is the error that is generated in the server's event viewer.
Any help would be appreciated.
Thank you!

Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 10/2/2014 11:37:30 AM
Event time (UTC): 10/2/2014 3:37:30 PM
Event ID: ff44fc4322874599824ca7ed070056b8
Event sequence: 1
Event occurrence: 1
Event detail code: 0

Application information:
Application domain: /LM/W3SVC/4/ROOT/blog-1-130567378490114132 
Trust level: Full 
Application Virtual Path: /blog 
Application Path: C:\inetpub\zservice-blog\ 
Machine name: WINHUB 
Process information:
Process ID: 14772 
Process name: w3wp.exe 
Account name: IIS APPPOOL\zService Blog 
Exception information:
Exception type: InvalidOperationException 
Exception message: The pre-application start initialization method Start on type System.Web.Mvc.PreApplicationStartCode threw an exception with the following error message: Attempt by security transparent method 'System.Web.Mvc.PreApplicationStartCode.Start()' to access security critical method 'System.Web.WebPages.PreApplicationStartCode.Start()' failed..
at System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection1 methods, Func1 setHostingEnvironmentCultures)
at System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods)
at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded)
at System.Web.Compilation.BuildManager.ExecutePreAppStart()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)

Attempt by security transparent method 'System.Web.Mvc.PreApplicationStartCode.Start()' to access security critical method 'System.Web.WebPages.PreApplicationStartCode.Start()' failed.
at System.Web.Mvc.PreApplicationStartCode.Start()



Request information:
Request URL: http://localhost/blog/ 
Request path: /blog/ 
User host address: 127.0.0.1 
User:  
Is authenticated: False 
Authentication Type:  
Thread account name: IIS APPPOOL\zService Blog 
Thread information:
Thread ID: 7 
Thread account name: IIS APPPOOL\zService Blog 
Is impersonating: False 
Stack trace:    at System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures)
at System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods)
at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded)
at System.Web.Compilation.BuildManager.ExecutePreAppStart()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)


Custom event details:
Coordinator
Oct 2, 2014 at 5:54 PM
See basic requirements, specifically full trust which most .net 4.5 assemblies required.
Oct 2, 2014 at 6:05 PM
I did that, and the only one I have a question about is the last requirement. I added the full trust in the web.config file. I added the latest version of MVC using NuGet in Visual Studio. Is there another version I should have installed on the server itself?
Oct 2, 2014 at 7:20 PM
Now I'm getting:

Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 10/2/2014 2:15:56 PM
Event time (UTC): 10/2/2014 6:15:56 PM
Event ID: 5b3d14088a8f460c98f0f0329eb57456
Event sequence: 1
Event occurrence: 1
Event detail code: 0

Application information:
Application domain: /LM/W3SVC/4/ROOT/blog-2-130567473501964161 
Trust level: Full 
Application Virtual Path: /blog 
Application Path: C:\inetpub\zservice-blog\ 
Machine name: WINHUB 
Process information:
Process ID: 13280 
Process name: w3wp.exe 
Account name: IIS APPPOOL\zService Blog 
Exception information:
Exception type: InvalidOperationException 
Exception message: The pre-application start initialization method Start on type System.Web.Mvc.PreApplicationStartCode threw an exception with the following error message: Attempt by security transparent method 'System.Web.Mvc.PreApplicationStartCode.Start()' to access security critical method 'System.Web.WebPages.PreApplicationStartCode.Start()' failed..
at System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection1 methods, Func1 setHostingEnvironmentCultures)
at System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods)
at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded)
at System.Web.Compilation.BuildManager.ExecutePreAppStart()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)

Attempt by security transparent method 'System.Web.Mvc.PreApplicationStartCode.Start()' to access security critical method 'System.Web.WebPages.PreApplicationStartCode.Start()' failed.
at System.Web.Mvc.PreApplicationStartCode.Start()



Request information:
Request URL: ---------/blog/ 
Request path: /blog/ 
User host address: -------- 
User:  
Is authenticated: False 
Authentication Type:  
Thread account name: IIS APPPOOL\zService Blog 
Thread information:
Thread ID: 8 
Thread account name: IIS APPPOOL\zService Blog 
Is impersonating: False 
Stack trace:    at System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures)
at System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods)
at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded)
at System.Web.Compilation.BuildManager.ExecutePreAppStart()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)


Custom event details:
Oct 3, 2014 at 3:26 PM
We figured this out. It was an issue with web.config inheritance. The blog was in a /blog directory, and it was picking up the web.config settings from the parent directory, /. The app in the parent directory is running on an older version of .Net.
Marked as answer by lucasajackson on 10/3/2014 at 7:26 AM