Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.Object' to type 'System.Byte[] #17

Open
craigvn opened this issue May 14, 2016 · 8 comments
Open

System.Object' to type 'System.Byte[] #17

craigvn opened this issue May 14, 2016 · 8 comments

Comments

@craigvn
Copy link

craigvn commented May 14, 2016

I added this nuget 3.0 beta 4 to an app and I get the error System.Object' to type 'System.Byte[]. Any ideas?

@TheCloudlessSky
Copy link
Owner

Hi @craigvn,

What's the full stack trace? Also, how are you configuring the cache provider?

@craigvn
Copy link
Author

craigvn commented May 15, 2016

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)

@TheCloudlessSky
Copy link
Owner

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.

@craigvn
Copy link
Author

craigvn commented May 15, 2016

Ah, I stuffed up. My config is actually

NHibernate.Caches.Redis.RedisCacheProvider,
NHibernate.Caches.Redis

Can this be related to lazy load properties?

@TheCloudlessSky
Copy link
Owner

Ok.

  1. 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?
  2. What's all the configuration for RedisCacheProvider (including SetConnectionMultiplexer and SetOptions)?
  3. What's the mapping cache configuration for each of your entities?
  4. Can you make a small reproducible failure case (e.g. a project you can send me)?

@craigvn
Copy link
Author

craigvn commented May 16, 2016

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.

  1. 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?
  2. What's all the configuration for RedisCacheProvider (including
    SetConnectionMultiplexer and SetOptions)?
  3. What's the mapping cache configuration for each of your entities?
  4. 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
#17 (comment)

@craigvn
Copy link
Author

craigvn commented May 18, 2016

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.

@TheCloudlessSky
Copy link
Owner

Ok, I'm interested in seeing what you can come up with to reproduce this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants