我的 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