0

我正在使用下面的代码尝试使用 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.Windows.ni.dll 中出现“System.Reflection.TargetInvocationException”类型的未处理异常

任何想法

4

1 回答 1

0

我需要使用该IsolatedStorageSettings功能,如下所示:

IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;


            settings["test"] = urlText.Text;
            settings.Save();
于 2013-12-01T04:42:31.730 回答