Compilation Error when change .Net framework from 4.5.2 to 4.5 in VS 2015 Community edition
I am answering my question just to let other user know what's the solution. After some googling and personal research. So I precisely did two thing.
- Go to each project property -> Build -> Advance and change the language version to C# 5.0
- Open web.config for the startup project (MVC in my case) and remove the codedom section that contain the custom compile information
This fix my issue.
C# in Visual Studio 2015 is C# 6.0, however the error message you're getting is from the ASP.NET Compiler (not the Visual Studio compiler) informing you that C# 6.0 is not available, only C# up-to version 5, so not version 6.
I suspect this error message is coming from your webhosting provider, which means they haven't installed the very latest version of the .NET Framework on their systems, you'll need to downgrade your C# language compilation options in your web.config back to what they were before and refrain from using any C# 6.0 language features in runtime-compiled code. I don't know what effect running C# 6.0 language-features in a .NET 4.5.0 environment will have if they rely on any new CLR instructions.
Update:
Alternatively, ensure you're using the latest version of the Microsoft.Net.Compilers
NuGet package, which causes the latest version of csc
to be bundled with your project when deployed, so it will have support for C# 6, 7, 8, etc.