Wednesday, December 20, 2006

Using SQL Server 2005 Exception Message box in your C# Application

SQL Workbench of SQL Server 2005 has a beautiful user interface. An interesting dialog for most of the developers in that user interface is Exception Message box.When ever an error occurs SQL Work bench shows that error with full information about the exception and a sample dialog box is shown below

If wish to use the same messagebox to show exceptions raised in your .NET application then you are lucky. Microsoft has exposed the message box class ExceptionMessageBox in the dll Microsoft.ExceptionMessageBox. The following is the sample code to demonstrate use of the exception message box

private void Form1_Load(object sender, EventArgs e)
int a, b, c;

//Set values
a = 10;
b = 0;
//Raise error
c = a / b;
catch (Exception exp)
ExceptionMessageBox objMsgBox;

objMsgBox = new ExceptionMessageBox(exp);

1 Comment:

Anonymous said...

This Message Box is really excellent. But do you know how to localize the user interface?

Thanks in Advance, Alexandra