Thursday, September 3, 2009

My Trials and Tribulations getting a WCF Service running on 64 bit Windows Server 2008 with 32 bit Native Dlls

My WCF Service uses a native DLL written in C++. This native Dll can be 32 bit or 64 bit. The 32 bit version relies on other 3rd party Dlls that are not available in 64 bit. And the 64 bit version is the same thing without the 3rd party dependencies.

1. IIS 7 is easy enough to work in 32 bit or 64 bit mode (on a 64 bit Windows Server 2008 server). By default, the application pool is 64 bit, but you can create another application pool for 32 bit applications or change the default application pool to 32 bit by using the “Enable 32-bit Applications” switch under Set Application Pool Defaults. Then on the Advanced Setting page for your WCF Services Virtual Directory, you can select the Application Pool to use. More Info:

2. The \Windows\System32 directory is for 64 bit files on a 64 Bit OS. And SysWow64 contains the 32 bit files. (Windows on Windows 64 bit). Confusing, but once you know, you know.

3. Getting a 32 bit app using MFC with shared DLLs running on a 64 bit OS can give you a funny error: “The application has failed to start because its side-by-side configuration is incorrect”. The 64 bit OS doesn’t get the standard 32 bit MFC Runtime dlls installed. So you can deliver the 32 bit dependencies or just recompile the DLL using MFC in a Static Library. Easy to fix either way, but the error message is not so obvious. More Info:

4. The WCF Service always runs fine on the development machine. Deploying it to a real IIS server then has various difficulties to overcome. Mostly, the problem is with security and permissions. If you get: “The caller was not authenticated by the service.” You can possibly just change the binding from wsHttpBinding to basicHttpBinding in the web.config file. Here is more discussion on the issue:

No comments: