エンティティでMVC 3を使用していますが、コントローラーから以下のコード行を使用しました
using (var scope = new TransactionScope())
{
_myRepository.DeleteFM1(id);
_myRepository.DeleteFM2(id, name);
scope.Complete();
}
Entityクラスで定義されたメソッドである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);
このエラーが発生しています。この行がないとコードは正常に動作します。トランザクション スコープを使用した場合でも、他のすべてのメソッドでこの行を使用しましたが、まだ問題を理解していないようです。助けてください。ありがとう
基になるプロバイダーが Open で失敗しました。
System.Transactions.TransactionManagerCommunicationException: 基になるトランザクション マネージャーとの通信に失敗しました。---> System.Runtime.InteropServices.COMException: 通信の問題により、MSDTC トランザクション マネージャーはソース トランザクション マネージャーからトランザクションを取得できませんでした。考えられる原因は次のとおりです。ファイアウォールが存在し、MSDTC プロセスの例外がない、2 台のマシンが NetBIOS 名で互いを検出できない、またはネットワーク トランザクションのサポートが 2 つのトランザクション マネージャーのいずれかで有効になっていない。(HRESULT からの例外: 0x8004D02B) System.Transactions.Oletx.IDtcProxyShimFactory.ReceiveTransaction (UInt32 propgationTokenSize、Byte[] propgationToken、IntPtr managedIdentifier、Guid& transactionIdentifier、OletxTransactionIsolationLevel& isolationLevel、
私のファイアウォール設定