2011-09-03 94 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

相關問題