I have a project that must be compiled and run in 64 bit mode. Unfortunately, I am required to call upon a DLL that is only available in 32 bit mode, so there\'s no way I ca
I know this answer might be a little bit late, but some time ago I faced the exact same problem (loading a 32bit dll into an AnyCPU assembly on a 64bit machine).
As a solution, I wrote the LegacyWrapper. It basically consists of a 32bit wrapper exe loading the desired dll, communicating with your application via Named Pipes.
A call would look like this:
// Define delegate matching api function
private delegate int GetSystemMetrics(int index);
// Create new WrapperClient
// Remember to ensure a call to the Dispose()-Method!
using (var client = new WrapperClient())
{
// Make calls providing library name, function name, and parameters
int x = (int)client.Invoke("User32.dll", "GetSystemMetrics", new object[] { 0 });
int y = (int)client.Invoke("User32.dll", "GetSystemMetrics", new object[] { 1 });
}
For some details, you can refer to this blog post.
Edit: Since Version 2.1, LegacyWrapper also supports loading 64bit DLLs from a 32bit process.