2012-03-02 57 views
0

我是windows phone開發中的新手。現在我正在嘗試研究隔離的存儲設置。 我google了一下關於獨立的存儲設置,並按照我的理解做了一個樣本。但它顯示編譯錯誤。我知道它是一個非常簡單的錯誤。孤立的存儲設置問題

在行

var names = IsolatedStorageSettings.ApplicationSettings; // Here it showing an error that 

「的類型或命名空間名稱的applicationSettings'不存在命名空間‘IsolatedStorageSettings’存在(是否缺少程序集引用?)」。

我導入了類庫。但問題仍然存在。

我粘貼了下面的代碼。

Thankx。

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Net; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Animation; 
using System.Windows.Shapes; 
using Microsoft.Phone.Controls; 
using System.IO.IsolatedStorage; 
using System.IO; 

namespace IsolatedStorageSettings 
{ 
    public partial class MainPage : PhoneApplicationPage 
{ 
    // Constructor 
    public MainPage() 
    { 
     InitializeComponent(); 

     var names = IsolatedStorageSettings.ApplicationSettings; 
     names.Add("myName", "Developer John"); 

     displayText.Text = names["myName"].ToString(); 
    } 
} 
} 

回答

5

代碼中的「命名空間IsolatedStorageSettings」這一行是罪魁禍首,因爲你試圖給同一個命名空間的名字您的應用程序重寫包括命名空間類「System.IO.IsolatedStorage.IsolatedStorageSettings」

我猜你的項目名稱爲IsolatedStorageSettings,因此它創建命名空間爲「IsolatedStorageSettings」

所以,請重命名您的應用程序的命名空間,或T ry用不同的名字創建另一個新項目,然後它適用於你。

+0

Thankx santhu。那是問題.. – Arun 2012-03-02 06:53:14

+0

如果我想要將圖像和一些變量存儲在一起,該怎麼辦? – CodeGuru 2012-06-06 17:39:35