Social Icons

Friday, 29 September 2017

[SOLVED] access denied can not execute the program csc.exe after publishing .net application web deploy mvc app

Hi, Recently i encountered this error after publishing an application to winhost server.

Error stacktrace is
[Win32Exception (0x80004005): Access is denied]

[ExternalException (0x80004005): Cannot execute a program. The command being 
executed was "E:\web\nrgwareh\bin\roslyn\csc.exe"

It is an mvc application using visual studio 2017 , targeted framework is 4.6.2.

I just published using webdeploy method. it is successfully deployed but when i try to run i encountered this one like

when i run locally its working fine. But here problem is winhost doesn't allow csc.exe to run which is roslyn compilation.

When we create a web application either webforms or mvc using .net framework 4.5 > then project is pre installed with roslyn csc.exe compilation. although it was successfully published to hosting environment, but some servers doesn't allow to run that roslyn compiler.

Solution 1:

Here solution is just compile and deploy project without any roslyn or any csc.exe files.

just go to Nuget manager, find  the package Microsoft.CodeDom.Provider.DotnetCompilerPlatform , uninstall it.



Now rebuild and re publish, then this problem gone away.

Solution 2:

In some hosting environments we have option to allow or run csc.exe files, just change that setting or allow read/write to exe files, it get's fixed.

Hope it can be useful to some folks.





No comments:

Post a Comment

Please Give your Valuable Suggestions,Questions and Comments to improve my blog.