尝试在Win Mobile 8 c#中保存数据时出现未处理的异常
本文关键字:数据 未处理 异常 保存 Win Mobile | 更新日期: 2024-06-14 03:58:57
我正在使用下面的代码尝试使用c#保存到Windows Mobile 8中的本地设置。
public void SaveInfo(string key, string value)
{
if (ApplicationData.Current.LocalSettings.Values.ContainsKey(key))
{
if (ApplicationData.Current.LocalSettings.Values[key].ToString() != null)
{
// do update
ApplicationData.Current.LocalSettings.Values[key] = value;
}
}
else
{
// do create key and save value, first time only.
ApplicationData.Current.LocalSettings.CreateContainer(key, ApplicationDataCreateDisposition.Always);
if (ApplicationData.Current.LocalSettings.Values[key] == null)
{
ApplicationData.Current.LocalSettings.Values[key] = value;
}
}
}
调用代码时,调试崩溃,出现以下异常:
类型的未处理异常中出现"System.Reflection.TargetInvocationException"System.Windows.ni.dll
任何想法
我需要使用IsolatedStorageSettings
功能,如下所示:
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
settings["test"] = urlText.Text;
settings.Save();