1、修改项目配置文件(.csproj)
要修改的版本是4.7.1,则写net471;要修改的版本是4.8,则写net48。
2、修改完,重新加载项目,在项目属性里可切换目标框架。
3、更改完目标框架,重新加载项目时,报错提示 当前上下文中不存在名称“ApplicationConfiguration” 注释即可
4、修改完目标框架后可能会出现:
无效的 nullable 值: C# 7.3 的“Enable”。请使用语言版本 8.0 或更高版本。
在1、修改项目配置文件(.csproj) 中 <PropertyGroup>下添加 <LangVersion>8.0</LangVersion>
5、又出错:命令空间"System.Net"中不存在类型或命名空间名"Http"(是否缺少程序集引用?)
检查到obj\Debug\net471 路径下XXX.GlobalUsings.g.cs
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.Drawing;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
global using global::System.Windows.Forms;
auto-generated :自动生成
在1、修改项目配置文件(.csproj) 中 <PropertyGroup>下添加 <ImplicitUsings>disable</ImplicitUsings>
重新加载项目