* MoonlightTypeConverter.cs: Convert CacheMode's from strings.
[moon.git] / test / 2.0 / ApplyTemplateInMeasure / App.xaml.cs
blob8090d414aa0626a45dd1a380737cd71aece9c3d3
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Net;
5 using System.Windows;
6 using System.Windows.Controls;
7 using System.Windows.Documents;
8 using System.Windows.Input;
9 using System.Windows.Media;
10 using System.Windows.Media.Animation;
11 using System.Windows.Shapes;
12 using System.Windows.Markup;
14 namespace ApplyTemplateInMeasure
16 public partial class App : Application
19 public App()
21 this.Startup += this.Application_Startup;
22 this.Exit += this.Application_Exit;
23 this.UnhandledException += this.Application_UnhandledException;
25 InitializeComponent();
28 private void Application_Startup(object sender, StartupEventArgs e)
30 this.RootVisual = new Page();
33 private void Application_Exit(object sender, EventArgs e)
37 private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
39 // If the app is running outside of the debugger then report the exception using
40 // the browser's exception mechanism. On IE this will display it a yellow alert
41 // icon in the status bar and Firefox will display a script error.
42 if (!System.Diagnostics.Debugger.IsAttached)
45 // NOTE: This will allow the application to continue running after an exception has been thrown
46 // but not handled.
47 // For production applications this error handling should be replaced with something that will
48 // report the error to the website and stop the application.
49 e.Handled = true;
50 Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
53 private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
55 try
57 string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
58 errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");
60 System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight 2 Application " + errorMsg + "\");");
62 catch (Exception)