I recently upgraded a c# windows service to run as a 64 bit .net process. Normally, this would be trivial, but the system makes use of a 32-bit DLL written in C++. It is not an option to convert this DLL to 64 bit, so I wrapped the DLL in a separate 32 bit .net process and exposed a .net interface via remoting.
This is quite a reliable solution, but I would prefer to run the system as a single process. Is there any way I can load my 32 bit DLL into a 64 bit process and access it directly (perhaps through some sort of thunking layer)?
No, you can't.
http://blogs.msdn.com/oldnewthing/archive/2008/10/20/9006720.aspx
If your .NET application is a website running in IIS you can circumvent it.
An ASP.NET webpage running on IIS on a 64-bit machine will be hosted by a 64-bit version of the w3wp.exe process, and if your webpage uses 32-bit dlls your site will fail.
However in IIS you can go into the Advanced Settings of the Application Pool running the site, and change "Enable 32-bit applications" to true.
So it's still not able to run 32-bit dll inside 64-bit process, but rather it is running w3wp.exe as a 32-bit process instead.