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.
- 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.
- Start a Visual Studio 2010 Command Prompt (one of the links from the start menu -> Visaul Studio 2010)
- “cd” to the directory where your copy of WcfSvcHost is located.
- Execute the command “corflags /32BIT+ /FORCE WcfSvcHost.exe”
- 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