2016-11-05 89 views
0

MS DTCを使用すると、NpgsqlException(0x80004005)が発生します。MS DTCを使用すると、NpgsqlException(0x80004005)が発生する

Npgsql.NpgsqlException(0x80004005が):いいえパスワードが提供されていないが、バックエンドは(MD5で)いずれかを必要と

ここではコードの一例です。

string strcon1 = "Server=localhost;Port=5432;User Id=postgres; Password=xxxxx; Database=db1;enlist=true;"; 
string strcon2 = "Server=localhost;Port=5432;User Id=postgres; Password=xxxxx; Database=db2;enlist=true;"; 

using (TransactionScope tx = new TransactionScope()) 
{ 
    using (NpgsqlConnection conn1 = new NpgsqlConnection(strcon1)) 
    { 
     string sql = "insert into test1(col1) values('A')"; 
     conn1.Open(); 
     using (NpgsqlCommand command = new NpgsqlCommand(sql, conn1)) 
     { 
      command.ExecuteNonQuery(); 
     } 
     using (NpgsqlConnection conn2 = new NpgsqlConnection(strcon2)) 
     { 
      conn2.Open(); 
      using (NpgsqlCommand command = new NpgsqlCommand(sql, conn2)) 
      { 
       command.ExecuteNonQuery(); 
      } 
     } 
    } 
    tx.Complete(); 
} // Error: tx.Dispose() 

Server stack trace: 
Npgsql.NpgsqlConnector.ProcessAuthenticationMessage(String username, AuthenticationRequestMessage msg) 
Npgsql.NpgsqlConnector.HandleAuthentication(String username, NpgsqlTimeout timeout) 
Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout) 
Npgsql.ConnectorPool.Allocate(NpgsqlConnection conn, NpgsqlTimeout timeout) 
Npgsql.NpgsqlConnection.OpenInternal() 
Npgsql.NpgsqlTransactionCallbacks.GetConnection() 
Npgsql.NpgsqlTransactionCallbacks.PrepareTransaction() 
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) 
System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg) 

Exception rethrown at [0]: 
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
Npgsql.INpgsqlTransactionCallbacks.PrepareTransaction() 
Npgsql.NpgsqlResourceManager.DurableResourceManager.Prepare(PreparingEnlistment preparingEnlistment) 
System.Transactions.Oletx.OletxEnlistment.PrepareRequest(Boolean singlePhase, Byte[] prepareInfo) 
System.Transactions.Oletx.OletxTransactionManager.ShimNotificationCallback(Object state, Boolean timeout) 
System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(Object state, Boolean timedOut)</StackTrace><ExceptionString>Npgsql.NpgsqlException (0x80004005): No password has been provided but the backend requires one (in MD5) 

Server stack trace: 
Npgsql.NpgsqlConnector.ProcessAuthenticationMessage(String username, AuthenticationRequestMessage msg) 
Npgsql.NpgsqlConnector.HandleAuthentication(String username, NpgsqlTimeout timeout) 
Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout) 
Npgsql.ConnectorPool.Allocate(NpgsqlConnection conn, NpgsqlTimeout timeout) 
Npgsql.NpgsqlConnection.OpenInternal() 
Npgsql.NpgsqlTransactionCallbacks.GetConnection() 
Npgsql.NpgsqlTransactionCallbacks.PrepareTransaction() 
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]&amp;amp; outArgs) 
System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg) 

Exception rethrown at [0]: 
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp;amp; msgData, Int32 type) 
Npgsql.INpgsqlTransactionCallbacks.PrepareTransaction() 
Npgsql.NpgsqlResourceManager.DurableResourceManager.Prepare(PreparingEnlistment preparingEnlistment) 
System.Transactions.Oletx.OletxEnlistment.PrepareRequest(Boolean singlePhase, Byte[] prepareInfo) 
System.Transactions.Oletx.OletxTransactionManager.ShimNotificationCallback(Object state, Boolean timeout) 
System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(Object state, Boolean timedOut) 

のWindows Server 2012 R2の標準、 のPostgreSQL 9.6、 Npgsqlの3.1.8

私はそれを解決できますか?

+0

で試してみてください。分散トランザクションサポートは問題があり、3.2リリースが役立つはずの領域の1つです。 –

+0

3.2 outとSystem.Transactionsのサポートが完全に書き直された場合、これをもう一度テストできますか? –

答えて

-1

解決策は、コードにconnectStringを上書きすることです。

-1

は、私は、これはNpgsqlの問題であることを確認することができます

Host=xxx.xxx.xxx.xx;Port=5432;Database=database;Username=postgres;Password=xxxxx;Integrated Security=false; 
関連する問題