Wrote an Asp.Net application using latest Visual Studio 2015 and target framework of .Net 4.5.2. but needed to re-compile it using just .Net 4.5 same as on the web server. Usually fairly simple just open Applications Project properties and change the Target Framework, re-compile and any errors will be apparent. However on running the Web App I see the following in the Browser:-
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: CS1617: Invalid option '6' for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default
[No relevant source lines]
Kind of tells you why it is failing in the Compiler Error Message so check your Web.Config. Find the section on <compilers> and check that is is correct.
Mine looked like this:-
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=18.104.22.168, Culture=neutral, warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701">
<providerOption name="CompilerVersion" value="v4.0"/>
Everything looks OK but the issue is in the section:-
So change this to:-
Recompile and all will be working again.