The following code is from an example case of how to manage application state in Windows Phone version 7.1 apps.
// Code to execute when the application is activated (brought to the foreground)
// This code will not execute when the application is first launched.
private void Application_Activated(object sender, ActivatedEventArgs e)
{
if (e.IsApplicationInstancePreserved)
{
ApplicationDataStatus = "application instance preserved.";
return;
}
// Check to see if the key for the application state data is in the State dictionary.
if (PhoneApplicationService.Current.State.ContainsKey("ApplicationDataObject"))
{
// If it exists, assign the data to the application member variable.
ApplicationDataStatus = "data from preserved state.";
ApplicationDataObject = PhoneApplicationService.Current.State["ApplicationDataObject"] as string;
}
}
When I insert the code above into my example app - per the instructions given in section 6 on the web page - e.IsApplicationInstancePreserved becomes underlined in red. Also when I try to Build the app, I get the following error message in the Error List pane, at the bottom VS 2010 Express for Windows Phone. (Note: I'm using VS 2010 Express for Windows Phone, version WPDTRTMRel - 30319.174.)
'Microsoft.Phone.Shell.ActivatedEventArgs' does not contain a definition for 'IsApplicationInstancePreserved' and no extension method 'IsApplicationInstancePreserved' accepting a first argument of type 'Microsoft.Phone.Shell.ActivatedEventArgs' could be found (are you missing a using directive or an assembly reference?)
Note: my project has a reference to the component Microsoft.Phone, and I do have the directive 'using Microsoft.Phone.Shell;' at the top of the .cs file, I'm inserting the code from the example app into.