2011-09-03 67 views
13

我正在为Windows Phone编写VS2010中的Silverlight数据透视应用程序。我刚刚添加了来自msdn here的示例代码。现在,每次我重新加载设计者时,我都会遇到异常:无法确定呼叫者的应用程序身份?

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

在System.IO.IsolatedStorage.IsolatedStorage.InitStore(IsolatedStorageScope范围,类型appEvidenceType)

在System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope范围,类型applicationEvidenceType)

在System.IO .IsolatedStorage.IsolatedStorageSettings.get_ApplicationSettings(c)中 在SettingsSample.AppSettings..ctor():.. \ Settings.cs:行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(调用者)试图运行代码,但没有关联应用程序(应用程序标识),因此失败。也许?

有什么想法?

回答

30

由于访问Visual Studio或Expression Blend中的IsolatedStorageSettings无效,因此您需要将代码添加到DesignerProperties.IsInDesignTool

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

完美谢谢! – Lemontongs

相关问题