Click here to Skip to main content
16,020,568 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
my code always go to TransactionAbortedException when using TransactionScope
here they are :

C#
try
{
	TransactionOptions transOption = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted };

	using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, transOption))
	{
		response.AssetTransactionHistory = new FaAssetTransactionHistory();
		response.AssetTransactionHistory.Merge(request.AssetTransactionHistory);

		// Generate Asset Transaction History ID with GUID
		response.AssetTransactionHistory.HistoryId = Guid.NewGuid().ToString();

		// Call ValidateAssetTransactionHistoryForCreate. If false, add message to respose object and return the response.
		if (!ValidateAssetTransactionHistoryForCreate(request.AssetTransactionHistory, response.Messages)) return response;

		// Call Add method from repository.
		_assetTransactionHistoryRepository.Add(response.AssetTransactionHistory);
		_assetTransactionHistoryRepository.SaveChanges();

		ts.Complete();
	}
}
catch (TransactionAbortedException transactionAbortedException)
{
	// MFS0069: The transaction was aborted.
	Message errorMessage = MessageFactory.GetMessage("MFS0069", MessageType.Error);
	PopulateExtendedMessages(errorMessage.ExtendedValues, transactionAbortedException);

	response.Messages.Add(errorMessage);
}


anyone has suggestion for this?
Posted
Comments
Andy Lanng 27-Apr-15 4:43am    
Could you post the error and stack trace, please. It would be helpful to know where the exception occurs.

Thanks - AL

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900