C# Windows.Storage.ApplicationData.Current.LocalSettings.CreateContainer中的NotImplementedException
在任何事情之前:n00b警告 我正试图向本地存储写入一些东西(至少我认为是这样),但我得到了一个C# Windows.Storage.ApplicationData.Current.LocalSettings.CreateContainer中的NotImplementedException,c#,windows-phone-8,C#,Windows Phone 8,在任何事情之前:n00b警告 我正试图向本地存储写入一些东西(至少我认为是这样),但我得到了一个NotImplementedException 我正在使用wp8.1预览版构建(8.10.12359.845),但这似乎太基本了,无法实现 我一定是做错了什么,但代码或多或少是MSDN教程所说的 代码如下: class AccountStore { private const string ContainerAccountInfo = @"account"; p
NotImplementedException
我正在使用wp8.1预览版构建(8.10.12359.845),但这似乎太基本了,无法实现
我一定是做错了什么,但代码或多或少是MSDN教程所说的
代码如下:
class AccountStore
{
private const string ContainerAccountInfo = @"account";
private const string KeyLastUpdated = "last_updated";
private const string KeyUserId = "user_id";
private const string KeyUsername = "user_name";
private const string KeyEmail = "email";
private const string KeyFullName = "full_name";
private const string KeyStatus = "account_status";
private static readonly object LOCK = new object();
private ApplicationDataContainer Settings
{
get
{
// BOOM goes the code right here: System.NotImplementedException
return Windows.Storage.ApplicationData.Current.LocalSettings.CreateContainer(ContainerAccountInfo, ApplicationDataCreateDisposition.Always);
}
}
public AccountInfo StoredAccountInfo {
get {
lock (LOCK)
{
var settings = Settings.Values;
if (settings.ContainsKey(KeyLastUpdated))
return new AccountInfo {
UserId = settings[KeyUserId] as string,
Username = settings[KeyUsername] as string,
Email = settings[KeyEmail] as string,
FullName = settings[KeyFullName] as string,
Status = AccountUtils.fromString(settings[KeyStatus] as string)
};
return AccountInfo.NULL;
}
}
set
{
lock (LOCK)
{
var settings = Settings.Values;
settings[KeyLastUpdated] = DateTime.Now;
settings[KeyUserId] = value.UserId;
settings[KeyUsername] = value.Username;
settings[KeyEmail] = value.Email;
settings[KeyFullName] = value.FullName;
settings[KeyStatus] = value.Status.ToString();
}
}
}
}
System.NotImplementedException未由用户代码处理
HResult=-2147467263
消息=未实现该方法或操作。
来源=Windows
堆栈跟踪:
在Windows.Storage.ApplicationData.get_LocalSettings()中
在APPNS.Auth.detail.AccountStore.get_Settings()中
在APPNS.Auth.detail.AccountStore.get_StoredAccountInfo()上
在APPNS.Auth.AccountManager..ctor()上
在APPNS.Auth.AccountManager.get_Instance()上
在APPNS.Auth.AccountManager.get_Info()上
在APPNS.Auth.AccountManager.get_IsRegistered()上
在APPNS.MainPage.checkRegistration()上
在APPNS.MainPage.PhoneApplicationPage_加载(对象发送方,RoutedEventTarget e)
位于MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32类型索引、委托handlerDelegate、对象发送器、对象参数)
在MS.Internal.JoltHelper.firevent处(IntPtr unmanagedObj、IntPtr unmanagedobjars、Int32 argsTypeIndex、Int32 actualgstypeindex、String eventName)
内部异常:
欢迎您的任何意见。
我上一次接触C#大约是5年前,我已经生锈了。我也没有使用Windows Phone的经验(我是一名Android开发人员)。所以,如果我在做上面完全愚蠢的事情,我也想知道
谢谢。您收到此错误是因为直到Windows Phone 8.1: (受支持的最低限度手机Windows phone 8.1[Windows phone Silverlight 8.1和Windows运行时应用])
要使用它,您的构建目标必须是WP8.1或更高版本。您是否已将“目标Windows Phone OS版本”设置为Windows Phone 8.1?你可以通过右键点击你的项目并选择“属性”来访问它。我在下拉列表中没有8.1。我还想让它与8.0及更高版本兼容。切换到隔离存储暂时有效