locked
Using Microsoft Fakes Framework with VSTO Application-Level Add-in an XML based Ribbon RRS feed

  • Question

  • I have an "Application-level" VSTO Add-in (as opposed to "Document-Level") that runs in Excel.  The Add-in runs fine.   Rather than the Ribbon designer, I'm using the Ribbon XML option.  In doing so, you end up with a Ribbon class that derives from Office.IRibbonExtensibility, with various methods such as:

            public void OnTextButton(Office.IRibbonControl control)
            { ....
            }
    etc.

    Now, when I create a unit-test project, add a reference to my add-in, then select "Add Fake Assembly" from the right-click menu under References, I get a errors.

    I don't believe it has anything to do with my project because I verified that the same thing happens with sample add-in code, such as this project: http://www.codeproject.com/Articles/296288/Excel-Add-in-for-Exporting-Excel-data-to-XML

    To reproduce, I downloaded that Add in:
    1.  Open it in Visual Studeio 2010/2012/2013
    2.  Create a Unit Test project in the same solution.
    3.  Add the Add-in Project as solution-level Reference to the Unit Test project.  In this particular sample, it's called "ExcelExportXML".
    4.  Then Expand the References tree in the Unit Test project, right click on the add-in reference, i.e. ExcelExportXML, and select "Add Fake Assembly".   This requires that you have at least Premium version of Visual Studio.  Professional version is not enough.

    You end up with errors such as this:

        error CS0234: The type or namespace name 'IRibbonControl' does not exist in the namespace 'eexml::Microsoft.Office.Core' (are you missing an assembly reference?) [...\UnitTestProject1\obj\Debug\Fakes\eexml\f.csproj]

    It's best to repeat the steps above to reproduce the problem -- it only takes a few minutes.

    My request is this.   Is there a way to make this work without switching to another mocking/isolator framework.  I really want to avoid anyone suggesting that I not use "Microsoft Fakes Framework" because that's really not useful input unless you're absolutely positive that there is no way to get the two Microsoft technologies to effectively play together. 

    I've already tried using   <StubGeneration> in the .fakes file in all sorts of combinations.  Here's what I've tried so far:

          <StubGeneration>
            <Clear />
            <Remove TypeName="Ribbon1" />
            <Remove TypeName="ExcelAddIn1.Ribbon1" />
            <Remove FullName="ExcelAddIn1.Ribbon1"/>
            <Remove Namespace="ExcelAddIn1"/>
            <Remove Namespace="Microsoft.Office.Core"/>
            <Remove Namespace="eexml::Microsoft.Office.Core"/>
            <Remove FullName="Microsoft.Office.Core.IRibbonControl"/>
            <Remove TypeName="IRibbonControl"/>
          </StubGeneration>

    I spent about half a day researching this.  Any help (short of splitting the assembly into VSTO and non-VSTO parts) would be greatly appreciated.

    (back reference: https://stackoverflow.com/questions/26349272/using-microsoft-fakes-framework-with-vsto-application-level-add-in-an-xml-based )

    Monday, October 13, 2014 9:57 PM

All replies

  • Hi Daisha,

    I want to confirm where the error occurred on your side because I can’t reproduce the error based on the steps you described and the ExcelExportXML project which targets to .Net Framework 4 Client Profile here: http://www.codeproject.com/Articles/296288/Excel-Add-in-for-Exporting-Excel-data-to-XML, I can add fake assembly for ExcelExportXML project successfully in Unit Test Project which targets to .Net Framework 4.5.1->Reference in VS2013 Ultimate with Update 3. SO whether did the error occur when you run the unit test?

    If you can add fakes assembly for ExcelExportXML project successfully, that error occurred in unit test code, could you provide us the code sample so that we can further look at this issue?

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 15, 2014 6:21 AM
  • Hi Daisha Lynn,

    What about your issue now?

    If you have resolved it, you can share the solution here, which will be beneficial for other members with the same issue.

    If you did not, please provide us more information, I will try my best to help you.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 20, 2014 1:35 AM