user1235555
user1235555

Reputation: 335

what is the cause of 'System.IO.IsolatedStorage.IsolatedStorageException'?

Exceptions: A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll A first chance exception of type 'System.IO.IsolatedStorage.IsolatedStorageException' occurred in mscorlib.dll

    public static IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

    private void GetScoreData()
    {
        if (settings.Contains(dataItem2.Name))
        {
            this.textBlock2.Text = settings[dataItem2.Name].ToString();
        }
        else 
        {
            settings.Add(dataItem2.Name, "N/A");
            this.textBlock2.Text = "N/A";
        }
        settings.Save();
    }

now in the other page

i am updating its value by doing this

ScorePage.settings["MyKey"] = moves.ToString();

so everytime i restart my emulator and run my project this exception comes. any reason why?

Upvotes: 2

Views: 2863

Answers (2)

user1099894
user1099894

Reputation:

The isolated storage in the emulator is not persisted after you close it.

Reference: Windows Phone Emulator: (see features)

Isolated storage is available while the emulator is running. Data in isolated storage does not persist after the emulator closes. This includes files stored in a local database, as these files reside in isolated storage. I suggest you to use site settings over application settings. One more thing, dont worry the windows phone is persistent.(only the emulator is not!)

Upvotes: 3

Matt Lacey
Matt Lacey

Reputation: 65564

After restarting the emulator (or reinstallign the app), the contents on IsolatedStorage will be deleted. If you're trying to update a setting, first check that the key exists.

Showing the line where the exception occurs and the exact text of the exception will also help with identifying the issue.

Upvotes: 1

Related Questions