无法更改目标框架(无法解析mscorlib)



我打开了一个新项目,我注意到目标框架是net 5。我曾经在4.7.2工作,所以我搜索了它,没有找到它。知道我有两个项目,我使用4.7.2,他们工作得很好,我试图修改。vbproj文件,使其像这样

<TargetFramework>net472</TargetFramework>

.net的所有版本都出现在我重新启动项目后,但当我修改表单设计时出现错误消息

Could not resolve mscorlib for target framework '.NETFramework,Version=v4.7.2'.  This can happen if the target framework is not installed or if the framework moniker is incorrectly formatted.

在Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse . .(IDesignTimeAssemblyLoader, IVsDesignTimeAssemblyResolution, IVsDesignTimeAssemblyResolution, IVsSmartOpenScope分发器)在Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse。GetUniverse(IDesignTimeAssemblyLoader, IVsDesignTimeAssemblyResolution, IVsDesignTimeAssemblyResolution, IVsSmartOpenScope分发器)在Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider . .(IVsDesignTimeAssemblyResolution assemblyResolution, IDesignTimeAssemblyLoader assemblyLoader, TypeDescriptionProvider parentProvider, IVsSmartOpenScope openScope)在Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.get_TargetFrameworkProvider ()在Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService。GetProvider(类型类型)在System.ComponentModel.Design.Serialization.DesignerSerializationManager。方法(字符串typeName)在System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager。方法(字符串typeName)在System.ComponentModel.Design.Serialization.TypeCodeDomSerializer。反序列化(IDesignerSerializationManager管理器,CodeTypeDeclaration声明)在System.ComponentModel.Design.Serialization.CodeDomDesignerLoader。PerformLoad (IDesignerSerializationManager经理)在Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader。PerformLoad (IDesignerSerializationManager serializationManager)——抛出异常的前一个位置的堆栈跟踪结束——在Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader。PerformLoad (IDesignerSerializationManager serializationManager)在Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents。OnLoadCompleted (Int32 fReload)

我删除了这个表单,并创建了一个新的表单,希望它能工作,但问题没有解决。这个问题的原因是什么?

您不能(轻松地)将项目从。net 5.0更改为。net Framework 4.8或更早版本。这是因为。net 5.0是。net核心,而不是。net框架。如果你想以。net框架为目标,那么你必须首先创建一个以。net框架为目标的项目。在创建新项目时,请注意使用的项目模板。如果名称包含"(.NET)"那么这就是。net Core,通常默认为。net 5.0,但可以更改为。net Core 3.1或更早的版本。如果你想以。net Framework为目标,那么选择一个带有"(的项目模板。净框架)";

最新更新