gpt4 book ai didi

visual-studio - MSB3644 找不到框架的引用程序集

转载 作者:行者123 更新时间:2023-12-02 23:44:41 29 4
gpt4 key购买 nike

我收到以下 MSB3644 复杂错误:

The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

根据我读到的内容here ,这是由于我的机器上的程序集存储在“程序文件”而不是“程序文件(x86)”中。 MSBuild 上的 FrameworkPathOverride 属性可以修复此问题。

我尝试将此属性 (FrameworkPathOverride) 添加到 csproj:

<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\tools\common.props" />
<PropertyGroup>
<TargetFrameworks>net40;net45;netstandard1.2</TargetFrameworks>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<FrameworkPathOverride>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0</FrameworkPathOverride>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
<Reference Include="System.Configuration" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System.Configuration" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.2' ">
<DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.2' ">
</ItemGroup>
</Project>

该错误随后消失,但无法解析我的所有类型和命名空间,并且我还收到此构建警告:

MSB3270 There was a mismatch between the processor architecture of the project being built "AMD64" and the processor architecture of the reference "C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

将项目的目标框架设置为 x86 后,警告消失,但仍然无法解析类型或命名空间。

我已经安装了所有必要的框架:

enter image description here

我在 Windows 10 上使用 Visual Studio 2017。

最佳答案

遇到同样的错误。框架版本已正确安装在我的计算机上(运行该特定版本框架的安装程序没有执行任何操作 - 它告诉我它已经安装)。但该框架并未“作为 Visual Studio 的一部分”安装。

是什么为我解决了这个问题:运行VS安装程序(如果丢失,请重新下载from here),在Visual Studio上单击“修改”,转到“单个组件”选项卡,然后检查.NET类别下缺少的内容。

我没有在我的 csproj 上设置任何 FrameworkPathOverride。

关于visual-studio - MSB3644 找不到框架的引用程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45303001/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com