我一直在尋找答案,我在程序集解析中檢測到的奇怪行爲無濟於事。我知道CLR會將程序集的引用記錄到其元數據(清單)中。它記錄名稱,版本號,公鑰標記和區域設置。在裝配時加載每個引用的組件被探測和加載。此探針是版本敏感的,換句話說,構建中使用的版本應位於並加載,而不是任何其他版本。如果程序集已簽名,則公鑰也會發揮作用。依賴程序集解析成功,即使使用錯誤的版本號
問題是,在我爲測試而創建的虛擬應用程序中,此規則已損壞!我已經搜索過,谷歌和答案不符合標準。請不要給我下面的原因,解決方法:
- 「特定版本」設置爲False:這僅僅是在編譯的時候真,沒有任何與運行。
- 此外,沒有或應用程序/機器配置集。
在我的測試安裝我有項目A引用項目B.每個版本之後,我改變項目B和只有建立本身,而不是A.現在我複製與更改版本新B.DLL到A的工作目錄並運行A.它的工作原理!我期望它會崩潰。
Fuselogvw.exe的輸出應該不言自明。在日誌中提到,程序集應該查找版本9,但版本8位於並加載!注意行:
LOG:大會名稱爲:dllProj,版本= 1.1.10.8,文化=中立, 公鑰=空
*** Assembly Binder Log Entry (10/8/2014 @ 2:34:51 PM) ***
The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
Running under executable C:\...\Documents\Visual Studio 2013\Projects\test1\test1\bin\Release\test1.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = ...
LOG: DisplayName = dllProj, Version=1.1.10.9, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/.../Documents/Visual Studio 2013/Projects/test1/test1/bin/Release/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : test1, Version=1.1.1.1, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\...\Documents\Visual Studio 2013\Projects\test1\test1\bin\Release\test1.exe.Config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/.../Documents/Visual Studio 2013/Projects/test1/test1/bin/Release/dllProj.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\...\Documents\Visual Studio 2013\Projects\test1\test1\bin\Release\dllProj.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: dllProj, Version=1.1.10.8, Culture=neutral, PublicKeyToken=null
LOG: Binding succeeds. Returns assembly from C:\...\Documents\Visual Studio 2013\Projects\test1\test1\bin\Release\dllProj.dll.
LOG: Assembly is loaded in default load context.
您是否嘗試更改版本號的第一個或第二個元素(主要/次要)? – Leandro 2014-10-08 19:56:28
我很確定發佈者策略可以應用於主要,次要,但程序集解析必須處理完全匹配。但是,在我看來,「私人程序集」並沒有強制版本化? – 2014-10-08 20:06:11