title: Windows Phone App crashes when using NavigationService.GoBack() too soon
body: <p>Even though <code>NavigationService.CanGoBack</code> returns <code>True</code>, <code>NavigationService.GoBack()</code> throws me these exceptions :</p>
  
  <pre><code>A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
  A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in 
  </code></pre>
  
  <p><strong>This happens systematically on two case, while the third works fine :</strong></p>
  
  <ul>
  <li>Crashes if I call <code>NavigationService.GoBack()</code> <strong>in <code>OnNavigatedTo()</code></strong></li>
  <li>Crashes If I call <code>NavigationService.GoBack()</code> <strong>as a result of <code>WebException</code> thrown in my <code>HTTPWebRequest</code></strong> when Internet is not available [1]</li>
  <li>Works fine if Internet is available and I call <code>NavigationService.GoBack()</code> when my <code>HTTPWebRequest</code> got results, parsed them, and displayed them.</li>
  </ul>
  
  <p>My theory is that I can't call <code>GoBack()</code> too soon after navigating from a page to another... My question : <strong>How can I programatically go back up the navigation stack when an <code>HTTPWebRequest</code> fails to load ?</strong></p>
  
  <p>Edit : I've decided to do it another way, but I think my problems might be due to navigation animations and the Windows Phone C# Toolkit (I use Feb 2011 edition)</p>
  
  <hr>
  
  <p>[1] Details of my code on case 2 :</p>
  
  <p>I have a simple <code>HTTPWebRequest</code>. My callback does this, and my app crashes when in Airplane Mode. The line <code>NavigationService.GoBack()</code> is responsible, even though <code>NavigationService.CanGoBack</code> returns <code>true</code>.</p>
  
  <pre><code>        try
          {
              response = request.EndGetResponse(result);
          }
          catch (WebException)
          {
              Dispatcher.BeginInvoke(() =&gt;
              {
                  NavigationService.GoBack();
              });
          }
  </code></pre>
  
  <p>I tried using <code>Deployment.Current.Dispatcher.BeginInvoke()</code> also.</p>