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

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

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

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

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

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

这是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); } } 

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

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

有什么想法吗?

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

 if (!System.ComponentModel.DesignerProperties.IsInDesignTool) { settings = IsolatedStorageSettings.ApplicationSettings; }