NHibernate.Caches.Redis
NHibernate.Caches.Redis copied to clipboard
System.Object' to type 'System.Byte[]
I added this nuget 3.0 beta 4 to an app and I get the error System.Object' to type 'System.Byte[]. Any ideas?
Hi @craigvn,
What's the full stack trace? Also, how are you configuring the cache provider?
Configuration is
<property name="cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property>
<property name="cache.use_query_cache">true</property>
<property name="cache.use_second_level_cache">true</property>
Stack trace is
System.InvalidCastException: Unable to cast object of type 'System.Object' to type 'System.Byte[]'. at NHibernate.Type.BinaryType.ToInternalFormat(Object bytes) at NHibernate.Type.AbstractBinaryType.DeepCopyNotNull(Object value) at NHibernate.Type.MutableType.DeepCopy(Object value, EntityMode entityMode, ISessionFactoryImplementor factory) at NHibernate.Type.AbstractType.Assemble(Object cached, ISessionImplementor session, Object owner) at NHibernate.Type.TypeHelper.Assemble(Object[] row, ICacheAssembler[] types, ISessionImplementor session, Object owner) at NHibernate.Cache.Entry.CacheEntry.Assemble(Object[] values, Object result, Object id, IEntityPersister persister, IInterceptor interceptor, ISessionImplementor session) at NHibernate.Cache.Entry.CacheEntry.Assemble(Object instance, Object id, IEntityPersister persister, IInterceptor interceptor, ISessionImplementor session) at NHibernate.Event.Default.DefaultLoadEventListener.AssembleCacheEntry(CacheEntry entry, Object id, IEntityPersister persister, LoadEvent event) at NHibernate.Event.Default.DefaultLoadEventListener.LoadFromSecondLevelCache(LoadEvent event, IEntityPersister persister, LoadType options) at NHibernate.Event.Default.DefaultLoadEventListener.DoLoad(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) at NHibernate.Event.Default.DefaultLoadEventListener.Load(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) at NHibernate.Event.Default.DefaultLoadEventListener.ProxyOrLoad(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) at NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent event, LoadType loadType) at NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType) at NHibernate.Impl.SessionImpl.Get(String entityName, Object id) at NHibernate.Impl.SessionImpl.Get(Type entityClass, Object id) at NHibernate.Impl.SessionImpl.Get[T](Object id)
According to your configuration, you're using NHibernate.Caches.SysCache.SysCacheProvider
and not this library (NHibernate.Caches.Redis
). You'll have to report this to the official NHibernate project.
Ah, I stuffed up. My config is actually
Can this be related to lazy load properties?
Ok.
- It shouldn't be related to lazy-loaded properties. I've used them in the past without any issues. If you remove the lazy-loaded properties, do you get caching exceptions?
- What's all the configuration for
RedisCacheProvider
(includingSetConnectionMultiplexer
andSetOptions
)? - What's the mapping cache configuration for each of your entities?
- Can you make a small reproducible failure case (e.g. a project you can send me)?
Thanks.
I will try and make a test case and get back to you once I find the exact area causing the problem.
Craig
On Mon, May 16, 2016 at 10:13 PM, Adrian Phinney [email protected] wrote:
Ok.
- It shouldn't be related to lazy-loaded properties. I've used them in the past without any issues. If you remove the lazy-loaded properties, do you get caching exceptions?
- What's all the configuration for RedisCacheProvider (including SetConnectionMultiplexer and SetOptions)?
- What's the mapping cache configuration for each of your entities?
- Can you make a small reproducible failure case (e.g. a project you can send me)?
— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/TheCloudlessSky/NHibernate.Caches.Redis/issues/17#issuecomment-219410996
The query cache seems to be working no problems, I have just pushed it to production :-)
The second-level cache still gives intermittent problems which I am looking into. It seems if an entity is loaded twice in a session, or something like that, it can give an error depending on the mapping. I need to investigate more.
Ok, I'm interested in seeing what you can come up with to reproduce this problem.