如何使dll兼容x86和x64位Windows操作系统。 [英] How to make dll compatible with x86 and x64 bit Windows OS.

查看:851
本文介绍了如何使dll兼容x86和x64位Windows操作系统。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些dll使用32位机器正常工作。但其中一些在x64 Windows 7上显示错误消息: - 不能在调用目标中加载assembly.Exception。有时无法使用dll名称加载程序集文件和路径名。



即使我在Visual Studio上使用 - > Configuration Manager-> AnyCPU / x86 / x64构建显示错误的dll。但仍未解决。



我试过谷歌,发现有关dumpbin,仍在探索它... ..



有没有选项可以构建兼容两种架构的dll(x86 && x64位)。或者怎么做?



请给我你宝贵的建议...

I have some dlls using on 32 bit machine working properly. But some of them showing error message on x64 Windows 7:-Could not load assembly.Exception in target of invocation. Sometimes Unable to load assembly file and path name with dll name.

Even i have used on Visual Studio->Configuration Manager-> AnyCPU/x86/x64 to build that dll which is showing error.But still it not resolved.

I tried google,found about dumpbin,still exploring about it....

Is there any option to build a dll compatible with both architecture (x86 && x64 bit).Or how to do it??

Please give me your valuable suggestion...

推荐答案

如果你做了一些与x86明确兼容的东西,那么你的x64机器将以32位模式运行它。如果您构建它以使用任何处理器,它将工作,只要您没有需要32位的依赖项,这是强制您的应用程序以32位模式运行的主要原因,因为如果您的代码运行为64位并尝试使用32位dll,这将失败。
If you make something explicitly compatible with x86, then your x64 machine will run it in 32 bit mode. If you build it to use any processor, it will work, so long as you don't have dependencies that require 32 bit, that's the main reason to force your app to run in 32 bit mode, because if your code runs as 64 bit and tries to use a 32 bit dll, that will fail.


AnyCPU将根据您运行的内容选择正确的架构。问题是,如果您正在运行AnyCPU并且您正在引用基于x64(如果运行32位)或x86(如果运行64位)构建的DLL,那么它将为您提供所描述的错误。确保不仅为AnyCPU编译了您的项目,而且还为您的DLL使用了任何引用。
AnyCPU will choose the right architecture based on what you are running on. The problem is that if you are running AnyCPU and you are referencing a DLL built on x64 (if running 32-bit) or x86 (if running 64-bit), then it will give you the error you described. Make sure that not only your project is compiled for AnyCPU, but any references that you use with your DLL as well.


这篇关于如何使dll兼容x86和x64位Windows操作系统。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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