Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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?

like image 876
user2434400 Avatar asked Nov 18 '25 16:11

user2434400


1 Answers

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.

like image 184
Remy Lebeau Avatar answered Nov 21 '25 10:11

Remy Lebeau