我今天在PC上安装了Visual Studio 2022。我有一个旧应用,该应用程序针对.NET 4.5。我在尝试构建/编译项目时会看到此错误:
“错误MSB3644找不到.netFramework的参考组件,版本= v4.5。要解决此问题,请安装此框架版本的开发人员包(SDK/Targeting Pack)或重新定位您的应用程序。 “
我已经读过: https://thomaslevesque.com/2021/11/11/12/building-a-project-project-target-target-net-45-inet-45-in-visual-studio-2022/ 。 C:\ Program Files(X86)\ Reference Assemblies \ Microsoft \ Framework.netframework \ V4.5在我的PC上已经存在。
我在此处下载了.NET 4.5开发人员包:。当我尝试运行它时,我会看到这一点:
我还有其他尝试吗?
I have installed Visual Studio 2022 on my PC today. I have an old app, which targets .NET 4.5. I see this error when attempting to build/compile the project:
"Error MSB3644 The reference assemblies for .NETFramework,Version=v4.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks"
I have read this: https://thomaslevesque.com/2021/11/12/building-a-project-that-target-net-45-in-visual-studio-2022/. C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5 already exists on my PC.
I have downloaded the .NET 4.5 Developer Pack here: https://learn.microsoft.com/en-gb/dotnet/framework/install/guide-for-developers. I see this when I attempt to run it:
Is there anything else I can try?
发布评论
评论(2)
因为您可能会首先安装更高版本的.NET框架,因此安装程序可能会阻止您安装较低版本的.NET框架,
因此另一种方法可以尝试修复它而无需重新安装。
microsoft.netframework.referenceassemblies.net45.nupkg
microsoft.netframework.referenceassemblies.net45.zip
和unzip cropredbuild \ .netFramework \ V4.5 \
toc:\ program Files(x86)\ Reference Assemblies \ Microsoft \ Microsoft \ Framework \ .netFramework \ .netframework \ v4.5
运行的 您的项目再次。注意
这种方式也适用于.net4.0 或其他哪个微软可能不支持功能
Because you might install a higher version of .net framework firstly, so installer might stop you install a lower version of .net framework
There is another way can try to fix it without reinstalling.
microsoft.netframework.referenceassemblies.net45.nupkg
tomicrosoft.netframework.referenceassemblies.net45.zip
and Unzip thatbuild\.NETFramework\v4.5\
toC:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5
Note
This way was also work for .net4.0 Microsoft.NETFramework.ReferenceAssemblies.net40 or other older version of .net framework which Microsoft might not support in feature
如果您想要一种不太黑的方式,另一个选择是下载VS2017构建工具,并仅安装.NET Framework 4.5 Targeting Pack(来自Tab单个组件)。这可以与Visual Studio 2022一起使用,因为它安装了需要的参考组件。
If you want a less hacky way, another option is to download the VS2017 Build Tools and install the .NET Framework 4.5 Targeting Pack only (from the tab Individual Components). This works fine with Visual Studio 2022, since it installs the reference assemblies where they are needed.