Problems publishing a website on smarterasp.net with csc.exe file included?

C#asp.netVisual Studio-2015

C# Problem Overview


I am using Microsoft Visual Studio 2015, I built a simple website with a C# contact form. When I compile and run on localhost it works perfectly fine. However, when I try to publish it (on smarterasp.net) I am getting an error:

>[Win32Exception (0x80004005): Access is denied] > >[ExternalException (0x80004005): Cannot execute a program. The command being executed was "..\bin\roslyn\csc.exe"

I have contacted smarterasp.net and they said they dont allow .exe files. I tried to delete csc.exe with ftp from the server but when I do that I am getting the error:

>Could not find file "..\bin\roslyn\csc.exe".

How can I solve this issue with the csc.exe that is trying to get included in my project so I can get my this website published?

C# Solutions


Solution 1 - C#

After hours of researching i came up with the solution.

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:

  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.)

This will solve your purpose. Basically this will not generate any csc.exe, vbc.exe files inside bin folder.

I hope it works for you too!

Solution 2 - C#

I had this issue on Smarter ASP. On the browser file manager in the control panel, navigate to 'Roslyn' folder in bin and set .net permission to read/write. It worked then.

Solution 3 - C#

If you actually want to keep the roslyn codegen, you just need to set the permissions on the application's bin folder to allow the ApplicationPool user Read & Execute.

I did this using the explorer Security tab on the folder properties dialog, but you should also be able to do something like:

icacls PATH_TO_SERVICE_BIN /grant "ApplicationPoolUser":(OI)(CI)RX

Solution 4 - C#

I found the solution as unchecking "Allow precompiled site to be updatable", on publish window. enter image description here

Solution 5 - C#

Just remove the codedom section from the Web.config, this solves the problem.

Solution 6 - C#

Just set rw access for /bin folder in Smarterasp.net File Manager as shown below, restart your app

See this image for details

Solution 7 - C#

Just experienced the same issue as the OP when publishing an ASP.net 4.5.2 SPA via web deploy in VS2015.

The solution I found to work was to remove the Nuget package "Microsoft.CodeDom.Providers.DotNetCompilerPlatform".

You could, alternatively, simply remove the system.codedom compiler config section from your Web.config file, which would have the same affect.

Solution 8 - C#

Here's how I got it working:

  1. In your control panel, navigate to Security Manager > Allow .EXE Files

  2. Set the value to On (this will let you upload .exe files)

  3. In your Web.config, set full trust (this will let you run them)

     <configuration> 
       <system.web> 
         <trust level="Full" /> 
       </system.web> 
     </configuration> 
    
  4. In your publish settings, enable "Precompile during publishing", but in the Advanced Precompile Settings (the Configure link next to this option), disable "Allow precompiled site to be updateable".

Solution 9 - C#

I had the same error and I solved it by enable the permissions of the hosting directory (read/write/delete).

Solution 10 - C#

If you need SmarterAsp.Net to allow the uploading of an .exe file to support the features and functionality of your website, you can. Just go to the control panel and turn on "Allow .Exe Files" See below:

enter image description here

In my case I had to do this because I wanted to host an Asp.Net Core website and that absolutely requires an .exe file :-)

Solution 11 - C#

tl;dr: Ensure that csc.exe is not zero bytes in size.


Longer answer

To add yet another cause and solution: In my case, I got this Yellow Screen Of Death in my browser:

> Server Error in '/' Application. > > Compilation Error > > Description: An error occurred during the compilation of a resource > required to service this request. Please review the following specific > error details and modify your source code appropriately. > > Compiler Error Message: The compiler failed with error code 255. > > c:\windows\system32\inetsrv>C:\inetpub\wwwroot\bin\roslyn\csc.exe > /t:library /utf8output /nostdlib+ ... > > Version Information: Microsoft .NET Framework Version:4.0.30319; > ASP.NET Version:4.7.2558.0

Upon investigation, I isolated the call to csc.exe by executing it inside a CMD window:

c:\inetpub\wwwroot\bin\roslyn\csc.exe

I got this message box:

enter image description here

followed by this line in the CMD window:

> Access is denied.

Upon inspecting the files in Windows File Explorer I found out that csc.exe had a size of zero bytes.

I'm unsure at which stage of my deployment script this happens, but after replacing the 0-byte-sized csc.exe with an actual working one, everything works correctly.

Solution 12 - C#

The above solutions did not work for me and are not correct, since roslyn is not optional these days.

What worked was ensuring that the pool account had read & execute permissions on the root folder of the web application. You can find the account to grant this permission to by finding the Pool name your web app uses, then Application Pool -> pool name -> Advanced Settings -> Identity.

My VPS host uses non-standard directories for hosting as follows:

The web.app.name folder needed the permission.

Solution 13 - C#

Updating the nuget package Microsoft.CodeDom.Providers.DotNetCompilerPlatform to the latest version (at that time) 2.0.1 resolved this issue for me without having to grant permissions to the folder or remove the compiler.

Solution 14 - C#

We encountered this due to a 3rd party application. MalwareBytes Anti-Ransomeware was actually the culprit that was blocking access. Resolved this with:

  • Right-click systray icon for MalwareBytes Anti-Ransomeware (not anti-exploit)
  • Stop Protection

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAhron M. GalitzkyView Question on Stackoverflow
Solution 1 - C#Ahron M. GalitzkyView Answer on Stackoverflow
Solution 2 - C#James SullivanView Answer on Stackoverflow
Solution 3 - C#ErisView Answer on Stackoverflow
Solution 4 - C#kprView Answer on Stackoverflow
Solution 5 - C#Himanshu ChauhanView Answer on Stackoverflow
Solution 6 - C#GuChilView Answer on Stackoverflow
Solution 7 - C#k-devView Answer on Stackoverflow
Solution 8 - C#aethercowboyView Answer on Stackoverflow
Solution 9 - C#Hasan Khaled Al-BzoorView Answer on Stackoverflow
Solution 10 - C#RonCView Answer on Stackoverflow
Solution 11 - C#Uwe KeimView Answer on Stackoverflow
Solution 12 - C#Herman SchoenfeldView Answer on Stackoverflow
Solution 13 - C#Ahmed MansourView Answer on Stackoverflow
Solution 14 - C#Lynn CrumblingView Answer on Stackoverflow