无法确定呼叫者的应用程序身份?

Lem*_*ngs 13 c# silverlight exception visual-studio-2010 windows-phone-7

我正在VS2010 for Windows Phone中编写一个Silverlight透视应用程序.我刚刚在这里添加了msdn的示例代码.现在,每当我重新加载设计器时,我都会遇到异常:

无法确定调用者的应用程序标识.

在System.IO.IsolatedStorage.IsolatedStorage.InitStore(IsolatedStorageScope范围,输入appEvidenceType)

在System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope范围,输入applicationEvidenceType)

在C:..\Settings.cs:第34行的SettingsSample.AppSettings..ctor()中的System.IO.IsolatedStorage.IsolatedStorageSettings.get_ApplicationSettings()

这是Visual Studio/Windows Phone SDK中的错误吗?

这是第34行构造函数中的代码:

public AppSettings()
    {
        // Get the settings for this application.
        try
        {
            settings = IsolatedStorageSettings.ApplicationSettings;
        }
        catch (System.Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
Run Code Online (Sandbox Code Playgroud)

我添加了try-catch以查看发生了什么.

我怀疑Visual Studio(调用者)正在尝试运行代码,但没有关联的应用程序(应用程序标识),因此它失败了.也许?

有什么想法吗?

Mic*_*ter 30

您需要将DesignerProperties.IsInDesignTool的检查添加到该代码,因为访问Visual Studio或Expression Blend中的IsolatedStorageSettings无效.

if (!System.ComponentModel.DesignerProperties.IsInDesignTool)
{
     settings = IsolatedStorageSettings.ApplicationSettings; 
}
Run Code Online (Sandbox Code Playgroud)