Error publishing web site

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.

Visual Studio – “Could not run the GenerateResource” after conversion

Problem:
After a project upgrade/update/convert you receive the following error on Build:

Could not run the “GenerateResource” task because MSBuild could not create or connect to a task host with runtime “CLR2? and architecture “x86?. Please ensure that (1) the requested runtime and/or architecture are available on the machine, and (2) that the required executable “C:\Program Files (x86)\MSBuild\12.0\bin\MSBuildTaskHost.exe” exists and can be run.

Solution:
Edit your project file (.csproj | .vbproj) with a text editor such as Notepad.
Manually add this line at the end of the first PropertyGroup node:

<PropertyGroup>

<DisableOutOfProcTaskHost>true</DisableOutOfProcTaskHost>
</PropertyGroup>