locked
Visual Studio Experimental Instance Freezes RRS feed

  • Question

  • I have written unit tests for Visual Studio 2010 the Microsoft.VsSDK.IntegrationTestLibrary.TestUtils class found in the testprojectet when I create a new solution using VsPackage project template. My test approximately follows the pattern below. 

    My problem is that Visual Studio 2010 Sp1 Freezes sometimes and my tests times out. I have this problem both on my developer machine. A Win 7 x64 with 2 cores and 2Gb of RAM and my buildserver which is a Win server 2008 R2 with 2 cores and 2Gb of RAM.

    After a reboot the tests usually go through but not allways. That happends om both my machines as well.

    My test follow this pattern.

    using System;
    using System.Text;
    using System.Collections.Generic;
    using System.Linq;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Microsoft.VSSDK.Tools.VsIdeTesting;
    using Microsoft.VsSDK.IntegrationTestLibrary;
     
    namespace SHB.MDEV.VS.IntegrationTests.Common
    {
        [TestClass]
        public class UnitTest1
        {
            [TestInitialize()]
            public void MyTestInitialize()
            {
                CreateEmptySolution(TestContext.TestDir);
            }
     
            [TestMethod]
            [HostType("VS IDE")]
            public void TestMethod1()
            {
                UIThreadInvoker.Invoke((ThreadInvoker)delegate()
                {
                    // Do some testing
                });
            }
     
            [TestMethod]
            [HostType("VS IDE")]
            public void TestMethod2()
            {
                UIThreadInvoker.Invoke((ThreadInvoker)delegate()
                {
                    // Do some more testing
                });
            }
     
            private static void CreateEmptySolution(string testdir, string solutionName = "CSharpColsoleAppSln")
            {
                TestUtils testUtils = new TestUtils();
     
                testUtils.CreateEmptySolution(testdir, solutionName);
     
                Assert.AreEqual<int>(0, testUtils.ProjectCount());
            }
     
            private delegate void ThreadInvoker();
     
            private TestContext testContextInstance;
            public TestContext TestContext
            {
                get
                {
                    return testContextInstance;
                }
                set
                {
                    testContextInstance = value;
                }
            }
        }
    }
    

    If a run the tests on my developer machine and when Visual Studio Experimental Instance freezes. Attach the debugger and hit "Break" I will end up in the CloseCurrentSolution in the TestUtil Class.

            public void CloseCurrentSolution(__VSSLNSAVEOPTIONS saveoptions)
            {
                // Get solution service
                IVsSolution solutionService = (IVsSolution)VsIdeTestHostContext.ServiceProvider.GetService(typeof(IVsSolution));
     
                // Close already open solution
                solutionService.CloseSolutionElement((uint)saveoptions, null, 0); // I end up here when debugging after Visual Studio Freezes
            }

     Do I have to check if Visual Studio i busy before trying to create a new empty solution for a test?

    Anyone have a clue of why Visual Studio 2010 freezes and my tests times out?

    /Christer

    • Moved by Yi Feng Li Thursday, December 22, 2011 10:09 AM Move to Unit Test forum for better support (From:Visual Studio Extensibility)
    Tuesday, December 20, 2011 9:12 AM

Answers

  • Found the problem. Did not have the

    UIThreadInvoker.Invoke((ThreadInvoker)delegate()
    {
        // Do some more testing
    });

    In every test. Now that I have it works great.

     

    /Christer

     

    Friday, December 23, 2011 9:08 AM

All replies

  • Can you enable mixed mode debugging, turn off Enable Just My Code and add the Microsoft symbol servers to your symbol path and then break when it is frozen and post the whole callstack?

    Ryan


    Tuesday, December 20, 2011 5:47 PM
  • Found the problem. Did not have the

    UIThreadInvoker.Invoke((ThreadInvoker)delegate()
    {
        // Do some more testing
    });

    In every test. Now that I have it works great.

     

    /Christer

     

    Friday, December 23, 2011 9:08 AM
  • Hello Christer,

    Glad to hear you have had your issue resolved. And thanks for sharing us your solution here.

    Have a nice day.


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us
    Friday, December 23, 2011 9:30 AM