tags:

views:

172

answers:

2

I developing windows form application in c#.net. Sometimes my program throw an error, windows error dialog shown (Please tell Microsoft about this problem, Send error report, Dont sent, bla bla...). I dont know why this dialog shown. What happening on my program?

+4  A: 

I dont know why this dialog shown.

Because you don't handle the exception in your program, indicating a bug. Windows' default resort is the shown dialog. Your job is to either prevent or handle all potential exceptions in your code, Windows doesn't do this for you (or rather, it does; only not to your liking).

Konrad Rudolph
Why are you suggesting to handle them? Much better not to handle unexpected exceptions, and have the user report them. Subscribe to Windows Error Reporting to get the nice summaries Microsoft compiles for you.
MSalters
Well, an application that doesn't handle all exceptions contains at least one bug by definition. Do you suggest shipping a buggy application? Of course I did *not* suggest writing a catch-all handler that simply suppresses the exception dialog without taking appropriate actions.
Konrad Rudolph
A: 

Just to extend Konrad's answer. You can handle expected errors using a try..catch.

try
{
    // operation that may throw an error
}
catch(Exception ex)
{
    // handle the exception. 
    // You might tell the user about the error with a messagebox
}
Jab