2012-12-06 33 views
1

我引用的是.net 2.0項目中構建的.net 2.0程序集。 Windows XP機器上它工作正常,但在Win2003的64位進行部署時程序集參考 - System.BadImageFormatException錯誤

我得到以下

System.BadImageFormatException: Could not load file or assembly 'Wrapper, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. 

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. 

項目錯誤是建立在Win XP的32位機,然後部署使用WiX的安裝程序,手動嘗試更換大會但沒有工作。

+0

可能的重複:http://stackoverflow.com/questions/7325660/cannot-load-assembly-problem – Rik

回答

2

您應該檢查Wrapper組件的構建屬性。我懷疑它設置爲32位(x86)。您將需要它爲AnyCpu或x64以便加載到64位CLR中。

現在,如果它實際上是非託管代碼的包裝,那麼您可能需要兩個不同版本的程序集 - 一個用於32位,一個用於64位。

另一種替代方法是將您的應用程序更改爲32位。目前還不清楚您正在運行的是哪種應用程序,或者這是否合適 - 但值得考慮。

+0

嗨,約翰,在32位系統上運行它沒有問題。所以我相信組件是32位版本。 – RAJ

+0

@RAJ:不要只是「相信」它 - *檢查它。查看文件,例如用ildasm,檢查元數據部分中的'.corflags'。 –

+0

找出問題,用corflags.exe找到頭文件, – RAJ