2 using System.Collections.Generic;
\r
5 using System.Windows;
\r
6 using System.Windows.Controls;
\r
7 using System.Windows.Documents;
\r
8 using System.Windows.Input;
\r
9 using System.Windows.Media;
\r
10 using System.Windows.Media.Animation;
\r
11 using System.Windows.Shapes;
\r
13 namespace PsychlopsSilverlight5test
\r
15 public partial class App : Application
\r
20 this.Startup += this.Application_Startup;
\r
21 this.Exit += this.Application_Exit;
\r
22 this.UnhandledException += this.Application_UnhandledException;
\r
24 InitializeComponent();
\r
27 private void Application_Startup(object sender, StartupEventArgs e)
\r
29 this.RootVisual = new MainPage();
\r
32 private void Application_Exit(object sender, EventArgs e)
\r
37 private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
\r
39 // If the app is running outside of the debugger then report the exception using
\r
40 // the browser's exception mechanism. On IE this will display it a yellow alert
\r
41 // icon in the status bar and Firefox will display a script error.
\r
42 if (!System.Diagnostics.Debugger.IsAttached)
\r
45 // NOTE: This will allow the application to continue running after an exception has been thrown
\r
46 // but not handled.
\r
47 // For production applications this error handling should be replaced with something that will
\r
48 // report the error to the website and stop the application.
\r
50 Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
\r
54 private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
\r
58 string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
\r
59 errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");
\r
61 System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
\r