在 64 位机器上使用 32 位 dll [英] Using a 32 bit dll on a 64 bit machine

查看:36
本文介绍了在 64 位机器上使用 32 位 dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 32 位 dll 的旧项目.这在 32 位处理器上运行良好,但是当我在 64 位操作系统上安装相同的项目时它不起作用.

I have an old project which uses a 32 bit dll. This works fine on 32 bit processor, however when I install the same project on a 64 bit OS it does not work.

有没有办法将 32 位 dll 转换为 64 位?是否有其他解决方案可以让我的 32 位 dll 在 64 位操作系统中工作?

Is there any way to convert 32 bit dll to 64 bit? Is there an alternative solution solution to make my 32 bit dll work in a 64 bit OS?

推荐答案

你的 32 位 dll 应该可以在 64 位机器上正常工作,只要它被加载到 32 位进程中 - 试图将 32 位 dll 加载到64 位进程将失败.

Your 32 bit dll should work just fine on a 64 bit machine as long as it is loaded into a 32 bit process - attempting to load a 32 bit dll into a 64 bit process will fail.

如果您的项目是 .Net(例如 C#)应用程序,那么您应该能够将程序集定位在 x86 上,以使您的 32 位 dll 正常工作:

If your project is a .Net (e.g. C#) application then you should be able to target your assembly at x86 in order to get your 32 bit dll working correclty:

  • 在 Visual Studio 中右键单击您的项目并选择属性
  • 在构建项目属性选项卡上,确保平台目标下拉列表显示为x86"而不是任何 CPU"

如果您的平台目标是任何 CPU",那么您的项目通常将针对任何可用平台,即 64 位操作系统上的 x64 - 这将阻止您的 32 位 dll 被加载.

If you platform target is "Any CPU" then your project will normally be targeted at whatever platform is available, i.e. x64 on a 64 bit OS - this will prevent your 32 bit dll from being loaded.

如果您的项目不是 .Net 程序集,那么执行上述操作所需的等效步骤将有所不同.

If your project is not a .Net assembly then the equivalent steps needed to do the above will be different.

或者,您可以尝试获取 dll 的 64 位版本 - 如果它是您生成的 dll,那么您需要自己将其迁移到 64 位.如果不是,则您依赖于提供 64 位兼容版本的原始供应商.

Alternatively you can attempt to obtain a 64 bit version of your dll - if it is a dll that you have produced then you will need to migrate it to 64 bit yourself. If not then you are dependent on the original suppliers providing a 64 bit compatible version.

这篇关于在 64 位机器上使用 32 位 dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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