例如,尝试在 App.Xaml.cs(App.Xaml 的代码隐藏)的 Application_UnhandledException 方法中输入以下行
“MessageBox.Show(e.ExceptionObject.Message);” . 这可以让您了解当调试器尚未连接浏览器时出了什么问题。购买方式,在 Visual Studio 中,您可以在调试菜单中手动将调试器附加到浏览器 -> 附加到进程...,然后选择类型为“Silverlight,x86”的进程,例如。
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
MessageBox.Show(e.ExceptionObject.Message);
// If the app is running outside of the debugger then report the exception using
// the browser's exception mechanism. On IE this will display it a yellow alert
// icon in the status bar and Firefox will display a script error.
if (!System.Diagnostics.Debugger.IsAttached)
{
// NOTE: This will allow the application to continue running after an exception has been thrown
// but not handled.
// For production applications this error handling should be replaced with something that will
// report the error to the website and stop the application.
e.Handled = true;
Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
}
}