【问题标题】:Bad Image Format exception problem [duplicate]Bad Image Format异常问题[重复]
【发布时间】:2011-05-19 03:24:43
【问题描述】:

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

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

【问题讨论】:

    标签: .net badimageformatexception


    【解决方案1】:

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

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

    这可能意味着您的 dll 使用的 .Net 框架版本高于其他使用它的 dll,例如,如果您使用不同版本重建特定组件。

    This question 涵盖了类似的基础,this one 也是如此,它还提出了一种强制您的 64 位应用程序在 32 位模式下运行的方法,以便它可以加载 32 位依赖项。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-12-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多