我们有一个Web应用程序,它将经常使用的数据存储在缓存中。
此前它是HttpRuntime缓存,但后来迁移到AppFabric缓存。
迁移后,它会引发以下错误,而试图将一个对象添加到高速缓存:
错误:
反序列化System.Collections.ArrayList类型的对象 - AppFabric Cache错误
System.Runtime.Serialization.SerializationException:
"There was an error deserializing the object of type
System.Collections.ArrayList. No set method for property '' in type ''."
添加到的httpRuntime缓存工作仍在。但是对于AppFabric Cache抛出上述错误。
代码片段添加项目高速缓存存储器:
public static void Add(string pName, object pValue)
{
//System.Web.HttpRuntime.Cache.Add(pName, pValue, null, DateTime.Now.AddSeconds(60), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.High, null);
appFabricCache.Add(pName, pValue);
}
以下类的实例试图在高速缓存存储器来存储。
public class Kernel
{
internal const BusinessObjectSource BO_DEFAULT_SOURCE=BusinessObjectSource.Context;
private System.Collections.ArrayList mProcesses = new System.Collections.ArrayList();
private System.Collections.Hashtable mProcessesHash = new System.Collections.Hashtable();
public SnapshotProcess mSnapShotProcess ;
private System.Collections.ArrayList mErrorInformation;
public Collections.ArrayList Processes
{
get { return mProcesses; }
}
}
任何人都知道如何解决这个问题......?谢谢。
谢谢@Cybermaxs。非常非常有用的信息。如果我们有一个编辑源类的选项,并且可以使用Serializable属性来修饰该类将解决问题...? – Sunil
NetDataContractSerializer可用于任何标有DataContractAttribute或SerializableAttribute的类型或实现ISerializable接口的类型。所以,你有三个选择! – Cybermaxs