Reputation: 3364
I have a question that is very similar to this: VS 2015, C# 6, MVC5, Roslyn -- 502 gateway errors on Azure web app so please don't mark this as a duplicate.
My situation is exactly the same as in that previous question: VS 2015, C# 6, MVC5, Roslyn, very slow website with 502 gateway errors, CodeDOM compiler Nuget package, Azure Web App with git continuous deployment. Additionally, I am getting compilation errors like this:
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 -532462766.
Show Detailed Compiler Output:
D:\Windows\system32>D:\home\site\wwwroot\bin\roslyn\csc.exe /t:library /utf8output /nostdlib+ /R:"D:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" /R:"D:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll" etc. for about four pages.
I have tried deleting obj and bin folders using Kudu. This seems to fix it for a short while until I go to a certain page and the problems start over again.
I don't really want to downgrade to C#5 because I like using nameof. Please help.
EDIT: I just found out that it's only using C# 6 features like nameof in the views that causes the problems, the rest of the project was using C# 6 fine. I uninstalled the CodeDOM package and reverted everything and it all works fine. But I really want C# 6 to work in the views.
Upvotes: 0
Views: 492
Reputation: 10940
The issue with the CodeDom package is that is copies the roslyn binaries into the \bin folder of your app, and tries to execute csc.exe from there, but it doesn't have the rights to do so.
The correct solution to this is to precompile your views before deploying them to the server. There are numerous existing guides on how to do that. For running StackOverflow we use StackExchange.Precompilation.
Besides supporting precompilation, it also includes a custom view engine that uses roslyn to compile the views in-memory in the app itself, instead of calling out to another process (csc.exe) to do so.
Upvotes: 1