例如,嘗試在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。這是真的出錯了。 –