6

I wrote program in C# that invokes MSTest from command line. One of test cases throws StackOverflowException and it causes, that QtAgent32 (and my application) process breaks. What can I do to prevent from this situation (I can't change unit tests)?

1
  • Can you share your c# code? Ideally same dialog box should appear from the c# code as well and am wondering whether it has something to do with process startInfo parameters? Commented Nov 12, 2010 at 15:55

2 Answers 2

3

One way by which you can avoid these kind of crashes is by setting the legacyUnhandledExceptionPolicy property in QTAgent32.exe.config (and/or QTAgent.exe.config depending upon the bitness of the machine/testrun) as mentioned here. Relevant text from this link is: -

As a temporary compatibility measure, administrators can place a compatibility flag in the section of the application configuration file. This causes the common language runtime to revert to the behavior of versions 1.0 and 1.1.

This will switch the "unhandled exception" handling behaviour to .net 1.1 and the process will not crash on such exceptions.

Sign up to request clarification or add additional context in comments.

Comments

2

The problem is that you cannot catch StackOverflowException on .NET (starting with the 2.0 version). This probably means that there is no way to solve the problem you have - because the unit testing framework simply cannot catch the exception.

See the following related SO question:

There are some interesting suggestions on the other thread - for example, you can create Thread and check the current FrameCount to detect the stack overflow earlier. However, that probably won't be very reliable. So, I'm afraid there is no good answer...

2 Comments

OK, but when I invoke MSTest from command line (not from C# code), when this unit test is executing I can just click cancel on error message box and MSTest continue to run. I don't know how to do something like this but in C# code
@mirt -- can you add that extra information into the original question? Those are good details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.