错误图像格式异常问题

时间:2010-12-02 13:29:44

标签: .net badimageformatexception

  

可能重复:
  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].

有人遇到过这个问题吗?可能解决这个问题的方法是什么?

2 个答案:

答案 0 :(得分:15)

这可能有多种原因,最有可能是您尝试在64位计算机上加载32位托管dll,反之亦然。

它也可能意味着您动态加载的DLL不是本机DLL,或者dll文件已损坏。

这可能意味着你有一个使用更高版本的.Net框架的dll而不是其他使用它的dll,如果你用不同的版本重建了一个特定的组件。

This question涵盖了类似的理由,this one也提出了一种方法来强制您的64位应用在32位模式下运行,因此它可以加载32位依赖关系。

答案 1 :(得分:3)

请检查您是否正在运行64位Windows并且dll仅为32位(有时可以使用64位Windows的特殊版本)

相关问题