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

47

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#
asp.net
visual-studio-2015
asked on Stack Overflow Feb 3, 2016 by Ahron Moshe Galitzky • edited Feb 3, 2016 by Evan Frisch

14 Answers

91

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!

20

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.

answered on Stack Overflow May 19, 2016 by James Sullivan
17

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
answered on Stack Overflow Feb 11, 2016 by Eris
13

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

answered on Stack Overflow Mar 10, 2016 by kpr
11

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

See this image for details

answered on Stack Overflow Jan 10, 2018 by GuChil • edited Jan 10, 2018 by Mogsdad
10

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

answered on Stack Overflow Mar 21, 2016 by Himanshu Chauhan
10

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.

answered on Stack Overflow Mar 29, 2016 by kbarry
1

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

answered on Stack Overflow Feb 18, 2016 by aethercowboy
1

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

1

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

answered on Stack Overflow May 18, 2017 by RonC
0

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.

answered on Stack Overflow Jan 12, 2018 by Uwe Keim
0

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:

c:\home\web.app.name\wwwroot

The web.app.name folder needed the permission.

answered on Stack Overflow Jul 4, 2018 by Herman Schoenfeld • edited Jul 4, 2018 by Herman Schoenfeld
0

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.

answered on Stack Overflow Mar 26, 2019 by Ahmed Mansour
0

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
answered on Stack Overflow Nov 26, 2019 by Lynn Crumbling

User contributions licensed under CC BY-SA 3.0