Silverlight OOB How to throw exception and exit program with Messagebox

105 Views Asked by At

In Silverlight Out of Broweser, How does one: 1) Throw an Exception 2) Display Messagebox with the error 3) Terminate the Application?

Can't seem to find any info on the net. Cheers!

1

There are 1 best solutions below

0
Nooodles On

Exceptions work in Silverlight as in any C# code.

Here's a simple sample code that should help you.

try
{
  //Whatever you want to try
}
catch(Exception e)
{
  //Display error message
  MessageBox.Show(e.Message);

  //Close the application
  Application.Current.MainWindow.Close();
}