隔离存储设置问题

Aru*_*run 0 isolatedstorage windows-phone-7 windows-phone

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

在线

var names = IsolatedStorageSettings.ApplicationSettings; // Here it showing an error that 
Run Code Online (Sandbox Code Playgroud)

"命名空间'IsolatedStorageSettings'中不存在类型或命名空间名称'ApplicationSettings'(你是否缺少程序集引用?)".

我导入了类库.但问题仍然存在.

我在下面粘贴了我的代码.

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();
    }
}
}
Run Code Online (Sandbox Code Playgroud)

San*_*thu 5

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

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

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