在隔离存储中存储一个字典<TKey, TValue>

3
我正在访问服务器并获取一些数据,然后解析这些数据并将其存储在一个Dictionary<TKey, TValue>中。
我将这个Dictionary<TKey, TValue>列表存储在隔离存储中。现在的问题是,在第二次运行时,当我尝试检索Dictionary<TKey, TValue>时(即使在第一次运行时已经存储了值),bean中每个键的值都变成了null。我不知道我存储Dictionary<TKey, TValue>的方式是否有误。
代码示例:
CacheManager.getInstance().PersistData(CacheManager.SERVICE_TABLE, 
    dictionaryList);

public void PersistData(string storageName, object dict)
{
    try
    {
        PersistDataStore.Add(storageName, dict);
        PersistDataStore.Save();
    }
    catch (Exception ex)
    {
    }
}

@Apoorva,我们需要知道你在缓存方面使用的框架是哪个。 - Claus Jørgensen
1个回答

2

我找到了解决问题的方法,字典dict的成员必须进行序列化。即,

using System.Runtime.Serialization;
[DataContact]
public class classname()
{
[datamember]
public int propertyname;
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接