locked
Specifying forcelegacymode in runsettings RRS feed

Answers

  • Hi Graeme

    You can find details of the schema on msdn.

    Here is a sample of runsetting with forcedlegacymode option enabled

                        <RunSettings>
                            <MSTest>
                                <ForcedLegacyMode>true</ForcedLegacyMode>
                            </MSTest>
                        </RunSettings>


    Thank You Allen Mathias

    • Proposed as answer by Vikram Agrawal Thursday, September 13, 2012 7:05 AM
    • Marked as answer by graydott Thursday, September 13, 2012 9:26 AM
    Thursday, September 13, 2012 5:18 AM

All replies

  • Hi Graydott,

    Thanks for using VS 2012.

    Ideally you should not be required to force legacy. What is issue you are facing? May be we can help you resolving that else you can try compatibility mode any time.

    Note: If you still want to use in compatibility mode, use a dummy .testsettings file.


    Regards,
    Vikram Agrawal,
    Developer, VSTLM, Microsoft Corporation

    Tuesday, September 11, 2012 3:43 PM
  • OK, I have a solution containing an Asp.net web application and two windows services.  The windows services use NServiceBus which has log4net 1.2.10 integrated into it.  Our web application uses Elmah with log4net 1.2.11.

    I can build the solution and run all tests in Visual Studio 2010 using a default local.testsettings.  In VS 2012 I can build the solution without problem but I'm having issues running the unit tests.  If I run the tests using a default local.testsettings then they all pass.  If I run the tests using a runsettings file then a proportion of the tests fail with the following error:

    Test Name: ConstructorThrowsExceptionWhenCommandParameterIsNull
    Test FullName: <TestClass>.ConstructorThrowsExceptionWhenCommandParameterIsNull
    Test Source: <TestClassFileName> : line 66
    Test Outcome: Failed
    Test Duration: 0:00:00

    Result Message: Unable to create instance of class <TestClass>. Error: System.IO.FileLoadException: Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).
    Result StackTrace: at <TestClass>..ctor()

    Now I could continue using VS2012 and just use a testsettings file but one of the main reasons I'm looking to move my team to 2012 is that premium edition now includes code coverage.  If I run code coverage using a testsettings file then all my unit tests are included in the coverage results.  I know I can decorate each test class with an ExcludeFromCodeCoverage attribute but with over 1000 tests that's a big overhead and requires discipline going forwards as new test classes are created.  My preference would be to use a runsettings file configured to exclude my unit test assemblies so I was hoping that by including 'forcelegacymode' in the runsettings file I would be able to both run the tests and get valid code coverage results.

    regards,

    Graeme.

    Wednesday, September 12, 2012 7:54 AM
  • Hi Graeme

    You can find details of the schema on msdn.

    Here is a sample of runsetting with forcedlegacymode option enabled

                        <RunSettings>
                            <MSTest>
                                <ForcedLegacyMode>true</ForcedLegacyMode>
                            </MSTest>
                        </RunSettings>


    Thank You Allen Mathias

    • Proposed as answer by Vikram Agrawal Thursday, September 13, 2012 7:05 AM
    • Marked as answer by graydott Thursday, September 13, 2012 9:26 AM
    Thursday, September 13, 2012 5:18 AM
  • Great, that's worked for me, thanks Allen and Vikram.
    Thursday, September 13, 2012 9:29 AM