奇怪的BadImageFormatException问题 [英] Strange BadImageFormatException issue

查看:79
本文介绍了奇怪的BadImageFormatException问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用VB编写的程序,可以在XP和W7 / 32上正确安装和运行,但在W7 / 64上表现得非常奇怪。如果我安装它,安装干净,但当我尝试运行它时,它失败了一个DLL的DLL上的BadImageFormatException。如果我将它从闪存驱动器复制到W7 / 64机器上的目录中,它运行时没有错误并产生正确的结果!



它不是CPU类型:在程序中的所有项目中都设置为x86。



必须与安装过程有关。



有没有人有任何有用的想法?

I have a program written in VB that installs and runs correctly on XP and W7/32, but behaves very strangely on W7/64. If I install it, the install goes cleanly but when I attempt to run it, it fails with a BadImageFormatException on one of it''s DLLs. If I copy it from a flash drive into a directory on the W7/64 machine,it runs without error and produces correct results!

It is not the CPU type: this is set to x86 on all projects within the program.

It must have something to do with the install process.

Does anyone have any useful ideas?

推荐答案

请检查所有模块是否已编译到目标指令集架构AnyCPU并且您没有任何本机(非托管)模块。如果确实有一些,则需要提供一种机制来为不同的指令集体系结构加载替代实现,例如x86-64或Itanium(IE-64)。这就是操作系统的原生模块的工作方式:在不同版本的操作系统上,您可以使用相同的API编译到此系统上使用的指令集架构。



或者,您可以使用x86中的所有模块,这些模块通过WoW64支持: http://en.wikipedia.org/wiki/WOW64 [ ^ ]。



在这种情况下,你应该确保在一个进程中没有不同的指令集体系结构(不同的进程,当然,可以在不同的平台上运行,WoW64和一个原生于操作系统的版本。再次确保您的本机(非托管)模块是一致的。



通常,您需要将所有内容都构建为AnyCPU 但是,它在WoW64上工作或任何特定的指令集架构由于某种原因很重要(它总是与非托管模块有关), d只有入口点组件才能定义特定的架构。



-SA
Please check up that all your modules are compiled to the target instruction-set architecture "AnyCPU" and you don''t have any native (non-managed) modules. If you do have some, you would need to provide a mechanism for loading alternative implementations for different instruction-set architectures, such as x86-64 or Itanium (IE-64). This is how native modules of OS work: on a different version of OS, you have the same but API compiled to the instruction-set architecture used on this system.

Alternatively, you can use all modules in x86, which is supported via WoW64: http://en.wikipedia.org/wiki/WOW64[^].

In this case, you should make sure that you don''t have a mixture of different instruction-set architectures in one process (different processes, naturally, can run in different platforms, WoW64 and the one native on the version of the OS. Again, make sure your native (non-managed) modules are consistent.

Generally, you need to have everything built to "AnyCPU", but, it working on WoW64 or any specific instruction-set architecture is important by some reason (which is always related to the unmanaged modules), and only the entry-point assembly should define a particular architecture.

—SA


这篇关于奇怪的BadImageFormatException问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆