"试图用不正确的格式&QUOT加载程序;即使当平台是相同的 [英] "An attempt was made to load a program with an incorrect format" even when the platforms are the same

查看:279
本文介绍了"试图用不正确的格式&QUOT加载程序;即使当平台是相同的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打电话在64位系统的32位非托管DLL函数。我得到的是:

I'm calling functions from a 32-bit unmanaged DLL on a 64-bit system. What I get is:

BadImageFormatException:试图用不正确的格式加载程序。 (从HRESULT异常:0x8007000B)

BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

起初,我有我的项目设置为任何CPU平台,所以我改变了他们俩到了X86,但这个错误仍然发生。这的确是我知道这样做的唯一的解决方法。

At first, I had my projects set to the Any CPU platform, so I changed them both to x86, but this error is still occurring. That's really the only fix I know for this.

该DLL文件是未损坏或任何东西,因为我可以将它们与其他程序(我没有源)。我想,也许它没有找到一个依赖,但我检查,他们都在那里。另外,是不是抛出一个 DllNotFoundException 在这种情况下?

The DLLs aren't corrupt or anything, because I can use them with other programs (that I don't have the source to). I thought that perhaps it wasn't finding a dependency, but I checked and they're all there. Plus, wouldn't it throw a DllNotFoundException in that case?

我还能做什么?而之前你说使用64位的非托管的DLL,而不是我要指出的是,没有一个。 ;)

What else can I do? And before you say "Use a 64-bit unmanaged DLL instead," let me point out that there isn't one. ;)

推荐答案

不知何故,在构建复选框中的配置管理器已选中了我的可执行文件,所以它仍与旧的运行任何CPU建立。之后我定的是,Visual Studio中抱怨说,它无法调试程序集,但被固定重启。

Somehow, the Build checkbox in the Configuration Manager had been unchecked for my executable, so it was still running with the old Any CPU build. After I fixed that, Visual Studio complained that it couldn't debug the assembly, but that was fixed with a restart.

这篇关于"试图用不正确的格式&QUOT加载程序;即使当平台是相同的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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