“System.ComponentModel.Win32Exception: Access is denied”

You may encounter the following error after publishing a .net 4.5 or higher application…

System.ComponentModel.Win32Exception: Access is denied [Win32Exception (0x80004005): Access is denied] [ExternalException (0x80004005): Cannot execute a program. The command being executed was “c:\hostingspace\USERNAME\somewebsite\wwwroot\bin\roslyn\csc.exe”

There are 2 solutions that will resolve the issue.

Solution #1

  1. Open NuGet Package Manager window
  2. Uninstall Microsoft.CodeDom.Providers.DotNetCompilerPlatform package and rebuild & republish. (This uninstallation also removes CodeDom configuration from web.config file.)

Solution #2

Remove the system.codedom (and its contents) element from your website’s web.config