Bug #65510 TransactionScope doesn't work when running with mono runtime
Submitted: 4 Jun 2012 12:56 Modified: 1 Jul 2016 12:58
Reporter: Mika Aalto Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.5.4 OS:Linux
Assigned to: CPU Architecture:Any
Tags: 6.5.4.0, Connector/Net, Mono, TransactionScope

[4 Jun 2012 12:56] Mika Aalto
Description:
.NET connector throws an exception when application is run with Mono .NET runtime.

Stack trace from exception:
Unhandled Exception: System.NotImplementedException: The requested feature is not implemented.
  at MySql.Data.MySqlClient.MySqlConnection.EnlistTransaction (System.Transactions.Transaction transaction) [0x00000] in <filename unknown>:0
  at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000] in <filename unknown>:0
  at MySQLTransactionTest.Program.MySQLTest () [0x00000] in <filename unknown>:0

Is there a specific reason why IPromotableSinglePhaseNotification type is used instead of simple IEnlistmentNotification when mysql transaction is enlisted to transaction scope? This looks like a bug especially when MySqlPromotableTransaction class Promote method throws always NotSupportedException.

How to repeat:
Exception is easy to reproduce with just couple of lines:

using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.Required))
{
    MySqlConnection conn = new MySqlConnection("....");
    transactionConn.Open();
}

Suggested fix:
Use IEnlistmentNotification type of enlistment class instead of IPromotableSinglePhaseNotification.
[16 Aug 2012 22:29] Gabriela Martinez Sanchez
hi Mika, thank you for this bug report. Which version of mono are you using? I'm  trying to reproduce the bug (I tried the 2.10.8), and I found a documented workaround to avoid this exception if you compile
MySQL.Data from sources, you can define 'MONO' (-define:MONO) and this exception won't happen.

Have you tried it?
[20 Aug 2012 17:00] Mika Aalto
Hi Gabriela,

I'm using Mono version 2.10.8 like you are. If you define MONO compiler option when compiling MySQL connector library, MySqlConnection class won't enlist to ambient transaction scopes at all (see Connection.cs lines 520-523). This means your workaround unfortunately isn't a solution to this bug because it breaks .NET transaction scopes.
[1 Jul 2016 12:58] Chiranjeevi Battula
Hello Mika Aalto,

Thank you for your feedback.
I could not repeat the issue at our end using with Visual Studio 2013, Connector/NET 6.9.8.
If you can provide more information, feel free to add it to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

Thanks,
Chiranjeevi.