例如,尝试在Application_Unhan进入下面一行App.Xaml.cs的dledException方法(App.Xaml的代码隐藏) “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); });
}
}
很奇怪!你有没有尝试在你的Silverlight代码开始时设置一个中断点,并且看看你是否可以得到一条失败的线? – NickHeidke
我做了,并且在构造函数后面的App.xaml.cs中出现错误。 我创建了一个新的silverlight项目并复制了所有的.xaml和.cs,并且它再次正常工作。仍然会有兴趣找到问题。 – MarkNach
发布此异常的InnerException。这是真的出错了。 –