【问题标题】:System assemblies not found for .Net v3.5 when starting new project or trying to open existing one启动新项目或尝试打开现有项目时找不到 .Net v3.5 的系统程序集
【发布时间】:2020-07-26 11:31:25
【问题描述】:

当我尝试打开以 .Net 3.5 为目标的现有项目或创建一个以它为目标的新项目时,Visual Studio 找不到一些 .Net Framework 程序集:

如您所见,SystemSystem.DataSystem.DrawingSystem.Runtime.SerializationSystem.Xml 未找到。

我在构建时遇到的错误类似于

Warning MSB3267 The primary reference "System", which is a framework assembly, could not be resolved in the currently targeted framework. ".NETFramework,Version=v3.5". 
To resolve this problem, either remove the reference "System" or retarget your application to a framework version which contains "System".  

如果我将项目重新定位到 .Net v4.5 之类的东西,则可以找到所有程序集,但我需要它以 v3.5 作为目标进行构建。

我尝试解决的问题: 1) 我确保在 Windows 功能中启用了 .Net3.5:

2) 我确保在 Visual Studio 中安装了 3.5 开发工具:

3) 我尝试从microsoft installation file手动安装.Net v3.5

到目前为止,这些步骤都没有帮助。我尝试手动搜索这些丢失的 dll,并在 C:\Windows\Microsoft.NET\Framework 的各个子文件夹中找到它们,主要在 C:\Windows\Microsoft.NET\Framework\v2.0.50727 中。

解决此问题的正确方法是什么?如何将 VS 指向程序集?我的设置有问题吗?

软件版本: Visual Studio Community 2019 v16.53,Windows 10 Pro,有一些新更新

【问题讨论】:

标签: c# visual-studio windows-10 .net-3.5


【解决方案1】:

四处询问后,我被告知这是 msbuild 中一个古老且已知的错误,有很多可能的解决方法:https://github.com/microsoft/msbuild/issues/1333

我个人使用自定义 FrameworkPathOverride: https://github.com/microsoft/msbuild/issues/1333#issuecomment-296346352, e.d.我已经将这个 XML 片段添加到我的 .csproj 中,它就像一个魅力:

<PropertyGroup>
  <FrameworkPathOverride Condition="'$(TargetFramework)' == 'net35'">$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
</PropertyGroup>

之后,卸载/加载项目,我就可以开始了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-05
    • 2018-11-10
    • 2017-05-12
    • 2023-02-13
    • 1970-01-01
    • 2011-12-21
    • 1970-01-01
    • 2019-01-19
    相关资源
    最近更新 更多