隔离存储设置问题

时间:2012-03-02 05:59:33

标签: windows-phone-7 windows-phone isolatedstorage

我是Windows手机开发的新手。现在我正在尝试研究隔离存储设置。 我搜索了有关隔离存储设置的信息并根据我的理解做了样本。但它显示编译错误。我知道这是一个非常简单的错误。

在第

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();
    }
}
}

1 个答案:

答案 0 :(得分:5)

在您的代码“namespace IsolatedStorageSettings”中,这一行是罪魁祸首,因为您尝试为应用程序提供相同的命名空间名称会覆盖包含的命名空间类“System.IO.IsolatedStorage.IsolatedStorageSettings”

我猜您的项目名称是 IsolatedStorageSettings ,因此它将名称空间创建为“IsolatedStorageSettings”

所以,请重命名您的应用程序命名空间,或者尝试创建另一个具有不同名称的新项目,然后它适合您。