1

my scenario is the following (Win7, VS2010, .NET 4.0):

I have a .NET assembly from an external company compiled for "Any CPU" (verified with corflags.exe). This assembly loads a native dll also from the external company. This native dll exists in two versions - x86 and x64. I have both available.

When I create a console application, add the .NET assembly (while making sure one of the native DLLs can be found by the .NET assembly), create an instance of one of the classes from that .NET library and start the program everything is fine.

However when I follow the exact same steps within a WCF Service, I am getting a BadImageFormatException. Now the obvious thing is search for the error in the targeted platform (I tried "Any CPU", "x86", "x64") or trying to exchange the native DLL (I tried both x86 and x64), but that does not help. I tried all combinations btw...

Does anyone have an idea what the problem might be?

Lars

P.S.: I read BadImageFormatException encountered with WcfSvcHost and IIS WCF host and as the author states he solved a similar problem by corflagging WcfSvcHost.exe as 32BIT, but WcfSvcHost.exe is strong named so I can't resign it. Not sure how he got it to work...

Community
  • 1
  • 1
larsbeck
  • 665
  • 2
  • 7
  • 11

1 Answers1

1

You could drop the dependency on WcfSvcHost, and host/debug the service in a local IIS where you can explicitly set the AppPool to either 32 or 64 bit. That's what I'd do.

mthierba
  • 5,587
  • 1
  • 27
  • 29
  • Yeah, that is a workaround and does the trick for me, thx! Interesting though that I can not get this to work with WcfSvcHost... – larsbeck May 07 '11 at 17:58
  • Can somebody shed some more details on this? I couldn't find where to change this AppPool setting. In my IIS Manager, go to Advanced Settings, see Application Pool with DefaultAppPool selected. But the other three options are: Classic .NET AppPool, ASP.NET v4.0, ASP.NET v4.0 Classic. So which one means 32 or 64? – newman Nov 29 '11 at 02:21