- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在将 MVC 3 与实体一起使用,现在我已经使用了 Controller 中的以下代码行
using (var scope = new TransactionScope())
{
_myRepository.DeleteFM1(id);
_myRepository.DeleteFM2(id, name);
scope.Complete();
}
在我的 DeleteFM2 方法中,该方法恰好是我在实体类中定义的方法,如下所示:
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();
}
}
}
我有一个单独的类,我将 Insert 方法定义为
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;
}
在上面的方法DeleteFM2中插入这行代码后
_repositoryHistory.Insert(name, message, "FM2", "Delete", dateTime);
我收到此错误,没有这一行,我的代码工作得很好,我在所有其他方法中也使用了这一行,即使我在那里使用了事务范围,但我似乎仍然不明白这里的问题。请帮忙。谢谢
底层提供程序在打开时失败。
System.Transactions.TransactionManagerCommunicationException:Communication with the underlying transaction manager has failed. --->System.Runtime.InteropServices.COMException: The MSDTC transactionmanager was unable to pull the transaction from the source transactionmanager due to communication problems. Possible causes are: a firewallis present and it doesn't have an exception for the MSDTC process, thetwo machines cannot find each other by their NetBIOS names, or thesupport for network transactions is not enabled for one of the twotransaction managers. (Exception from HRESULT: 0x8004D02B) atSystem.Transactions.Oletx.IDtcProxyShimFactory.ReceiveTransaction(UInt32propgationTokenSize, Byte[] propgationToken, IntPtr managedIdentifier,Guid& transactionIdentifier, OletxTransactionIsolationLevel&isolationLevel, ITransactionShim& transactionShim) atSystem.Transactions.TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(Byte[]propagationToken) --- End of inner exception stack trace --- atSystem.Transactions.TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(Byte[]propagationToken) atSystem.Transactions.TransactionStatePSPEOperation.PSPEPromote(InternalTransactiontx) atSystem.Transactions.TransactionStateDelegatedBase.EnterState(InternalTransactiontx) atSystem.Transactions.EnlistableStates.Promote(InternalTransaction tx)at System.Transactions.Transaction.Promote() atSystem.Transactions.TransactionInterop.ConvertToOletxTransaction(Transactiontransaction) atSystem.Transactions.TransactionInterop.GetExportCookie(Transactiontransaction, Byte[] whereabouts) atSystem.Data.SqlClient.SqlInternalConnection.GetTransactionCookie(Transactiontransaction, Byte[] whereAbouts) atSystem.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transactiontx) at System.Data.SqlClient.SqlInternalConnection.Enlist(Transactiontx) atSystem.Data.SqlClient.SqlInternalConnectionTds.Activate(Transactiontransaction) atSystem.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transactiontransaction) atSystem.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnectionowningObject) atSystem.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnectionowningConnection) atSystem.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnectionouterConnection, DbConnectionFactory connectionFactory) atSystem.Data.SqlClient.SqlConnection.Open() atSystem.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(BooleanopenCondition, DbConnection storeConnectionToOpen, DbConnectionoriginalConnection, String exceptionCode, String attemptedOperation,Boolean& closeStoreConnectionOnFailure)
我的防火墙设置
最佳答案
即使配置、防火墙和 netbios/dns 设置正确,我也遇到了此错误。我的设置中的两台服务器是彼此的克隆,因此每台服务器上的 MSDTC 具有相同的 CID 值,这使得它们无法互操作。
排除 MSDTC 故障时需要考虑以下一些其他事项 http://msdn.microsoft.com/en-us/library/aa561924.aspx确保为 MSDTC 分配唯一的 CID 值
下描述了我的情况The MSDTC feature of the Windows operating system requires unique CID values to ensure that MSDTC functionality between computers works correctly. Disk duplicate images of Windows installations must have unique CID values or MSDTC functionality may be impaired. This can occur when using virtual hard disks to deploy an operating system to a virtual machine.
To determine if MSDTC CID values for computers that are running the Windows operating system are unique, check the values for the entries under the HKEY_CLASSES_ROOT\CID registry key on both computers. If these values are not unique for each computer then follow the steps in the section Consider reinstalling the Distributed Transaction Coordinator service if other troubleshooting steps are not successful to reinstall MSDTC on one of the computers, which will then generate unique MSDTC CID values for that computer and accommodate proper MSDTC operations.
要在 Windows 2012 Server 上重置 CID,请使用以下 Powershell 脚本:
#View: CIDs (These must be different on all systems)
ls Microsoft.PowerShell.Core\Registry::HKEY_CLASSES_ROOT\CID | select Name
#reinstall MSDTC to regenerate CIDs.
msdtc -uninstall
sleep 5
msdtc -install
sleep 5
Set-Service msdtc -startuptype "auto"
#then reboot for changes to take effect
关于sql-server - MVC 3 : The MSDTC transaction manager was unable to pull the transaction from the source,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10346367/
我是一名优秀的程序员,十分优秀!