Problem: When caching an instance of a class and immediately getting it back out of cache, i get the object back (its not null), but all of its properties / fields are null or defaults.
_cacheHelper.PutInCache("testModuleControlInfoOne", mci);
//mci has populated fields
var mciFromCacheOne = _cacheHelper.GetFromCache("testModuleControlInfoOne");
//mciFromCacheOne now has null or default fields
So I suspect the way the object is structured is the problem and AbbFabric is not serializing the object properly for some reason.
When I use the following Serialization method however, I get the object back with all properties / fields as they were prior to serialization.
public T SerializeThenDeserialize<T>(T o) where T : class
{
BinaryFormatter bf = new BinaryFormatter();
using (MemoryStream ms = new MemoryStream())
{
bf.Serialize(ms, o);
ms.Position = 0;
return (T)bf.Deserialize(ms);
}
}
How can an object serialize and deserialize properly using the binary formatter and not do exactly the same thing via caching?
Has anyone encountered this or does anyone have any suggestions or tips on generally what to look out for?