Azure-System.MethodAccessException: Attempt by security transparent method

Today I faced a strange issue, after publishing an empty ASP.NET MVC application to Azure WebSite.

When I tried to browse the page I got an exception like this -

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.

Here is the screenshot

System.MethodAccessException: Attempt by security transparent method

This issue was resolved by changing the file publish options.

File Publish Options

Select the “Remove additional files at destination” checkbox.

Happy Programming :)