Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to determine application identity of the caller?

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?

like image 396
Lemontongs Avatar asked Sep 03 '11 16:09

Lemontongs


1 Answers

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; 
}
like image 170
Michael S. Scherotter Avatar answered Nov 20 '22 16:11

Michael S. Scherotter