I am trying to configure Fluent NHibernate with MemCache but I get the following error. I am using MVC5+CastleWindsor+FluentNHibernate+UOW
private static ISessionFactory CreateNhSessionFactory()
{
var connStr = System.Configuration.ConfigurationManager.ConnectionStrings["AESConnect"].ConnectionString;
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(connStr))
.Cache(c=>c.ProviderClass(typeof(NHibernate.Caches.MemCache.MemCacheProvider).AssemblyQualifiedName).UseSecondLevelCache())
.ExposeConfiguration(e=>e.SetProperty("hibernate.cache.use_second_level_cache","true"))
.Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetAssembly(typeof(HotelsMap))))
.BuildSessionFactory();
}
Error:
[NullReferenceException: Object reference not set to an instance of an object.] Memcached.ClientLibrary.SockIOPool.Initialize() in C:\devroot\memcacheddotnet\trunk\clientlib\src\clientlib\SockIOPool.cs:441 NHibernate.Caches.MemCache.MemCacheProvider.Start(IDictionary`2 properties) +3627
NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners) +1098
NHibernate.Cfg.Configuration.BuildSessionFactory() +181
FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() +73[FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
] FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() +117 AESRepositories.Installers.AESInstaller.CreateNhSessionFactory() ....
Thanks in advance
It looks to be a problem with the server list not being initialised.
This is from the SockIOPool.cs file:
The same file has an initialisation example like this:
Maybe you are missing the configuration of the connection pool, or maybe you are not initialising it.