0
我想在其他頁面上顯示錯誤消息。我得到了NullReferenceException,但查詢字符串設置在有錯誤的頁面上。有人會告訴我我的代碼有什麼問題嗎?設置查詢字符串,但仍然得到NullReferenceException
catch (Exception ex)
{
//Dispatcher.BeginInvoke(new Action(() =>MessageBox.Show(ex.StackTrace,"Error!",MessageBoxButton.OK)));
string [email protected]"/ErrorPage.xaml?msg=" + ex.StackTrace.ToString() ;
Dispatcher.BeginInvoke(new Action(() =>this.NavigationService.Navigate(new Uri(query, UriKind.Relative))));
}
有用於顯示網頁時其他網頁上加載
public ErrorPage()
{
InitializeComponent();
string msg = NavigationContext.QueryString["msg"].ToString();
lstMessage.Items.Add(msg);
}
檢查StackTrace是否超過260個字符?並嘗試使用Uri.EscapeUriString – onmyway133
@entropy它是670個字符。我改變方法來顯示消息。我將它們存儲爲全局變量,所以在下一頁我可以得到它。謝謝 –