.net 错误的图像格式异常问题

.net 错误的图像格式异常问题,.net,badimageformatexception,.net,Badimageformatexception,可能重复: 我正在尝试运行一个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 inco

可能重复:

我正在尝试运行一个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].

有人面对过这个问题吗?此问题的可能解决方案是什么?

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

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

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

例如,如果您使用不同的版本重新生成特定组件,则这可能意味着您的dll使用的.Net framework版本高于使用它的其他dll版本

涵盖了类似的内容,这也提出了一种方法,可以强制64位应用程序以32位模式运行,以便加载32位依赖项