0

當我運行它提供了以下錯誤門戶:未能加載在Visual Studio中的WebAPI項目System.runtime DLL

Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from 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是微軟的包是的WebAPI項目的一部分。

觀察預綁定狀態信息,它顯示從System.Runtime.CompilerServices.Unsafe dll調用system.runtime dll。還有以下重定向由:

LOG: Redirect found in application configuration file: 4.0.0.0 redirected to 4.1.1.0.

System.Runtime包的版本是4.3.0,並生成DLL版本4.1.1.0。 這是我第一個懷疑。我的事情DLL版本應該是4.3.0.0但ILSpy檢查它表明大會版本屬性是4.1.1.0

Web配置重定向是正確的,它重定向爲調用4.0.0.0版本4.1.1.0版本 在預先綁定日誌中顯示

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

這裏有什麼問題?我還能檢查什麼?

+0

您是否檢查了packages.config中的版本? – Nova

+0

它指向版本4.3.0。 – ByteArtisan

+0

我假設你已經嘗試重新安裝軟件包? – Nova

回答

-1

發現問題是由版本衝突造成的,而不是由於我預期的不兼容版本造成的。

下面的構建警告暴露了衝突。只需雙擊警告消息即可解決Web衝突中的綁定會話。

Warning Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: ...

我不知道如果Visual Studio將能夠檢測所有構建衝突,所以不存在這個警告可能仍然由同樣的錯誤引起的。

相關問題