Problem:
The following error is encountered after publishing a website:
System.ComponentModel.Win32Exception: Access is denied[Win32Exception (0x80004005): Access is denied]
[ExternalException (0x80004005): Cannot execute a program. The command being executed was "E:\someDirectory\myWebsite.com\wwwroot\bin\roslyn\csc.exe"
Solution:
Change the .NET application's framework version to 4.5.
Also erase the <compiler> section from the web.config if it's throwing an error when you build.
Explanation:
This happened to me when running Visual Studio 2015, and publishing my website with a .NET version of 4.5.2, on my Personal Class ASP server on Arvixe. I noticed the problem did not happen when I was using a different computer with an older version of Visual Studio 2015 CTP. I noticed that the non-working version of VS was setting the target framework to 4.5.2, but the version of VS that was working for me had it set to 4.5.
The version that did not work is:
Microsoft Visual Studio Enterprise 2015
Version 14.0.23107.0 D14REL
Microsoft .NET Framework
Version 4.6.00081
The version that did work is:
Microsoft Visual Studio Ultimate 2015 CTP
Version 14.0.22609.0 D14REL
Microsoft .NET Framework
Version 4.6.00030
To fix this, open up Visual Studio. Open the Solution Explorer.
Right click on "WebApplication1" (or whatever you named your app) and then click on "Properties".
You'll be presented with the following window.
Ensure that "Target Framework" is set to 4.5. Hit Ctrl+S to save.
If you previously built with a target framework of 4.5.2, you may have a <compiler> section in your web.config, and this may throw an error when you build. Just remove this section to fix the issue. Removing it should not cause any problems.
That solved it for me. It may not solve it for you depending on the configuration of IIS on the server you're deploying to. If it didn't work, check below for other things I tried that didn't work for me but may work for you!
The version that did not work is:
Microsoft Visual Studio Enterprise 2015
Version 14.0.23107.0 D14REL
Microsoft .NET Framework
Version 4.6.00081
The version that did work is:
Microsoft Visual Studio Ultimate 2015 CTP
Version 14.0.22609.0 D14REL
Microsoft .NET Framework
Version 4.6.00030
Right click on "WebApplication1" (or whatever you named your app) and then click on "Properties".
You'll be presented with the following window.
Ensure that "Target Framework" is set to 4.5. Hit Ctrl+S to save.
If you previously built with a target framework of 4.5.2, you may have a <compiler> section in your web.config, and this may throw an error when you build. Just remove this section to fix the issue. Removing it should not cause any problems.
That solved it for me. It may not solve it for you depending on the configuration of IIS on the server you're deploying to. If it didn't work, check below for other things I tried that didn't work for me but may work for you!
Other things I tried that didn't work:
- In IIS, Enabled Basic Authentication, disabled Integrated Windows Authentication.
- In VS when publishing using Web Deploy, I selected to exclude app_data files.
- Tried running VS as admin
- In IIS, checked "Enable write permissions" and "enable directory browsing",
- Deleted everything from wwwroot and published again
- Changed platform target from "any cpu" to x86 in web application build settings.
- Changed platform target from "any cpu" to x64 in web application build settings.
Thanks dude, you are my hero today!
ReplyDeleteExcellent! I'm glad I could help. Thanks for letting me know :)
DeleteThis comment has been removed by a blog administrator.
DeleteThank you for posting this. You saved me.
ReplyDeleteA huge thanks for this!
ReplyDeleteHi Brendan. Thanks for your post. This solution did not work for me, however, but this solution did (per this post on Stack Overflow https://stackoverflow.com/questions/35184429/problems-publishing-a-website-on-smarterasp-net-with-csc-exe-file-included/35207055#35207055 )
ReplyDelete"Since the .NET 4.5 version, Roslyn compilation is the default way of compiling. This means if you create any web application either Web Forms or MVC using .NET 4.5 you get this Roslyn csc.exe compilation pre-installed in your project.
Basically what i needed was to compile and deploy my project without Roslyn or any .exe files on it.
So here is the Solution that worked for me. You can deploy without Roslyn with no change in code:
Open NuGet Package Manager window
uninstall Microsoft.CodeDom.Providers.DotNetCompilerPlatform package and rebuild & republish. (This uninstallation also removes CodeDom configuration from web.config file.)"
thanks a million! saved me!
DeleteThank you for this info!
DeleteThis comment has been removed by the author.
DeleteThank you, uninstalling Microsoft.CodeDom.Providers.DotNetCompilerPlatform works for me
DeleteThanks dude. I waste 5 hours to find solution
ReplyDeleteThanks for tracking down that solution. Very helpful.
ReplyDeleteYou hero! Excellent work listing the stuff that -didn't- work. May be the answer(s) next time.
ReplyDeleteThank you, it's works on my godaddy Web server.
ReplyDeleteThank you, it was really helpful!
ReplyDeleteThank you very much. It is really helpfully.
ReplyDeleteYou are great help. Thank you
ReplyDeletegreat
ReplyDeleteNice info, thanks for sharing.
ReplyDeletereally thanks very much you are my hero today too.
ReplyDelete