I'm interested in enum
generic constraints, but when I'm switching language version for project on Build → Advanced I'm still getting error «not available in C#5; please use language version 7.3 or greater» even after reopening the project.
Project type is an ASP.NET MVC application.
Asked
Active
Viewed 5,862 times
9

Troll the Legacy
- 675
- 2
- 7
- 22
-
6The answer is yes but your compiler version must support c#7. What compiler version/vs version are you using? – pinkfloydx33 Sep 20 '18 at 08:40
-
6this depends on your C# compiler version rather than your .NET version – ADyson Sep 20 '18 at 08:41
-
1How I can find version of current compiler and install needed one? – Troll the Legacy Sep 20 '18 at 08:41
-
which version of VS are you using? – MakePeaceGreatAgain Sep 20 '18 at 08:42
-
It's a VS 2017, version 15.8.4. – Troll the Legacy Sep 20 '18 at 08:42
-
THen it support it assuming you did all the updates. check the project properties and select 7.3 as langauge version. – TomTom Sep 20 '18 at 08:45
-
If the compiler can tell you that you use the wrong version then you have the right compiler. But not the right version. Change this build setting for both the Debug and the Release configuration, combobox at the top of the Build tab. – Hans Passant Sep 20 '18 at 08:46
-
Already, but still getting an error. – Troll the Legacy Sep 20 '18 at 08:47
-
You are doing *something* wrong, but it is unguessable from the question. Try this first on a new project. Next ask a co-worker to look over your shoulder, he might see something. – Hans Passant Sep 20 '18 at 08:50
-
Looks like restarting VS helps. Sorry for fake alarm, guys. upd.: Oh no, it not. Again error. – Troll the Legacy Sep 20 '18 at 08:51
-
1Installed *Compilers* and *CodeDom.DotNetPlatform*, then changed in web.config `system.codedom → compilers → compiler language="c#;cs;csharp"` property `langversion` to `7.3` and all works. – Troll the Legacy Sep 21 '18 at 14:20
-
When dealing with ASP.NET, that does dynamic compilation at runtime, you have two compilers in play, the one used by msbuild/Visual Studio/whatever, and the one running at runtime, your package installation dealt with the runtime compiler, you likely already had the right IDE compiler. – Lasse V. Karlsen Sep 25 '18 at 06:42
-
1@TrolltheLegacy Please post that as an answer to your own question. – Ian Kemp Sep 25 '18 at 07:31
1 Answers
3
I've installed Microsoft.Net.Compilers
and Microsoft.CodeDom.Providers.DotNetCompilerPlatform
packages from Nuget, then changed in web.config system.codedom → compilers → compiler language="c#;cs;csharp"
property langversion
to 7.3
, reloaded project and all worked.

Troll the Legacy
- 675
- 2
- 7
- 22
-
not working for me, already updated both `Microsoft.Net.Compilers` and `Microsoft.CodeDom.Providers.DotNetCompilerPlatform` to the latest version which is `v3.6.0` at the moment. The `langversion` is correctly set to `7.3` but still cannot build the project. – Hopeless Jul 12 '20 at 10:00