简体   繁体   English

我可以将32位本机DLL(不是.Net程序集)链接到我的64位.Net应用程序中吗?

[英]Can I link a 32-bit native dll (not .Net assembly) into my 64 bit .Net applicaiton?

We have an old 3rd party component which is a 32 bit native dll. 我们有一个旧的第三方组件,它是一个32位的本机dll。 In our COM based app, we link it through Windows API. 在我们基于COM的应用程序中,我们通过Windows API链接它。 Now, we are planning to upgrade our app to .Net and running on 64 bit system. 现在,我们计划将我们的应用程序升级到.Net并在64位系统上运行。 My question: Can we still link the old 32 bit native dll into our 64 bit .net app through Windows API? 我的问题:我们是否仍然可以通过Windows API将旧的32位本机dll链接到我们的64位.net应用程序中? If not, any ideas on how to get it to work? 如果没有,有关如何使其工作的任何想法?

32-bit code cannot be used inside of a 64-bit process, period. 32位代码不能在64位进程内使用。 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. 但是,您可以将32位DLL包装在32位进程外COM服务器内(如果DLL已经是COM服务器,那么您可以使用COM DllSurrogate代理它),然后任何64位进程(.NET或其他)可以根据需要使用该COM服务器。 Otherwise, you will have to set the .NET project to 32-bit instead of 64-bit. 否则,您必须将.NET项目设置为32位而不是64位。 It will still run on a 64-bit machine, provided the WOW64 emulator component is installed. 如果安装了WOW64仿真器组件,它仍将在64位计算机上运行。

Short answer Link is not possible because you can't link 32 and 64 bit together 简短回答链接是不可能的,因为您无法将32位和64位链接在一起

Communicate yes, but you need two executable one 32bits and one 64bits 沟通是的,但你需要两个可执行的32位和一个64位
Then after you need to search for interprocess communication. 然后,您需要搜索进程间通信。

If you go to message communication, the only one you could send between 32 as 64bits is WM_COPYDATA and it could be block by UIPI so you may need to use the ChangeWindowMessageFilter to let it through. 如果你进行消息通信,你唯一可以在32位之间发送64位的是WM_COPYDATA ,它可能被UIPI阻止,所以你可能需要使用ChangeWindowMessageFilter让它通过。

It works but you'll need to encapsulate every call you want to make between the 32 and 64 system. 它可以工作,但你需要封装你想要在32和64系统之间进行的每个调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM