NHibernate configuration StandardQueryCache Exception Find BUG
2013.06.02
#region
configuration.Cache(c => //(Cache)
{
c.UseQueryCache = DefaultUseQueryCache;
c.UseMinimalPuts = true;
c.RegionsPrefix = "Cache";
c.DefaultExpiration = 60;//秒
if (DefaultUseSecondLevelCache)
{
c.Provider<HashtableCacheProvider>();//
c.QueryCache<StandardQueryCache>();//
//configuration.SetProperty(Environment.UseSecondLevelCache, "true");
// configuration.SetProperty(Environment.QueryCacheFactory, typeof(StandardQueryCacheFactory).FullName);
}
});
#endregion
未处理 NHibernate.HibernateException
Message=could not instantiate IQueryCacheFactory: NHibernate.Cache.StandardQueryCache, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4Source=NHibernate
StackTrace:
在 NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary`2 properties)
在 NHibernate.Cfg.Configuration.BuildSettings()
在 NHibernate.Cfg.Configuration.BuildSessionFactory()
在 Com.Zfrong.Arch.Common.Data.NH.Core.NHSessionFactoryManager.BuildSessionFactory(String key) 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\Core\NHSessionFactoryManager.cs:行号 40
在 Com.Zfrong.Arch.Common.Data.NH.Core.NHSessionFactoryManager.GetSessionFactory(String key) 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\Core\NHSessionFactoryManager.cs:行号 26
在 Com.Zfrong.Arch.Common.Data.NH.Core.NHSessionManager.GetSessionFactory(String key) 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\Core\NHSessionManager.cs:行号 71
在 Com.Zfrong.Arch.Common.Data.NH.Core.NHSessionManager.BindCurrentSession(String key, IInterceptor interceptor) 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\Core\NHSessionManager.cs:行号 35
在 Com.Zfrong.Arch.Common.Data.NH.Core.NHSessionManager.BindCurrentSession(String key) 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\Core\NHSessionManager.cs:行号 28
在 Com.Zfrong.Arch.Common.Data.NH.DatabaseImp.get_CurrentSession() 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\DatabaseImp.cs:行号 54
在 NH.Test.test2.initData(String key, Int64 row) 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\test2.cs:行号 69
在 NH.Test.test2.Test1(Int32 i, Int32 j) 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\test2.cs:行号 139
在 NH.Test.test2.TestThead() 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\test2.cs:行号 113
在 NH.Test.test2.Main(String[] args) 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\test2.cs:行号 107
InnerException: System.MissingMethodException
Message=没有为该对象定义无参数的构造函数。
Source=mscorlib
StackTrace:
在 System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
在 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
在 System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
在 System.Activator.CreateInstance(Type type, Boolean nonPublic)
在 System.Activator.CreateInstance(Type type)
在 NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type)
在 NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary`2 properties)
InnerException:
Solve
Program
#region
configuration.Cache(c => //(Cache)
{
c.UseQueryCache = DefaultUseQueryCache;
c.UseMinimalPuts = true;
c.RegionsPrefix = "Cache";
c.DefaultExpiration = 60;//秒
if (DefaultUseSecondLevelCache)
{
c.Provider<HashtableCacheProvider>();//
// c.QueryCache<StandardQueryCache>();// is error
//is OK
configuration.SetProperty(Environment.UseSecondLevelCache, "true");
configuration.SetProperty(Environment.QueryCacheFactory, typeof(StandardQueryCacheFactory).FullName);
}
});
#endregion