Configuration 使用Nhibernate.Caches.MemCached配置Fluent Nhibernate
我试图用MemCache配置Fluent NHibernate,但出现以下错误。我使用的是MVC5+CastleWindsor+FluentNHibernate+UOWConfiguration 使用Nhibernate.Caches.MemCached配置Fluent Nhibernate,configuration,fluent-nhibernate,memcached,castle-windsor,Configuration,Fluent Nhibernate,Memcached,Castle Windsor,我试图用MemCache配置Fluent NHibernate,但出现以下错误。我使用的是MVC5+CastleWindsor+FluentNHibernate+UOW 私有静态ISessionFactory CreateNhSessionFactory() { var connStr=System.Configuration.ConfigurationManager.ConnectionString[“AESConnect”]。ConnectionString; 流畅地返回。Configure
私有静态ISessionFactory CreateNhSessionFactory()
{
var connStr=System.Configuration.ConfigurationManager.ConnectionString[“AESConnect”]。ConnectionString;
流畅地返回。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();
}
错误:
[NullReferenceException:对象引用未设置为
对象中的Memcached.ClientLibrary.SockIOPool.Initialize()
C:\devroot\memcacheddotnet\trunk\clientlib\src\clientlib\SockIOPool.cs:441
NHibernate.Caches.MemCache.MemCacheProvider.Start(IDictionary`2
属性)+3627NHibernate.Impl.SessionFactoryImpl..ctor(配置cfg,IMapping 映射、设置、事件侦听器侦听器)+1098
NHibernate.Cfg.Configuration.BuildSessionFactory()+181
FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()+73 [FluentConfigurationException:配置无效或不完整 在创建SessionFactory时使用。请检查可能的原因 集合和InnerException以获取更多详细信息 ]FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() +117.Installers.AESInstaller.CreateNhSessionFactory()
提前感谢服务器列表未初始化似乎有问题 这来自SockIOPool.cs文件:
/// The pool must be initialized prior to use. This should typically be early on
/// in the lifecycle of the application instance.
同一文件的初始化示例如下:
/// String[] serverlist = {"cache0.server.com:12345", "cache1.server.com:12345"};
///
/// SockIOPool pool = SockIOPool.GetInstance();
/// pool.SetServers(serverlist);
/// pool.Initialize();
可能您缺少连接池的配置,或者您没有初始化连接池。感谢您的回复。我觉得我在设置中错过了一大步。我没有看到SockIOPool.cs文件。所以我要找出我遗漏了什么,我会在这里回复。再次感谢您的回复,并请将此帖子加入书签:)我很快就会有一些问题:)谢谢。