【发布时间】:2023-04-11 09:16:02
【问题描述】:
我正在尝试使用 MemCache 配置 Fluent NHibernate,但出现以下错误。我正在使用 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();
}
错误:
[NullReferenceException: 对象引用未设置为 对象。] Memcached.ClientLibrary.SockIOPool.Initialize() 在 C:\devroot\memcacheddotnet\trunk\clientlib\src\clientlib\SockIOPool.cs:441 NHibernate.Caches.MemCache.MemCacheProvider.Start(IDictionary`2 属性)+3627
NHibernate.Impl.SessionFactoryImpl..ctor(配置 cfg,IMapping 映射、设置设置、EventListeners 侦听器)+1098
NHibernate.Cfg.Configuration.BuildSessionFactory() +181
FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() +73[FluentConfigurationException:无效或不完整的配置 在创建 SessionFactory 时使用。检查潜在原因 集合和 InnerException 了解更多详细信息。
] FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() +117 AESRepositories.Installers.AESInstaller.CreateNhSessionFactory() ....
提前致谢
【问题讨论】:
标签: configuration fluent-nhibernate memcached castle-windsor