2012-06-04 133 views
15

我在部署引用程序集的應用程序時出現了一個奇怪的問題,它使用託管C++編寫。System.IO.FileNotFoundException:在部署應用程序時無法加載文件或程序集「X」或其某個依賴關係

我創建了一個程序集X,編譯它並在一個名爲Starter的exe文件中引用它。

Starter.exe在本地mashine上正常啓動。然而,當我啓動debug文件夾中的所有內容複製到虛擬mashine,並嘗試那裏開始它,它與下面的異常崩潰:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or 
assembly 'X' or one of its dependencies. The specified module could not be found. 

這沒有任何意義,我,因爲X是正確的在與Starter.exe相同的文件夾中。

什麼可能導致此問題?

UPDATE

我檢查了依賴於反射器在目標機器上,這是能夠找到的文件,所有這些的。

我也改變了所有項目的配置爲x86/win32。

UPDATE

以下是自Fusion日誌的日誌(位置:C:\ FusionLog \默認\ Starter.exe \ X,版本= 1.0.4538.22813文化=中性公鑰= null.HTM) :

*** Assembly Binder Log Entry (6/4/2012 @ 1:56:13 PM) *** 

The operation was successful. 
Bind result: hr = 0x0. The operation completed successfully. 

Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll 
Running under executable C:\Documents and Settings\Administrator\Desktop\tmp\k;k\Starter.exe 
--- A detailed error log follows. 

=== Pre-bind state information === 
LOG: User = MENKAUR-7683827\Administrator 
LOG: DisplayName = X, Version=1.0.4538.22813, Culture=neutral, PublicKeyToken=null 
(Fully-specified) 
LOG: Appbase = file:///C:/Documents and Settings/Administrator/Desktop/tmp/k;k/ 
LOG: Initial PrivatePath = NULL 
LOG: Dynamic Base = NULL 
LOG: Cache Base = NULL 
LOG: AppName = Starter.exe 
Calling assembly : Starter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. 
=== 
LOG: This bind starts in default load context. 
LOG: Using application configuration file: C:\Documents and Settings\Administrator\Desktop\tmp\k;k\Starter.exe.Config 
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\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 and Settings/Administrator/Desktop/tmp/k;k/X.DLL. 
LOG: Assembly download was successful. Attempting setup of file: C:\Documents and Settings\Administrator\Desktop\tmp\k;k\X.dll 
LOG: Entering run-from-source setup phase. 
LOG: Assembly Name is: X, Version=1.0.4538.22813, Culture=neutral, PublicKeyToken=null 
LOG: Binding succeeds. Returns assembly from C:\Documents and Settings\Administrator\Desktop\tmp\k;k\X.dll. 
LOG: Assembly is loaded in default load context. 

的唯一錯誤是在C:\ FusionLog \ NativeImage \ Starter.exe \目錄:

*** Assembly Binder Log Entry (6/4/2012 @ 1:56:13 PM) *** 

The operation failed. 
Bind result: hr = 0x80070002. The system cannot find the file specified. 

Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll 
Running under executable C:\Documents and Settings\Administrator\Desktop\tmp\k;k\Starter.exe 
--- A detailed error log follows. 

=== Pre-bind state information === 
LOG: User = MENKAUR-7683827\Administrator 
LOG: DisplayName = BookmarkWiz.Kernel, Version=1.0.4538.22813, Culture=neutral, PublicKeyToken=null 
(Fully-specified) 
LOG: Appbase = file:///C:/Documents and Settings/Administrator/Desktop/tmp/k;k/ 
LOG: Initial PrivatePath = NULL 
LOG: Dynamic Base = NULL 
LOG: Cache Base = NULL 
LOG: AppName = Starter.exe 
Calling assembly : Starter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. 
=== 
LOG: Start binding of native image X, Version=1.0.4538.22813, Culture=neutral, PublicKeyToken=null. 
WRN: No matching native image found. 
LOG: IL assembly loaded from C:\Documents and Settings\Administrator\Desktop\tmp\k;k\X.dll. 

我無法登錄大會,因爲它本身引用veral其他組件,未簽署

+0

請參閱我的更新回答,並檢查您的dll是否被阻止,因爲它們來自不可靠的來源。 – flayn

+2

聽起來像你應該使用融合日誌進行調查 - http://stackoverflow.com/questions/4562859/solving-assembly-not-found-filenotfoundexception-fusion-log –

+0

看到更新..... –

回答

11

...未能加載文件或程序集「X」或其依賴 之一...

最有可能不能加載另一個依賴。

您可以嘗試使用依賴關係人檢查依賴關係。

即:http://www.dependencywalker.com/

另外,請檢查您的構建配置(86/64)

編輯: 我也有這個問題,一旦當我從一個「不可信」的網絡共享複製拉鍊的DLL。該文件被Windows鎖定並引發了FileNotFoundException。

在這裏看到:Detected DLLs that are from the internet and "blocked" by CASPOL

+10

依賴步行者只能配置文件非託管程序。 –

1

我通過重命名DLL解決了這個問題。上傳到其共享位置時,DLL已被手動重命名(版本號附加到文件名)。從下載的文件中刪除版本號解決了問題。

0

我有同樣的問題。對我來說,它有助於刪除項目文件夾中的.vs目錄。

+0

這並沒有幫助我的情況。 – Shimmy

相關問題