PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Visual Studio 2008/VBSL3OOB/VBSL3OOB/App.xaml.vb

#
Visual Basic | 44 lines | 25 code | 12 blank | 7 comment | 0 complexity | ec08ef9908d5a1dce3c3d14c8419bee8 MD5 | raw file
  1. Partial Public Class App
  2. Inherits Application
  3. public Sub New()
  4. InitializeComponent()
  5. End Sub
  6. Private Sub Application_Startup(ByVal o As Object, ByVal e As StartupEventArgs) Handles Me.Startup
  7. Me.RootVisual = New MainPage()
  8. End Sub
  9. Private Sub Application_Exit(ByVal o As Object, ByVal e As EventArgs) Handles Me.Exit
  10. End Sub
  11. Private Sub Application_UnhandledException(ByVal sender As object, ByVal e As ApplicationUnhandledExceptionEventArgs) Handles Me.UnhandledException
  12. ' If the app is running outside of the debugger then report the exception using
  13. ' the browser's exception mechanism. On IE this will display it a yellow alert
  14. ' icon in the status bar and Firefox will display a script error.
  15. If Not System.Diagnostics.Debugger.IsAttached Then
  16. ' NOTE: This will allow the application to continue running after an exception has been thrown
  17. ' but not handled.
  18. ' For production applications this error handling should be replaced with something that will
  19. ' report the error to the website and stop the application.
  20. e.Handled = True
  21. Deployment.Current.Dispatcher.BeginInvoke(New Action(Of ApplicationUnhandledExceptionEventArgs)(AddressOf ReportErrorToDOM), e)
  22. End If
  23. End Sub
  24. Private Sub ReportErrorToDOM(ByVal e As ApplicationUnhandledExceptionEventArgs)
  25. Try
  26. Dim errorMsg As String = e.ExceptionObject.Message + e.ExceptionObject.StackTrace
  27. errorMsg = errorMsg.Replace(""""c, "'"c).Replace(ChrW(13) & ChrW(10), "\n")
  28. System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(""Unhandled Error in Silverlight Application " + errorMsg + """);")
  29. Catch
  30. End Try
  31. End Sub
  32. End Class