When a 开发者_如何转开发Silverlight project throws an exception it ends up raising a "script error" dialog that needs to be acknowledged before proceeding. We're using Silverlight for part of the content on a HTML page, but don't want the error dialog to appear if that content is unavailable. Instead we are already writing the script error to a log and consider that sufficient.
Is it possible to prevent that dialog appearing on an uncaught exception? Is the only solution to catch and handle all exceptions? I have tried removing the "onError" parameter with its value of "onSilverlightError" but that made no difference.
in the App.xaml.cs there will be "ReportErrorToDOM" event handler, completely comment all the code inside the handler, then you will not see any dialog box.
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)
{
}
}
your code might be little bit, just comment all the code inside the event handler then you should be ok.
精彩评论