I am trying to do a simple test with isolated storage, so I can use it for the Windows Phone 7 application that I am doing.
The test that I create sets a, creates the key and value with one button, and with the other button sets this value equal to the TextBlock text.
namespace IsoStore { public partial class MainPage : PhoneApplicationPage { // Constructor public MainPage() { InitializeComponent(); } public class AppSettings { IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings; private void button1_Click(object sender, RoutedEventArgs e) { appSettings.Add("email", " someone@somewhere.com "); } private void button2_Click(object sender, RoutedEventArgs e) { textBlock1.Text = (string)appSettings["email"]; } } } }
This method gives me this error:
It is not possible to access the non-stationary member of the external type "IsoStore.MainPage" through the nested type "IsoStore.MainPage.AppSettings"
So, I tried this:
namespace IsoStore { public partial class MainPage : PhoneApplicationPage { // Constructor public MainPage() { InitializeComponent(); } public class AppSettings { IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings; private void button1_Click(object sender, RoutedEventArgs e) { appSettings.Add("email", " someone@somewhere.com "); } } private void button2_Click(object sender, RoutedEventArgs e) { textBlock1.Text = (string)appSettings["email"]; } } }
And instead, I get this error:
The name "appSettings" does not exist in the current context
So what obvious problem do I not see here?
Thanks so much for your time.
c # visual-studio-2010 windows-phone-7 isolatedstorage
Dan
source share