Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6741771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:45:54+00:00 2026-05-26T11:45:54+00:00

I have an ErrorPage.xaml page in my WP7 application. When an unhandled exception occurs,

  • 0

I have an ErrorPage.xaml page in my WP7 application. When an unhandled exception occurs, the method in app.xaml.cs is called and that passes the exception to the ErrorPage.xaml.cs and the error is displayed to the user with a link to go back to the main page.
If I click on the AppBar IconButton too fast, then the Navigation Failed event is raised, errorpage is still called but nothing is displayed on the error page. The AppBar is the only thing visible.

Cannot figure out why

Here is the code in my 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 is like this

    <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>

and finally the ErrorPage.xaml.cs is

    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);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:45:55+00:00Added an answer on May 26, 2026 at 11:45 am

    I suspect once it hits Application_UnhandledException and the Exception is set as Handled = true, it might get flaky if you get two in rapid succession – the way around this would be to make sure that the AppBar Button allows only one press while its trying to do something (so disable while its trying to navigate, and re-enable if it fails)

    Also, consider using Dispatcher.BeginInvoke() for your Navigate method call if you aren’t already doing so.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an error page error.jsf mentioned in the web.xml : <error-page> <exception-type>javax.faces.application.ViewExpiredException</exception-type> <location>/viewExpired.jsp</location>
I have a custom error page set up for my application: <customErrors mode=On defaultRedirect=~/errors/GeneralError.aspx
I have an application web.xml with the following entry: <error-page> <error-code>404</error-code> <location>/system_files/error/p_notfound.jsp</location> </error-page> However,
I have a custom error page in an Azure ASP.NET web app where I'd
I have a custom error page that should display for HTTP 404 errors. It
I have deployed my application on server and Now I am getting this error:
In my web.xml page I have the 404 error mapped to a jsp page
I am designing a test application (Using NUnit) that will have to navigate (through
I have an HTML error page which I am looking to redirect users from.
I'd like to have better error page reporting in Google Analytics. Currently, if someone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.