VSTestHost crashes and won't work anymore

For my project I am using the Visual Studio Integrated Unit Testing Framework, but I am having some issues that I have never seen before.

One of my classes is causing VSTestHost to crash. So at first I did, although it was because there was a bunch of code causing a stack overflow. What's really weird is that now, even if I create a new project or use old projects that worked before, VSTestHost crashes immediately (1/2 second after pressing the test run button). In fact, I just can't test the units anymore ... It really drives me crazy.

I tried to find many solutions on the internet to fix this problem, but nothing worked. I had to restore Windows to my last update to get it back. I'm pretty sure this is one particular test class that drove the unit-test framework crazy. When I run this test class for the first time everything goes well and all tests pass, and then every time I try to run a unit test the VSTestHost crashes, preventing me from unit testing in any project.

Here I am showing you a test that supposedly causes the program to crash. My LoadFromExe () method uses the ConfigurationManager.OpenExeConfiguration () method. I have been using this AlphaProjectConfiguration for a month without any problem.

[TestMethod()]
public void LoadGoodConfigurationFromExeTest()
{  

    using (StreamWriter sw = new StreamWriter(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).FilePath))
    {
        sw.Write(Resources.GoodConfiguration);
    }

    AlphaProjectConfiguration actual = new AlphaProjectConfiguration();
    actual.LoadFromExe();

    Assert.IsNotNull(actual);
}

      

I just did my best to solve this problem and now I am really getting rid of it. This is why I am now asking for help from the community. Thank.


Edit: This test class contains 3 other tests that almost do the same thing. I tried this on Windows 7 x64 and Windows XP x86 with VSTS 2008 SP1. The crash occurs on both systems.

+2


source to share


3 answers


I had a similar problem, luckily a hotfix that solved the problem on my machine. If you are interested in the details of this problem, I wrote about it on my blog .



0


source


I can't imagine what's going wrong here. We also have some annoying problems with MSTest. It is rather erratic and slow.

To address another type of problem, we configured the test node to rerun for each test. It might also solve your problem.

Go to Tools

Options

Test Tools

Test Execution

. Disable "Keep test execution engine between test runs".



It may take a little more time to start the test tunnel, because the test node has to be started every time. But it solves some problems.

Hope it helps.

0


source


If something goes wrong when running the test, it is possible that some resources are becoming locked by the mestest process causing the problem.

I might suggest adding some troubleshooting code to make sure all file shares are properly closed if unexpected exceptions occur. Throw exception handling around StreamWriter methods in the LoadGoodConfigurationFromExeTest method as well as the AlphaProjectConfiguration code.

Set some breakpoints or run some entries there to see where the error occurs (if any).

Additional suggestions are to fully comment out the use of the AlphaProjectConfiguration class and see if everything happens. It sounds like you are saying that it will only crash when using this class. If so, it's time to unfold in imolementation.

I'm probably not helping you much, but these are the first steps I would take without knowing how much you've already taken.

0


source







All Articles