I'm writing a Silverlight pivot app in VS2010 for Windows Phone. I just added the example code from msdn here. Now every time I reload the designer I get an exception:
Unable to determine application identity of the caller.
at System.IO.IsolatedStorage.IsolatedStorage.InitStore(IsolatedStorageScope scope, Type appEvidenceType)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope scope, Type applicationEvidenceType)
at System.IO.IsolatedStorage.IsolatedStorageSettings.get_ApplicationSettings() at SettingsSample.AppSettings..ctor() in C:..\Settings.cs:line 34
Is this a bug in Visual Studio/Windows Phone SDK?
This is the code in the constructor at line 34:
public AppSettings()
    {
        // Get the settings for this application.
        try
        {
            settings = IsolatedStorageSettings.ApplicationSettings;
        }
        catch (System.Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
I added the try-catch to see what was going on.
I suspect that Visual Studio(the caller) is attempting to run the code but there is no application(application identity) associated, so it fails. Maybe?
Any thoughts?
You need to add a check to DesignerProperties.IsInDesignTool to that code since accessing IsolatedStorageSettings in Visual Studio or Expression Blend is invalid.
if (!System.ComponentModel.DesignerProperties.IsInDesignTool)
{
     settings = IsolatedStorageSettings.ApplicationSettings; 
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With