I'm getting error when I use azure caching but not using HttpRuntime.Cache:
Type 'System.Web.Services.Protocols.LogicalMethodInfo' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. If the type is a collection, consider marking it with the CollectionDataContractAttribute. See the Microsoft .NET Framework documentation for other supported types.
After searching I noticed of this article that says "HttpRuntime.Cache doesn't serialize data at all"
What is the default serialization used by the ASP.net HttpRuntime.Cache
Sample Code:
protected void Page_Load(object sender, EventArgs e)
{
List<myclass> items = new List<myclass>();
MyClass item1 = new MyClass() { ID = 1 };
items.Add(item1);
HttpRuntime.Cache.Insert("test1", items); //working
DataCache cache = new DataCache("default");
cache.CreateRegion("reg");
cache.Put("test2", items, "reg");//error
}
}
public class MyClass
{
public MyClass()
{
Type myType = typeof(MyService);
MethodInfo myMethodInfo = myType.GetMethod("Add");
_log = new **LogicalMethodInfo**(myMethodInfo);
}
public int ID { get; set; }
public **LogicalMethodInfo** _log;
}
public class MyService
{
public int Add(int xValue, int yValue)
{
return (xValue + yValue);
}
}