Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a 64bit DLL in a 32bit Application

XCode's ARC refactoring forced my Cocoa Library DLL to be 64bit, and I don't know if I can still DllImport that DLL from an x86 C# application. Is this possible, and are there any consequences of doing so?

like image 684
Mr. Smith Avatar asked Mar 13 '13 21:03

Mr. Smith


People also ask

Can I use a 64-bit DLL in a 32-bit application?

On 64-bit Windows, a 64-bit process cannot load a 32-bit dynamic-link library (DLL). Additionally, a 32-bit process cannot load a 64-bit DLL. However, 64-bit Windows supports remote procedure calls (RPC) between 64-bit and 32-bit processes (both on the same computer and across computers).

Can a 32-bit application use a 64-bit driver?

Because 32-bit device drivers cannot be used with the 64-bit operating system, these drivers must be recompiled as 64-bit objects. Moreover, the 64-bit drivers need to support both 32-bit applications and 64-bit applications.

What is the difference between 32-bit and 64-bit DLL?

If the first DLL in the path is 32 bit and your app is 32 bit, then the DLL load will work. If the app is 64 bit, it will fail to load the DLL and the process will abort. If you want two DLLs to coexist on the system path, you need to give them unique file names.

Can we use 32-bit DLL in 64-bit application C#?

You can not run a 32-bit DLL inside a 64-bit process, no matter how hard you try, so you need to run it in a 32-bit process. If compiling your application for 32-bit only is not an option, you have no choice but to create a host application.


1 Answers

You cannot mix 32 bit and 64 bit code in a single process. So the only way to use mix bitness code is to have more than one process. You'll need some form of IPC to make it work. You cannot do it with DllImport since that is in-process.

like image 62
David Heffernan Avatar answered Oct 24 '22 22:10

David Heffernan