Environment: Visual Studio 2013
Situtation: Trying to publish a website with pre-compile option ON.
Error:
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..
Solution:
Delete reference to System.Web.Administration (select it in References folder and press Del)
Note: This error can also happen when launching your website if you published with the option pre-compile set to OFF.