我可以链接32位原生的DLL(不是.NET程序集)到我的64位的.Net应用程序了?我的、应用程序、链接、不是

2023-09-05 03:46:16 作者:Pretend 虚 伪

我们有一个旧的第三方组件,它是一个32位原生的DLL。在我们的基于COM的应用程序,我们通过Windows的API联系起来。现在,我们正计划升级我们的应用程序到.NET,并在64位系统上运行。我的问题是:我们仍然通过Windows API连接旧的32位原生的DLL到我们的64位.net应用程序?如果不是,就如何得到它的任何想法来工作?

We have an old 3rd party component which is a 32 bit native dll. In our COM based app, we link it through Windows API. Now, we are planning to upgrade our app to .Net and running on 64 bit system. My question: Can we still link the old 32 bit native dll into our 64 bit .net app through Windows API? If not, any ideas on how to get it to work?

推荐答案

32位code不能用里面的64位程序,期限。但是,你可以用32位的DLL进程外了32位COM服务器内(如果DLL已经是一个COM服务器,那么你可以使用COM的 DllSurrogate 代理),然后将所有的64位程序(.NET或其他方式)可以使用COM服务器需要。否则,你将不得不设置.NET项目为32位而不是64位。它会在64位机器上仍然运行,只要安装了WOW64仿真程序的组成部分。

32-bit code cannot be used inside of a 64-bit process, period. However, you can wrap the 32-bit DLL inside of a 32-bit out-of-process COM server (if the DLL is already a COM server, then you can use a COM DllSurrogate to proxy it), then any 64-bit process (.NET or otherwise) can use that COM server as needed. Otherwise, you will have to set the .NET project to 32-bit instead of 64-bit. It will still run on a 64-bit machine, provided the WOW64 emulator component is installed.

 
精彩推荐
图片推荐