[英]Compiler refuses to compile after I retarget a .NET 6 project to .NET Framework 4.8
I have a .NET 6 project.我有一个 .NET 6 项目。 I want to retarget it to .NET 4.8.
我想将其重新定位到 .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).在第 1 行,来自我的项目文件夹中名为CSC的文件(奇怪的是,CSC 是编译器的名称,而我没有这样的文件)。 I am not using nullable types surely and this error is not correct IMO.
我肯定没有使用可空类型,而且这个错误是不正确的 IMO。 What do I do?
我该怎么办?
EDIT: @RahulSharma's answer isn't valid.编辑:@RahulSharma 的回答无效。 It doesn't work, produces another error.
它不起作用,产生另一个错误。
This error is shown when your project settings reference the language version 7.3.当您的项目设置引用语言版本 7.3 时会显示此错误。 I assume you can verify this by right-clicking your project & choose properties, build, advanced in VS.
我假设您可以通过右键单击您的项目并在 VS 中选择属性、构建、高级来验证这一点。 If the language version is shown as 7.3, you need to change this so it match the framework version you use.
如果语言版本显示为 7.3,则需要更改它以匹配您使用的框架版本。 Howver you cannot change this in the VS dialogue, so you need to do this manually.
但是,您无法在 VS 对话框中更改此设置,因此您需要手动执行此操作。 Unload your project and open the project file as a file, and then add the
<LangVersion>latest</LangVersion>
in the <PropertyGroup>
section.卸载项目并将项目文件作为文件打开,然后在
<PropertyGroup>
部分添加<LangVersion>latest</LangVersion>
。 See the full documentation of language versions for each .NET framework version here在此处查看每个 .NET 框架版本的语言版本的完整文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.