'Compiler refuses to compile after I retarget a .NET 6 project to .NET Framework 4.8
I have a .NET 6 project. I want to retarget it to .NET 4.8. I did it from the project properties. I removed all instances of my code using newer language features. I have clean the solution also
However after doing it, I get an error while compiling
CS8630 Invalid 'nullable' value: 'Enable' for C# 7.3. Please use language version '8.0' or greater
at line 1, from a file called CSC in my project folder (weird, CSC is the name of the compiler, and I have no such file). I am not using nullable types surely and this error is not correct IMO. What do I do?
EDIT: @RahulSharma's answer isn't valid. It doesn't work, produces another error.
Solution 1:[1]
This error is shown when your project settings reference the language version 7.3. I assume you can verify this by right-clicking your project & choose properties, build, advanced in VS. If the language version is shown as 7.3, you need to change this so it match the framework version you use. Howver you cannot change this in the VS dialogue, so you need to do this manually.
Unload your project and open the project file as a file, and then add the <LangVersion>latest</LangVersion> in the <PropertyGroup> section.
See the full documentation of language versions for each .NET framework version here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
