简体   繁体   English

在我将 .NET 6 项目重新定位到 .NET Framework 4.8 后,编译器拒绝编译

[英]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.

相关问题 将 .NET Framework 4.6.1 更新到 4.8 后出错 - Error after updating .NET Framework 4.6.1 to 4.8 升级到 .NET Framework 4.8 后重新创建证书 - Certificate recreation after upgrading to .NET Framework 4.8 将 .NET 5 库中的 UserControl 加载到 .NET Framework (4.8) 项目中 - Loading a UserControl from a .NET 5 library into .NET Framework (4.8) Project 将项目从 .NET5 转换为 .NET Framework 4.8 - Converting a project from .NET5 to .NET Framework 4.8 从 .Net Framework 4.7 升级到 4.8 后使用 MSBuild 发布项目时出错 - Error in publishing project with MSBuild after upgrading from .Net Framework 4.7 to 4.8 如何从 .NET Framework 4.8 项目创建 .EXE 文件? - How can I create an .EXE file from .NET Framework 4.8 project? 如何在 Visual Studio 2015 中为 .NET Core 应用程序重新定位框架? - How can I retarget the framework for a .NET Core application in Visual Studio 2015? WiX 引导程序项目上的 .NET 4.8 框架安装问题 - Issue with .NET 4.8 framework installation on WiX bootstrapper project 我将我的项目升级到 .NET Framework 4.8 和新的包格式,现在我收到一条错误消息,提示 System.Net.Http 丢失 - I upgraded my project to .NET Framework 4.8 and the new package format, and now I get an error saying System.Net.Http is missing 接口中的层次结构 (.NET Framework 4.8) - Hierarchy in Interfaces (.NET Framework 4.8)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM