Detecting Exceptions During Beta Testing

2019-06-09 08:06发布

(see update below)

While running within the VisualStudio 2010 environment, I can easily tell if my Winform application causes an exception. I just have to go to Debug | Exceptions and make sure that both columns of checkboxes are checked. I then run the application and if any exceptions then I get dropped straight into the offending piece of code.

How do I determine exceptions during testing, when I give test build to a tester. I do not want the tester to run within Visual Studio, just as a regular user. I still want to know if there are exceptions and the pertinent details.

Obviosualy, I should be able to control the process, so that when the code gets released normal execution happens.

Yes, I know about and use try/catch blocks, but I am talking about a method similar to Visual Studio exception catcher and reporter, just possibly compiled into the product and used for deployment to beta testers.

Maybe Visual Studio has such a feature, in which case where and how to set up, or possibly a third party component.

[Update: I added two sub-questions, which you can find at Unhandled Exception next line or exit.

The solution mentioned below sounds great and with a tweak probably works, just not at the moment.

Inside the Visual Studio both 2010 and now 2012 works great. The exception handler gets called, okay after VS breaks at the line and I say to continue. I decided to test outside the VS2012 IDE, good thing for that. The OS traps the bug, shows the standard an "An Unhandled Exception Occurred" dialog giving the details along with a continue and quit buttons. Selecting continue, just continues the application with no trapping into my uber exception handler. Selecting quite, whites-out the application and displays the standard close window dialog. The quit button also does not call my uber handler.

The purpose is so that my exception handler gets called. I do not need an uber exception handler if I am working inside the VS2012 IDE. The purpose of the handler is for end users and beta testers, namely anyone other than myself and who will not have my development station.

So unless I am missing something, the question is still open.

There are code samples in the other question, enough to copy and paste and create a test application in a couple minutes time. ]

Thanks in advance,

Sarah

2条回答
仙女界的扛把子
2楼-- · 2019-06-09 08:26

Okay, the Google Uberlord took pitty upon me and I found this wonderful article solving the problem. Praise to the almighty Google.

Here is the link: http://www.switchonthecode.com/tutorials/csharp-tutorial-dealing-with-unhandled-exceptions

Basically, JRadness had the right idea, just slightly in error. He should have used

Application.ThreadException += 

new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

rather than

AppDomain.CurrentDomain.UnhandledException += 
    new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

The author on Switch on the Code talked of three methods, the first of which is what JRadness proposed and does not work for Windows forms.

The autor even solved my other question of Continue and Abort. The OS got bypassed.

Yeah!!

查看更多
叛逆
3楼-- · 2019-06-09 08:44

I don't know of any automagical ways to reports error in Visual Studio but here is what I do.

  1. Hook into the UnhandledException event for the application.

  2. Use a logging framework like nLog or Log4Net to log the exception and other data you get from that event. Or just write to a text file.

  3. Upload that data either from within your application or have the beta-tester send it to you.

查看更多
登录 后发表回答