當我使用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; 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; 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, 3.1.8 Npgsql的
我怎樣才能解決呢?
我可以證實這是一個問題Npgsql的。分佈式事務支持存在問題,並且是3.2版本應該提供幫助的領域之一。 –
隨着3.2出和System.Transactions支持完全重寫,任何機會,你可以再次測試這個? –