0

Unity + Fluent NHibernate + NHibernate 3.3.1.4 を中程度の信頼環境で使用する

var session = sessionFactory.OpenSession();

このエラーを返します:

Attempt by method 'NHibernate.AdoNet.SqlClientSqlCommandSet..ctor()' to access method 'System.Data.SqlClient.SqlCommandSet..ctor()' failed.

   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at NHibernate.AdoNet.SqlClientSqlCommandSet..ctor()
   at NHibernate.AdoNet.SqlClientBatchingBatcher.CreateConfiguredBatch()
   at NHibernate.AdoNet.SqlClientBatchingBatcher..ctor(ConnectionManager connectionManager, IInterceptor interceptor)
   at NHibernate.AdoNet.SqlClientBatchingBatcherFactory.CreateBatcher(ConnectionManager connectionManager, IInterceptor interceptor)
   at NHibernate.AdoNet.ConnectionManager..ctor(ISessionImplementor session, IDbConnection suppliedConnection, ConnectionReleaseMode connectionReleaseMode, IInterceptor interceptor)
   at NHibernate.Impl.SessionImpl..ctor(IDbConnection connection, SessionFactoryImpl factory, Boolean autoclose, Int64 timestamp, IInterceptor interceptor, EntityMode entityMode, Boolean flushBeforeCompletionEnabled, Boolean autoCloseSessionEnabled, ConnectionReleaseMode connectionReleaseMode)
   at NHibernate.Impl.SessionFactoryImpl.OpenSession(IDbConnection connection, Boolean autoClose, Int64 timestamp, IInterceptor sessionLocalInterceptor)
   at NHibernate.Impl.SessionFactoryImpl.OpenSession(IInterceptor sessionLocalInterceptor)
   at NHibernate.Impl.SessionFactoryImpl.OpenSession()
   at BsCms.Bootstrapper.<>c__DisplayClass5.<BuildUnityContainer>b__2(IUnityContainer c)
   at Microsoft.Practices.Unity.InjectionFactory.<>c__DisplayClass2.<.ctor>b__0(IUnityContainer c, Type t, String s)
   at Microsoft.Practices.ObjectBuilder2.FactoryDelegateBuildPlanPolicy.BuildUp(IBuilderContext context)
   at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
   at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)

誰かが私を助けることができますか?

4

1 に答える 1

0

これは非常に簡単に解決できる問題です。バッチ処理を無効にする必要があります。プロパティadonet.batch_sizeをに設定することでそれを行うことができます0

/のhibernate.cfg.xmlまたは nhibernate 構成セクションで:App.configWeb.config

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <reflection-optimizer use="false"/>
  <session-factory>
    <!-- other properties -->
    <property name="adonet.batch_size">0</property>
  </session-factory>
</hibernate-configuration>

またはFluentNHibernateによる:

var db = MsSqlConfiguration.MsSql2008
    // other configurations
    .AdoNetBatchSize(0); 

return Fluently.Configure()
    // other configurations
    .Database(db)
    .BuildConfiguration();
于 2012-09-23T10:54:45.813 に答える