2010-12-06 11 views
1

WP7アプリケーションにErrorPage.xamlページがあります。未処理の例外が発生すると、app.xaml.csのメソッドが呼び出され、例外がErrorPage.xaml.csに渡され、エラーがメインページに戻るためのリンクと共にユーザーに表示されます。
AppBarアイコンボタンをすばやくクリックすると、ナビゲーション失敗イベントが発生し、errorpageは引き続き呼び出されますが、エラーページには何も表示されません。 AppBarのみが表示されます。wp7エラー処理

はここで、なぜ

を把握することはできません私のapp.xaml.csのコード

 // Code to execute on Unhandled Exceptions 
    private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) 
    { 
     if (System.Diagnostics.Debugger.IsAttached) 
     { 
      // An unhandled exception has occurred; break into the debugger 
      System.Diagnostics.Debugger.Break(); 
     } 

     e.Handled = true; 
     ErrorPage.Exception = e.ExceptionObject; 
     (RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Source = 
      new Uri(Navigation.PAGE_ERROR, UriKind.Relative); 
    } 

Error.xamlこの

<Grid x:Name="LayoutRoot" Background="{StaticResource GlobalPageBackgroundBrush}" CacheMode="BitmapCache"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 

    <!--TitlePanel contains the name of the application and page title--> 
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="24,24,0,12"> 
     <TextBlock x:Name="ApplicationTitle" Text="{StaticResource AppName}" Style="{StaticResource PhoneTextNormalStyle}" FontWeight="SemiBold"/> 
     <TextBlock x:Name="PageTitle" Text="error" Margin="-3,-8,0,0" Style="{StaticResource PhoneTextTitle1Style}"/> 
    </StackPanel> 
    <!--ContentPanel - place additional content here--> 
    <Grid x:Name="ContentPanel" Grid.Row="1"> 
     <TextBlock x:Name="ErrorText" Style="{StaticResource PhoneTextTitle3Style}" TextWrapping="Wrap" /> 
     <StackPanel x:Name="FriendlyErrorStackPanel" Margin="0,100,0,0" Orientation="Vertical"> 
      <TextBlock Style="{StaticResource PhoneTextTitle3Style}" TextWrapping="Wrap"> 
       <TextBlock.Text> 
        Please click the link below to return to the main page of the application. 
       </TextBlock.Text> 
      </TextBlock>     
      <HyperlinkButton Style="{StaticResource PhoneHyperlinkStyle}" Content="Start Over" NavigateUri="/Views/MainPage.xaml" /> 
     </StackPanel> 
    </Grid> 
</Grid> 

そして最後にErrorPageのようです。 xaml.csは

public partial class ErrorPage : PhoneApplicationPage 
{ 
    public ErrorPage() 
    { 
     InitializeComponent(); 
    } 

    public static Exception Exception; 

    // Executes when the user navigates to this page. 
    protected override void OnNavigatedTo(NavigationEventArgs e) 
    { 
     if (Exception != null) 
     { 
      if (System.Diagnostics.Debugger.IsAttached) 
      { 
       FriendlyErrorStackPanel.Visibility = System.Windows.Visibility.Collapsed; 
       ErrorText.Text = Exception.ToString(); 
      } 
      else 
      { 
       FriendlyErrorStackPanel.Visibility = System.Windows.Visibility.Visible; 
       ErrorText.Text = GlobalConstants.DEFAULT_ERROR_MESSAGE; 
      } 
     } 

     base.OnNavigatedTo(e); 
    } 
} 
+0

私は、このエラーページから** forward **をメインページにナビゲートしていることが懸念されます。それはあなたが_back_ 2xを押して、おそらくエラー状態に戻ることを示唆していますか? –

+0

WP7トレーニングツールキットには、処理されない例外についてエラーページがユーザーに表示されるサンプルが表示されます。私はそれを拡張して、ユーザーにフレンドリーなメッセージを表示し、メインページにアクセスしてアプリケーションを再利用できるようにしました。この合格証明書に問題はありますか? –

+0

@PratikKothari私は、エラーページから戻って前のアクションをもう一度試みることができる市場で複数のアプリを持っているので、間違いなく認証を通過します。 Mango/WP 7.1ではバックスティックをクリアすることで、アプリを終了させることができますが、ユーザーが再試行できるようにするかどうかや、エラーが重大であることを検出してアプリを再起動する必要があります。 –

答えて

0

Application_UnhandledExceptionにヒットし、ExceptionがHandled = trueと設定されていると思われますが、2つの連続したボタンが連続して表示された場合は不安定になる可能性があります。これはAppBarボタンが、何かをする(無効にすると無効にして再度有効にする)

また、Navigateメソッドの呼び出しにDispatcher.BeginInvoke()を使用していない場合は、このメソッドを使用することを検討してください。