开发者

BadImageFormatException in WCF Context

开发者 https://www.devze.com 2023-03-04 11:19 出处:网络
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 fro

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 bot开发者_开发技巧h 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...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消