Moq & Interop Types: works in VS2012, fails in VS2010?

后端 未结 4 729
攒了一身酷
攒了一身酷 2020-12-03 11:43

I have a .NET library project with about 500 unit tests. All these tests run fine in Visual Studio 2012. However, some of my tests fail in Visual Studio 2010. In these faili

4条回答
  •  难免孤独
    2020-12-03 12:34

    First of all check while adding library to the project in VS2010, make sure you created the mock object like

    Mock _mock = new Mock();
    

    Also .NET 4.0 allows primary interop assemblies to be embedded into your assembly so that you don't need to deploy them alongside your application.Open the properties tab in the assembly in VS2010 and check the Embed Interop types.mkae sure its true.

    And to instantiate excel, Excel.Application xlapp = new Excel.Application();

    Hope it will work..

提交回复
热议问题