【问题标题】:Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'无法加载文件或程序集“System.Runtime,版本=4.0.0.0,文化=中性,PublicKeyToken=b03f5f7f11d50a3a”
【发布时间】:2018-02-05 18:56:14
【问题描述】:

我的 VisualStudio 2017 Wep API 项目出现此错误:

无法加载文件或程序集 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 或其之一 依赖关系。定位程序集的清单定义不 匹配程序集引用。 (HRESULT 异常:0x80131040)

堆栈跟踪:

=== Pre-bind state information ===
LOG: DisplayName = System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 (Fully-specified)
LOG: Appbase = .../WebApp/
LOG: Initial PrivatePath = ...\bin
Calling assembly : System.Runtime.CompilerServices.Unsafe, Version=4.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: ...\web.config
LOG: Using host configuration file: ...\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.0.0 redirected to 4.1.1.0.
LOG: Post-policy reference: System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/30ca8c3f/b4b96212/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/30ca8c3f/b4b96212/System.Runtime/System.Runtime.DLL.
LOG: Attempting download of new URL file:///D:/DSTS/WF/WF1_0/WebApp/bin/System.Runtime.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

无法准确确定何时发生,但可能是在更新到 Visual Studio(到版本 15.3.2)或更新了 wep Api 包之后。

出现了一些其他问题,我已经解决了,但现在我陷入了这个错误。调用程序集是System.Runtime.CompilerServices.Unsafe。 我的第一个猜测是降级这个包和依赖它的包,女巫我已经做过但没有成功。

我还尝试重新安装解决方案中的所有包,检查失败的程序集引用(有一些),检查重复的包版本。没有运气。

更新: 经过几次颠簸后,System.Runtime 现在出现在参考文件夹中,但标记为黄色(缺失)。我只是重新安装了“System.Runtime”包,所以要么我的解决方案已损坏,要么包作为错误。 目标框架是 4.7

【问题讨论】:

    标签: visual-studio asp.net-web-api2 visual-studio-2017 compiler-services


    【解决方案1】:

    就我而言,当使用 Visual Studio 2017 打开解决方案并收到此错误时,要解决此问题,我必须结合以下内容:

    1) 在“C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe.config”中

    找到任何出现的 "..\..\MSBuild" 并将其替换为 “C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild”

    2) 我注意到我的 Microsoft.Build.Framework.dll 从文件夹中丢失,进行了搜索并在下面找到它 “C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\”。 将其复制到“C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE”

    3) 同样,在 deven.exe.config 中,已更改

    codeBase version="15.1.0.0" href="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Build.Framework.dll "

    在 amd 文件夹中找到的版本,在我的例子中: codeBase version="15.3.409.57025" href="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Build.Framework.dll" em>

    我假设这与我安装了 VS2017 Enterprise v15.3 的事实有关,并且某些东西已经损坏或者是一个错误。

    在任何情况下,这都不是永久修复,但现在它对我来说很好,并且已经解除了我的进度。如果我有新发现会更新。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-11-19
      • 1970-01-01
      • 2017-03-07
      • 2021-01-22
      • 2018-06-27
      • 1970-01-01
      相关资源
      最近更新 更多