Hosting/Debugging WCF Service with 32 Bit WCFServiceLibrary

These days I had the problem that I needed to host and debug 32Bit WCF Service in Visual Studio 2010, because my backend had to talk to a Access Database where no 64Bit Driver is available.

But always when I tried to do that, I got the following exception:
System.BadImageFormatException: Could not load file or assembly

After googling around the web I found out, that the WcfServiceHost in VS2010 is not able to accept 32 Bit DLLs. But I also found a clever solution how to fix it.

  1. Copy WcfSvcHost.exe from C:\program files (x86)\Microsoft Visual Studio 9.0\Common7\IDE to a local directory. Keep a backup copy of this file, of course.
  2. Start a Visual Studio 2010 Command Prompt (one of the links from the start menu -> Visaul Studio 2010)
  3. “cd” to the directory where your copy of WcfSvcHost is located.
  4. Execute the command “corflags /32BIT+ /FORCE WcfSvcHost.exe”
  5. Copy the exe back to where you found it.

That solution works very great and should solve your problem as it did solve my.

Thanks and respect to Marco Zhou and Gordon Watts who found out this solution:
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/2e29a4aa-e587-43ef-bf50-329b7cd3eefb/

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.