title: Test App failing on Back Button... Windows Phone 7
body: <p>Ok this question stems from this question:
  <a href="https://stackoverflow.com/questions/5530555/wp7-app-failing-can-not-figure-out-where">wp7: App failing!  Can not figure out where?</a></p>
  
  <p>I thought it was corrected but it is still failing.  I ripped out all of the app.xaml.cs code and it still crashing when the search button is clicked and the back button is immediately pressed.</p>
  
  <p>So...  I decided to see if I could replicate the issue with a new test app.  Basically I have create a basic pivot application with the default Main View Model.  None of my code exists...  </p>
  
  <p>I press the search button and then immediately press the back button and low and behold...  The SAME THING HAPPENS....  It crashes the application, the emulator shows a blank screen and the debugger stops!</p>
  
  <p>So...  That leads me to believe that I've found a bug in the emulator (I find this very hard to believe)...  OR, my Studio environment maybe is corrupted (I'm hoping it is not).</p>
  
  <p>I'm not sure where to go on this one.  I don't know what the error is, and it is preventing my apps from being accepted on the market place.</p>
  
  <p>Does anyone have any ideas?</p>
  
  <p><strong>I made a screen capture of what I'm seeing:</strong>  </p>
  
  <p>Notice that the 1st 3 search/back combos work as the boxes in the search screen are allowed to display.  However, the last 2 search/back combos don't work as you will see that the boxes aren't allowed to display...</p>
  
  <p><a href="http://www.youtube.com/watch?v=XVht3OtBGaI" rel="nofollow noreferrer">http://www.youtube.com/watch?v=XVht3OtBGaI</a></p>
  
  <p><strong>The error report I'm getting from Microsoft:</strong></p>
  
  <pre><code>Comments: The application reactivate after deactivation and terminates unexpectedly.
  Steps to reproduce:
  1) Launch the application.
  2) Select a vehicle.
  3) Press the device's "Start" button.
  4) Select the device's "Back" button.
  5) Observe the application terminates unexpectedly and does not reactive the application.
  This error is reproducible 8 out of 10 times.
  </code></pre>
  
  <p>The other error report from a different application:</p>
  
  <pre><code>Comments: The application terminates rather than resuming when the user attempts to return from a Search.
  Steps to reproduce:
  1. Launch the application
  2. Select the Add + button
  3. Press the Search button
  4. Press the Back button
  5. Observe the application terminates after a few seconds.
  </code></pre>
  
  <p><strong>I noticed that:</strong></p>
  
  <p>When the following happens in the debugger:</p>
  
  <pre><code>The thread '&lt;No Name&gt;' (0xd1b0092) has exited with code 0 (0x0).
  The thread '&lt;No Name&gt;' (0xd6900ba) has exited with code 0 (0x0).
  </code></pre>
  
  <p>That the project DOES NOT FAIL as described (100% of the time).  However, if I click the back button before this, then the application fails (100% of the time).</p>
  
  <p><strong>Update #1: App.xaml.cs</strong> </p>
  
  <pre><code>// Code to execute when the application is launching (eg, from Start)
  // This code will not execute when the application is reactivated
  private void Application_Launching(object sender, LaunchingEventArgs e)
  {
  }
  
  // Code to execute when the application is activated (brought to foreground)
  // This code will not execute when the application is first launched
  private void Application_Activated(object sender, ActivatedEventArgs e)
  {
      // Ensure that application state is restored appropriately
      if (!App.ViewModel.IsDataLoaded)
      {
          App.ViewModel.LoadData();
      }
  }
  
  // Code to execute when the application is deactivated (sent to background)
  // This code will not execute when the application is closing
  private void Application_Deactivated(object sender, DeactivatedEventArgs e)
  {
  }
  
  // Code to execute when the application is closing (eg, user hit Back)
  // This code will not execute when the application is deactivated
  private void Application_Closing(object sender, ClosingEventArgs e)
  {
      // Ensure that required application state is persisted here.
  }
  </code></pre>