Ways to access a 32bit DLL from a 64bit exe

As you correctly note, there is no way to mix bitness in the same process. You need a separate process for your 32-bit part.

I think hosting a WCF Service is the right way to go. Your link only talks about wcfsvchost. I am pretty sure you can create your own Windows Service, and host the WCF service in that on 32 bit.

See this link: How to host a WCF service in a managed application. You can host your service in any managed application, including a Windows Service, and run it under the bitness you like.

This is the amount of code required to self-host a WCF service in your application, assuming you have just created a new service called MyService, and the appropiate configuration has been added to app.config:

class Program
{
    static void Main(string[] args)
    {
        using(ServiceHost host = new ServiceHost(typeof(MyService), new Uri[0]))
        {
            host.Open();
            Console.ReadKey();    
        }
    }
}

The above program will run just as well, also if you compile it explicitly as 32 or 64 bit.

Leave a Comment