Informix .NET Provider を使用して、NHibernate 挿入を TransactionScope オブジェクトの Informix データベースにラップしようとする小さなプログラムがあります。以下に示すエラーが表示されます。NHibernate セッション トランザクションで挿入がラップされている場合を含め、TransactionScope オブジェクトのないコードは機能します。問題が何であるかについてのアイデアはありますか?ところで、EnterpriseServicesInterop がないと、Informix .NET Provider は TransactionScope トランザクションに参加しません (NHibernate を使用せずに検証済み)。
コードスニペット:
public static void TestTScope()
{
Employee johnp = new Employee { name = "John Prideaux" };
using (TransactionScope tscope = new TransactionScope(
TransactionScopeOption.Required,
new TransactionOptions() { Timeout = new TimeSpan(0, 1, 0),
IsolationLevel = IsolationLevel.ReadCommitted },
EnterpriseServicesInteropOption.Full))
{
using (ISession session = OpenSession())
{
session.Save(johnp);
Console.WriteLine("Saved John to the database");
}
}
Console.WriteLine("Transaction should be rolled back");
}
static ISession OpenSession()
{
if (factory == null)
{
Configuration c = new Configuration();
c.AddAssembly(Assembly.GetCallingAssembly());
factory = c.BuildSessionFactory();
}
return factory.OpenSession();
}
static ISessionFactory factory;
スタックトレース:
NHibernate.ADOException は未処理でした Message="Could not close IBM.Data.Informix.IfxConnection connection" Source="NHibernate" StackTrace: at NHibernate.Connection.ConnectionProvider.CloseConnection(IDbConnection conn) at NHibernate.Connection.DriverConnectionProvider.CloseConnection(IDbConnection conn ) NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Release() で NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect ダイアレクト、IConnectionHelper connectionHelper) で NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory) で NHibernate.Impl.SessionFactoryImpl ..ctor (構成 cfg、IMapping マッピング、設定設定、EventListeners リスナー) NHibernate.Cfg.Configuration で。D:\Development\ScratchProject\HelloNHibernate\Employee.cs:line 73 の HelloNHibernate.Employee.OpenSession() の BuildSessionFactory() D:\Development\ScratchProject\HelloNHibernate\Employee.cs:line の HelloNHibernate.Employee.TestTScope() D:\Development\ScratchProject\HelloNHibernate\Program.cs: の HelloNHibernate.Program.Main(String[] args) で 53:System.AppDomain._nExecuteAssembly(アセンブリ アセンブリ、String[] args) で System.AppDomain.ExecuteAssembly で 19 行目(String assemblyFile, Evidence assemblySecurity, String[] args) System.Threading.ThreadHelper.ThreadStart_Context(オブジェクト状態) で Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() で System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback コールバック、Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: IBM.Data.Informix.IfxException Message="ERROR - no error information available" Source="IBM.Data.Informix" ErrorCode=-2147467259 StackTrace: IBM で。 IBM.Data.Informix.IfxConnection.DisposeClose() の Data.Informix.IfxConnection.HandleError(IntPtr hHandle, SQL_HANDLE hType, RETCODE retcode) IBM.Data.Informix.IfxConnection.Close() の NHibernate.Connection.ConnectionProvider.CloseConnection( IDbConnection conn) InnerException:ErrorCode=-2147467259 StackTrace: at IBM.Data.Informix.IfxConnection.HandleError(IntPtr hHandle, SQL_HANDLE hType, RETCODE retcode) at IBM.Data.Informix.IfxConnection.DisposeClose() at IBM.Data.Informix.IfxConnection.Close() NHibernate.Connection.ConnectionProvider.CloseConnection (IDbConnection conn) InnerException で:ErrorCode=-2147467259 StackTrace: at IBM.Data.Informix.IfxConnection.HandleError(IntPtr hHandle, SQL_HANDLE hType, RETCODE retcode) at IBM.Data.Informix.IfxConnection.DisposeClose() at IBM.Data.Informix.IfxConnection.Close() NHibernate.Connection.ConnectionProvider.CloseConnection (IDbConnection conn) InnerException で: