2010-12-02 25 views
4

可能重複:
BadImageFormatException during .Net assembly load issue無效的圖片格式異常問題

我試圖運行的加載組件,並提取其版本exe文件。該文件在win xp上運行良好,但在win 7上運行時崩潰,並出現以下異常。

Unhandled Exception: System.BadImageFormatException: Could not load file or asse 
mbly 'some.dll' or one of its dependencies. An attempt was made to load a program with 
an incorrect format. 
File name: 'some.dll' 
    at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, 
Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boo 
lean throwOnFileNotFound, Boolean forIntrospection) 
    at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence 
assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) 
    at System.Reflection.Assembly.LoadFrom(String assemblyFile) 
    at NxTools.InstallTools.Utils.MIPSettings.MIPEnvironmentSettings.Main(String[ 
] args) 

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

有沒有人遇到過這個問題?什麼可能是這個問題的可能解決方案?

回答

3

請檢查您是否正在運行64位Windows和DLL北京時間32位ONLY(有時是特殊版本的64位Windows可用)

15

這可能有幾個原因,最有可能的是,你要加載一個32位託管的DLL在64位機器上,反之亦然。

它也可能意味着您正在動態加載的DLL不是本機DLL,或者該DLL文件已損壞。

這可能意味着,如果您使用不同的版本重新構建特定組件,則可能意味着您的某個dll使用的是.Net框架的高版本,而不是某些其他正在使用它的dll。

This question涵蓋了類似的地方,this one也提供了一種方法來強制您的64位應用程序在32位模式下運行,因此它可以加載32位依賴項。