图像格式错误异常问题

发布于 2024-10-05 14:31:45 字数 1453 浏览 4 评论 0原文

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

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

Possible Duplicate:
BadImageFormatException during .Net assembly load issue

I am trying to run a exe file which loads a assembly and extracts its version. The file is working fine on win xp but while running it on win 7 it crashes giving the following exception.

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].

Has anybody faced this problem? What could be the probable solution to this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

极度宠爱 2024-10-12 14:31:45

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

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

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

这个问题涵盖了类似的基础,这个还建议了一种强制 64 位应用程序在 32 位模式下运行的方法,以便它可以加载 32 位依赖项。

This can have several causes, the most likely is that you are trying to load a 32bit managed dll on a 64 bit machine, or vice versa.

It can also mean that a dll you are dynamically loading is not a native dll, or that the dll file is corrupted.

It may mean that you have a dll which is using a higher version of the .Net framework than some other dll that is using it, if you rebuilt a particular component with a different version for example.

This question covers similar ground, as does this one which also suggests a way to force your 64bit app to run in 32bit mode so it can load the 32bit dependency.

浪菊怪哟 2024-10-12 14:31:45

请检查您是否运行 64 位 Windows,并且 dll 是否仅限 32 位(有时有适用于 64 位 Windows 的特殊版本)

Please check if you are running a 64bit Windows and the dll ist 32bit ONLY (sometimes special versions for 64bit Windows are available)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文