mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
52 lines
1.4 KiB
C#
52 lines
1.4 KiB
C#
using System;
|
|
using System.Windows;
|
|
|
|
namespace SilverlightApplication
|
|
{
|
|
public partial class App : Application
|
|
{
|
|
|
|
public App()
|
|
{
|
|
this.Startup += this.Application_Startup;
|
|
this.Exit += this.Application_Exit;
|
|
this.UnhandledException += this.Application_UnhandledException;
|
|
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Application_Startup(object sender, StartupEventArgs e)
|
|
{
|
|
this.RootVisual = new MainPage();
|
|
}
|
|
|
|
private void Application_Exit(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
|
|
{
|
|
if (!System.Diagnostics.Debugger.IsAttached)
|
|
{
|
|
e.Handled = true;
|
|
Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
|
|
}
|
|
}
|
|
|
|
private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
|
|
errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");
|
|
|
|
System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|