2011-09-27 82 views
3

我正在打服务器并获取一些数据,正在解析这些数据并将其存储在Dictionary<TKey, TValue>中。在隔离存储中存储字典<TKey,TValue>

我将此Dictionary<TKey, TValue>列表存储在独立存储中。现在,问题是,无论何时试图检索第二次运行中存储的第一次运行中的Dictionary<TKey, TValue>时,bean中每个键的值都将变为空值。我不知道是否存储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) 
    { 
    } 
} 
+0

@Apoorva我们需要知道你用于缓存的是什么框架。 –

回答

2

我得到了解决这个问题,字典dict的成员必须被序列化。即

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