I can reference Matlab code from a x86 based project, but not from an x64 project.
I can build the WCF Service as "Any CPU", but not x86. When I attempt to build as x86 only, it gives the following error:
---start error---
System.BadImageFormatException: Could not load file or assembly 'file:///D:\backtest\WcfServiceLibrary.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
---end error---
Thus, I'm stuck: how on earth do I provide Matlab calls via WCF? Its like some weird form of developers XOR.
Any ideas on how to either (a) compile the WCF Service Library in 32-bit mode, or (b) work around the issue?
I have Win7 x64, MSVS 2010.
Your problem is actually the WCF Test Client complaining that your WCF Service Library is 32bit. This is because by default, the WCF Test Client always runs in 64 bit mode.
I found the following steps on this blog which makes the WCF Test Client run in 32bit mode - and therefore you will not see the error you have posted.
"cd" to the directory where your copy of WcfSvcHost is located.
Execute the command "corflags /32BIT+ /FORCE WcfSvcHost.exe"
Execute the command "corflags /32BIT+ /FORCE WcfTestClient.exe"
Copy the files back to where you found it.
Now your WcfSvcHost and WcfTestClient will be running in 32 bit mode, and you won't get your error
WcfServiceLibrary is a DLL, so should be built as "Any CPU". Only EXE projects hosting all the other DLLs need to be marked as "x86" or "x64" as required. Which project is the EXE in this case?
I found a couple of good solutions which solved all my problems. I documented it here: I can't compile a standard "WCF Service Library" in x86 format
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With