0

エラーメッセージを他のページに表示したい。NullReferenceException が発生しましたが、エラーのあるページにクエリ文字列が設定されています。誰かが私のコードの何が問題なのか教えてくれますか?

 catch (Exception ex)
        {
            //Dispatcher.BeginInvoke(new Action(() =>MessageBox.Show(ex.StackTrace,"Error!",MessageBoxButton.OK)));

           string query=@"/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);

    }
4

1 に答える 1