问题
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