I can't compile a standard “WCF Service Library” in x86 format

前端 未结 2 1267
夕颜
夕颜 2020-12-09 05:48

If I start up Microsoft Visual Studio, create a standard \"WCF Service Library\", and compile it, it works perfectly.

However, if I go into Properties..Build and set

相关标签:
2条回答
  • 2020-12-09 06:42

    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.

    Rather than going to the lengths of changing to a WCF Service Application so you can debug, 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.

    1. Copy WcfSvcHost.exe and WcfTestClient.exe from C:\program files (x86)\Microsoft Visual Studio 10.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. Execute the command "corflags /32BIT+ /FORCE WcfTestClient"

    6. Copy the files back to where you found it.

    Now your WcfSvcHost and WcfTestClient will be running in 32 bit mode, and you can debug away!

    0 讨论(0)
  • 2020-12-09 06:51

    I found two good methods to solve this:

    1. Installing the 64-bit version of Matlab means you can compile 64-bit .dll's which are compatible with the 64-bit WCF Service Library. This removes the need to compile in 32-bit mode so it doesn't throw exceptions when it calls the 32-bit assembly. This solution works well.
    2. There are two types of projects you can generate in MSVS 2010: "WCF Service Library" and "WCF Service Application". Although you cannot build and run a "WCF Service Library" in 32-bit mode (it only supports 64-bit), you can build and run a "WCF Service Application" in 32-bit mode.
    0 讨论(0)
提交回复
热议问题