Can I use C# 7.3 with .Net Framework 4.6.1?
Asked Answered
B

1

9

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.

Bobbybobbye answered 20/9, 2018 at 8:39 Comment(13)
The answer is yes but your compiler version must support c#7. What compiler version/vs version are you using?Bryner
this depends on your C# compiler version rather than your .NET versionContented
How I can find version of current compiler and install needed one?Bobbybobbye
which version of VS are you using?Legpull
It's a VS 2017, version 15.8.4.Bobbybobbye
THen it support it assuming you did all the updates. check the project properties and select 7.3 as langauge version.Girard
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.Frostbitten
Already, but still getting an error.Bobbybobbye
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.Frostbitten
Looks like restarting VS helps. Sorry for fake alarm, guys. upd.: Oh no, it not. Again error.Bobbybobbye
Installed 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.Bobbybobbye
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.Discordance
@TrolltheLegacy Please post that as an answer to your own question.Glaikit
B
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.

Bobbybobbye answered 25/9, 2018 at 10:37 Comment(1)
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.Unhelm

© 2022 - 2024 — McMap. All rights reserved.