0

I'm using NHibernate 2.1.2 via Castl ActiveRecord. I wanted to set up second level cache using SysCache. But I got error:

Unable to cast object of type 'NHibernate.Caches.SysCache.SysCacheProvider' to type 'NHibernate.Cache.ICacheProvider'.

How can I correct this?

Afshar Mohebi
  • 10,479
  • 17
  • 82
  • 126
  • That shouldn't be a problem. We are using that provider without any problem. How have you configured it? Are you using the ActiveRecordFacility? – jishi Feb 09 '11 at 13:31
  • 5
    Sounds like a version mismatch. Make sure the cache provider assembly is the one for NHibernate 2.1.2 – Mauricio Scheffer Feb 09 '11 at 14:11
  • @Mauricio: I'm using NHibernate 2.1.2.4000, Castle.ActiveRecord 2.1.2.6725 and NHibernate.Caches.SysCache 2.1.2.4000. Is it the problem? – Afshar Mohebi Feb 10 '11 at 04:37
  • @jishi: My configurations is based on followings: http://www.castleproject.org/activerecord/documentation/v1rc1/advanced/secondLevelCache.html and http://www.klopfenstein.net/lorenz.aspx/using-syscache-as-secondary-cache-in-nhibernate I'm not using `ActiveRecordFacility`. – Afshar Mohebi Feb 10 '11 at 04:47

2 Answers2

1

I'm guessing that you have some assemblies locally in your project and others in the GAC which have a version mismatch as Mauricio is saying. Make sure that NHibernate.Caches.SysCache.dll is in your bin folder (for your website), is the correct version and check that you don't have it in the GAC.

jishi
  • 24,126
  • 6
  • 49
  • 75
0

I found the reason. It was a nasty problem from ours. My team have merged all Castle ActiveRecord related assemblies together with ilmerge.exe and suppose named it Company.NHibernate.dll. I have not merged NHibernate.Caches.SysCache.dll with Company.NHibernate.dll. I have just put NHibernate.Caches.SysCache.dll alongside of Company.NHibernate.dll and mentioned name of NHibernate.Caches.SysCache in provider_class.

When I merged NHibernate.Caches.SysCache.dll with Company.NHibernate.dll and mentioned name of Company.NHibernate.dll in provider_class instead, everything went OK.

Thanks all users that tried to help me.

Afshar Mohebi
  • 10,479
  • 17
  • 82
  • 126