簡體   English   中英

無法在Visual Studio WebApi項目上加載System.runtime dll

[英]Failure to load System.runtime dll on Visual studio WebApi project

當我運行門戶網站時,出現以下錯誤:

無法加載文件或程序集“ System.Runtime,版本= 4.0.0.0,區域性=中性,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 = file:///D:/.....
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: ....\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: The same bind was seen before, and was failed with hr = 0x80131040. 

System.Runtime是Microsoft軟件包,屬於webapi項目。

觀察預綁定狀態信息它表明system.runtime DLL被從稱為System.Runtime.CompilerServices.Unsafe DLL。 還進行以下重定向:

日志:在應用程序配置文件中找到重定向:4.0.0.0重定向到4.1.1.0。

System.Runtime軟件包的版本為4.3.0,並生成dll版本4.1.1.0。 這是我的第一個疑問。 我的東西dll版本應該是4.3.0.0,但是用ILSpy檢查后,它的Assembly版本屬性是4.1.1.0

Web配置重定向正確,它將調用重定向到版本4.0.0.0到版本4.1.1.0,如預綁定日志中所示

奇怪的是System.Runtime沒有顯示在項目的引用中。 如果我手動添加,它將顯示一個黃色圖標(失敗)。

怎么了 我還能檢查什么?

發現該問題是由版本沖突引起的,而不是我所預期的不兼容版本。

Follow build警告暴露了沖突。 只需雙擊警告消息即可將綁定會話修復為Web沖突。

警告在同一從屬程序集的不同版本之間發現沖突。 在Visual Studio中,雙擊該警告(或選擇它並按Enter)以解決沖突; 否則,將以下綁定重定向添加到應用程序配置文件中的“運行時”節點:...

我不確定Visual Studio是否能夠檢測到所有構建沖突,因此,同樣的錯誤也可能導致缺少此警告。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM