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

假装没事ソ 提交于 2019-12-14 03:53:04

问题


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?


回答1:


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.




回答2:


Short answer Link is not possible because you can't link 32 and 64 bit together

Communicate yes, but you need two executable one 32bits and one 64bits
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.

It works but you'll need to encapsulate every call you want to make between the 32 and 64 system.



来源:https://stackoverflow.com/questions/18724384/can-i-link-a-32-bit-native-dll-not-net-assembly-into-my-64-bit-net-applicait

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!