IsolatedStorageSettings.ApplicationSettings on persisting in emulator after emulator restarts

StackOverflow https://stackoverflow.com/questions/18730387

Pergunta

Does the emulator "remember" settings when it is restarted?

I'm using very simple code:

    private static void SetAppUniqueId()
    {
        string guid;

        var appSettings = IsolatedStorageSettings.ApplicationSettings;

        if (appSettings.Contains("GUID"))
        {
            guid = appSettings["GUID"].ToString();
        }
        else
        {
            guid = Guid.NewGuid().ToString("N");
            appSettings["GUID"] = guid;
            appSettings.Save();
        }

        App.UniqueId = guid;
    }

And when it is first ran, it creates a new GUID. Then if I do not shut the emulator down, but simply stop and restart my project, the GUID is still in app settings.

But, if I shut the emulator down, then restart my project, the GUID is re-created again.

Am I doing anything wrong, or is this expected behavior?

Foi útil?

Solução

It's a normal behaviour because each time you restart the emulator you create a new instance of it!

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top