MVC 3:MSDTC事务管理器无法从源头上拉动成交 [英] MVC 3 : The MSDTC transaction manager was unable to pull the transaction from the source
问题描述
我使用MVC 3的实体,现在我已经用下面的一行codeS从我的控制器
I am using MVC 3 with Entities, now I have used the below line of codes from my controller
using (var scope = new TransactionScope())
{
_myRepository.DeleteFM1(id);
_myRepository.DeleteFM2(id, name);
scope.Complete();
}
和里面我的 DeleteFM2 这发生在实体类中定义我的方法方法如下:
and inside my DeleteFM2 method which happens to be my method defined in the Entity class is as follows :
public void DeleteFM2(int id, string name)
{
var data= _repositoryMD.Fetch().Where(mColl => mColl.Col1 == id);
if (data!= null)
{
//insert here is giving some error MSDTC error !
// here I prepare a message using the '**data**'
_repositoryHistory.Insert(name, message, "FM2", "Delete", dateTime);
_repositoryMD.Attach(data);
_repositoryMD.Delete(data);
_repositoryMD.SaveChanges();
}
}
}
和我有,我已经定义插入方法
and I have a seperate class where I have defined the Insert method as
public bool Insert(string realName, string logMessage, string tableName, string changeType, DateTime dateTime)
{
var history = new History
{
ModifiedBy = realName,
ChangeType = changeType,
DateModified = dateTime,
LogMessage = logMessage,
TableName = tableName
};
_repositoryHistory.Add(history);
_repositoryHistory.SaveChanges();
return true;
}
在插入此行code在上述方法后DeleteFM2
After inserting this line of code in the above method DeleteFM2
_repositoryHistory.Insert(name, message, "FM2", "Delete", dateTime);
我收到此错误,没有这条线我的code工作得很好,我用这条线在我所有的其他方法,也即使我有我用了交易范围,但我仍然不似乎明白了这里的问题。请帮忙。谢谢
I am getting this error, without this line my code works just fine, I have used this line in all of my other methods too even where I there I had used Transaction Scope, but I still dont seem to understand the problem here. Please help. Thanks
基础提供开放式失败。
System.Transactions.TransactionManagerCommunicationException:
与基础事务管理器通信失败。 --->
System.Runtime.InteropServices.COMException:该MSDTC事务
经理无法从源头交易拉动交易
经理由于通信问题。可能的原因有:防火墙
是present并且它不具有用于将MSDTC过程异常,则
两台计算机无法通过其NetBIOS名称找到对方,或者
对网络事务的支持不是为一个两个启用
事务管理器。 (从HRESULT异常:0x8004D02B)在
System.Transactions.Oletx.IDtcProxyShimFactory.ReceiveTransaction(UInt32的
propgationTokenSize,字节[] propgationToken,IntPtr的managedIdentifier,
GUID&安培; transactionIdentifier,OletxTransactionIsolationLevel&安培;
的IsolationLevel,ITransactionShim&安培; transactionShim)在
System.Transactions.TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(字节[]
propagationToken)---内部异常堆栈跟踪的结尾---在
System.Transactions.TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(字节[]
propagationToken)在
System.Transactions.TransactionStatePSPEOperation.PSPEPromote(InternalTransaction
TX)的
System.Transactions.TransactionStateDelegatedBase.EnterState(InternalTransaction
TX)的
System.Transactions.EnlistableStates.Promote(InternalTransaction TX)
在System.Transactions.Transaction.Promote()在
System.Transactions.TransactionInterop.ConvertToOletxTransaction(交易
交易)的
System.Transactions.TransactionInterop.GetExportCookie(交易
交易,字节[]下落)的
System.Data.SqlClient.SqlInternalConnection.GetTransactionCookie(交易
交易,字节[]下落)的
System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(交易
TX)在System.Data.SqlClient.SqlInternalConnection.Enlist(交易
TX)的
System.Data.SqlClient.SqlInternalConnectionTds.Activate(交易
交易)的
System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(交易
交易)的
System.Data.ProviderBase.DbConnectionPool.GetConnection(的DbConnection
owningObject)在
System.Data.ProviderBase.DbConnectionFactory.GetConnection(的DbConnection
owningConnection)在
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(的DbConnection
outerConnection,DbConnectionFactory connectionFactory的)在
System.Data.SqlClient.SqlConnection.Open()在
System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(布尔
openCondition,的DbConnection storeConnectionToOpen,的DbConnection
originalConnection,字符串例外code,字符串attemptedOperation,
布尔和放大器; closeStoreConnectionOnFailure)
System.Transactions.TransactionManagerCommunicationException: Communication with the underlying transaction manager has failed. ---> System.Runtime.InteropServices.COMException: The MSDTC transaction manager was unable to pull the transaction from the source transaction manager due to communication problems. Possible causes are: a firewall is present and it doesn't have an exception for the MSDTC process, the two machines cannot find each other by their NetBIOS names, or the support for network transactions is not enabled for one of the two transaction managers. (Exception from HRESULT: 0x8004D02B) at System.Transactions.Oletx.IDtcProxyShimFactory.ReceiveTransaction(UInt32 propgationTokenSize, Byte[] propgationToken, IntPtr managedIdentifier, Guid& transactionIdentifier, OletxTransactionIsolationLevel& isolationLevel, ITransactionShim& transactionShim) at System.Transactions.TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(Byte[] propagationToken) --- End of inner exception stack trace --- at System.Transactions.TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(Byte[] propagationToken) at System.Transactions.TransactionStatePSPEOperation.PSPEPromote(InternalTransaction tx) at System.Transactions.TransactionStateDelegatedBase.EnterState(InternalTransaction tx) at System.Transactions.EnlistableStates.Promote(InternalTransaction tx) at System.Transactions.Transaction.Promote() at System.Transactions.TransactionInterop.ConvertToOletxTransaction(Transaction transaction) at System.Transactions.TransactionInterop.GetExportCookie(Transaction transaction, Byte[] whereabouts) at System.Data.SqlClient.SqlInternalConnection.GetTransactionCookie(Transaction transaction, Byte[] whereAbouts) at System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx) at System.Data.SqlClient.SqlInternalConnection.Enlist(Transaction tx) at System.Data.SqlClient.SqlInternalConnectionTds.Activate(Transaction transaction) at System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction) at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
我的防火墙设置
推荐答案
该错误意味着MSDTC或者未在数据库服务器上运行,包含数据库,其中 _repositoryHistory
目标;或出现交易到该计算机网络问题preventing传播。
The error implies that MSDTC is either not running on the database server that contains the database which _repositoryHistory
targets; or that there is a network issue preventing propagation of the transaction to that machine.
检查MSDTC安装和数据库服务器上运行。
Check that MSDTC is installed and running on the database server.
检查Windows防火墙是否在目标服务器上运行;如果是,检查MSDTC防火墙例外。此链接有助于指出:的http:// TechNet联系。 microsoft.com/en-us/library/cc725913(v=ws.10).aspx
Check whether Windows Firewall is running on the target server; if it is, check the firewall exclusions for MSDTC. This link helps with that: http://technet.microsoft.com/en-us/library/cc725913(v=ws.10).aspx
这篇关于MVC 3:MSDTC事务管理器无法从源头上拉动成交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!