detect windows errors/popups

My app doesn't cover all the exception scenarios. During run time, sometimes a window pops up which shows the error for ex: "System Null reference exception" or "The file or directory is corrupted and unreadable". Once the error window comes up, it doesn't go away until the user responds with the buttons.

I want to capture these exception and don't want to show these error windows to the users.

Answers


You can catch all exceptions on AppDoamin Level by signing for UnhandledException event

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

You need to wrap your code in a try {} catch(Exception e) {} block so you can catch the error yourself.

example:

try
{
  // all of my code
}
catch ( Exception e )
{
  // show my own error dialog
}

Need Your Help

The action can't be completed because the file is open in IIS Worker Process

c# asp.net .net c#-4.0 file-upload

I am uploading a image for a user & saving it on a specified location. The code is working fine in normal scenario i.e. user selects a image & save it, it works.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.