MSDTC分散トランザクションエラー:このトランザクションは明示的または暗黙的に確認または終了しました
2290 ワード
処理方法:データベースサーバ(MS SQL)上のhostsファイルにWebサーバ(IIS)のIPとホスト名マッピングペア1を加える.C:WINDOWSsystem 32driversetcディレクトリ2にナビゲートします.メモ帳はhostsファイルを開きます(拡張子はありません).10.10.1.118 MyWebServerHostName 4のようなWebサーバのIPとホスト名のマッピングを追加します.OK!
TransactionScopeの例:
TransactionScopeの例:
/// <summary>
///
/// </summary>
/// <param name="sendUserId"></param>
/// <param name="toUser"> 7FFA3AF2-E74B-4174-8403-5010C53E49A7|userName,7FFA3AF2-E74B-4174-8403-5010C53E49A7|userName</param>
/// <param name="content"></param>
/// <param name="sendedStatus"> </param>
/// <returns></returns>
public static int sendMessage(string sendUserId, string toUser, string content, string sendedStatus)
{
int receiveCount = 0;
TransactionOptions transactionOption = new TransactionOptions();
//
transactionOption.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
// 60
transactionOption.Timeout = new TimeSpan(0, 0, 60);
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, transactionOption))
{
try
{
//
//
insertMessage(sendUserId, toUser, content, sendedStatus);
//
receiveCount += insertReceiveMessage(userids[0], sendUserId, content, "0");
// ,
scope.Complete();
}
catch (Exception ex) {
throw new Exception(" , :"+ex.Message);
}finally{
//
scope.Dispose();
}
}
return receiveCount;
}