Fakes sample on MSDN for WCF isolation doesn't work. [ShimNotSupportedException] and [InvalidProgramException] were seen.


  • Hi guys,

    I am trying to use Fakes to isolate one of our component from the external WCF dependencies.

    So I found a demo code for WCF unit test with VS2012 Fakes at here:

    Unfortunately, the sample failed to work on one of my box. Though it succeeded on another box.

    Here's the configurations for the 2 boxes, and I use VS2012 to run the sample on both boxes.

    Win2008R2 + VS2012 + VS2010: Success

    Win8 + VS2012 + VS2010: Failure

    On the failed box I tried these approaches:

    1. If I choose to run the case in VS2012, it gave me this error in the Output window:

    ------ Run test started ------
    Exception has been thrown by the target of an invocation.
    ========== Run test finished: 0 run (0:00:03.7908642) ==========

    2. If I choose to debug the case, it gave me the following error even before entering my test method. So no breakpoint in my test method was hit.


    3. Finally, I have to try to run it with mstest from command line, and I got a trx file with the following stack trace:


    Anybody can shed some light on my frustrated mind? I was expecting Fakes to be a powerful tool, never thought it could be this tricky.

    sam witwiki

    • Edited by SoBigSoBig Wednesday, November 14, 2012 3:05 PM
    Wednesday, November 14, 2012 2:56 PM

All replies

  • I just checked a blog here:

    It doesn't work.

    It seems the ShimNotSupportedException is very legendary!

    sam witwiki

    • Edited by SoBigSoBig Wednesday, November 14, 2012 4:13 PM
    Wednesday, November 14, 2012 4:12 PM
  • Hi,

    I am trying to involve someone familiar with this topic to further look at this issue.


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, November 15, 2012 6:42 AM
  • Hello guys, any update on this?

    sam witwiki

    Tuesday, November 20, 2012 8:01 AM
  • Hi,

           This MSDN sample that you are using was written for the Beta version of VS 2012.  We are in the process of porting this over the RTM version to investigate the problem you are seeing.   Expect a follow up soon.


    Wednesday, November 21, 2012 4:42 PM
  • I had uploaded the MSDN sample. I replicated this issue in same environment i.e. Win 8, VS 2010 & VS 2012. In order to drill down I created a new Unit Test project(new solution) and added reference to System.ServiceModel dll. I added Fakes assembly for System.ServiceModel reference. I ran the default unit test(empty test method) and it failed with same error message. I removed the System.ServiceModel.Fakes and instead added Fakes assembly for System. This time it worked.

    My initial thoughts are "Adding Fakes assembly for System.ServiceModel on Win 8 + VS 2010 + VS 2012 causes this error." I'll share if I find a workaround. Thanks.

    • Edited by Atul.Verma Wednesday, November 21, 2012 6:04 PM
    Wednesday, November 21, 2012 6:02 PM
  • I have found a fix for this issue. The workaround is

    Go to Test> Test Settings>Default Processor Architecture> and change to X64.

    In my case it was X86. I changed it to X64, rebuild and ran the test ... it worked :)



    Monday, November 26, 2012 6:51 PM