Wcf AppFabric-返回的列表对象具有空值的对象

Wcf AppFabric-返回的列表对象具有空值的对象,wcf,list,null,appfabric,Wcf,List,Null,Appfabric,我不熟悉AppFabric并对其进行探索。我能够将列表放入appfabric中,并能够使用Get方法检索列表。但是,在检索之后,对象的所有属性都设置为null。谁能帮我解决这个问题 下面是示例代码 //Country object Country country1 = new Country(); country1.Name ="test"; //Create list List <Country> countryList = new List <Country>();

我不熟悉AppFabric并对其进行探索。我能够将列表放入appfabric中,并能够使用Get方法检索列表。但是,在检索之后,对象的所有属性都设置为null。谁能帮我解决这个问题

下面是示例代码

//Country object 
Country country1 = new Country();
country1.Name ="test";
//Create list
List <Country> countryList = new List <Country>();
countryList.Add(country1);
//Add to AppFabric
_cache.Put("countryKey",countryList)
 //Retrieve from cache
List <Country> countryList  = (List <Country>)_cache.Get("countryKey");
//check the result
countryList.Count returns 1 which is expected.
countryList[0].Name returns null;
//国家/地区对象
Country Country 1=新国家();
country1.Name=“测试”;
//创建列表
List countryList=新列表();
countryList.Add(country1);
//添加到AppFabric
_cache.Put(“countryKey”,countryList)
//从缓存中检索
List countryList=(List)u cache.Get(“countryKey”);
//检查结果
countryList.Count返回预期的1。
countryList[0]。Name返回空值;

对象以序列化形式存储在缓存中。AppFabric在将项存储到缓存中之前使用该类进行序列化

空属性通常意味着序列化/反序列化中存在问题。尝试将
DataContract
属性添加到
Country
中,并将
DataMember
属性添加到要保留此类的每个属性中