Bug #90280 NullReferenceException thrown on TransactionScope dispose
Submitted: 2 Apr 2018 15:56 Modified: 13 Mar 16:57
Reporter: Daniel Valdez Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.9.11 OS:Any
Assigned to: Assigned Account CPU Architecture:Any

[2 Apr 2018 15:56] Daniel Valdez
Description:
Exception thrown on dispose of TransactionScope.

- There is already a bug (https://bugs.mysql.com/bug.php?id=59346) created and closed for this issue but the problem is appearing again. 

How to repeat:
1) Before running, lock tables t2 read

2) 
        private void btnTestTransactionScope_Click(object sender, EventArgs e)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                DoInsertTablet1();
                DoInsertTablet2(); //X
                scope.Complete();
            }            
        }

        //DoInsertTable2 is similar except for the table name
        private static void DoInsertTable1()
        {

            try
            {
                using (MySqlConnection conn = new MySqlConnection(GetTestDBConn()))
                using (MySqlCommand cmd = conn.CreateCommand())
                {
                    conn.Open();
                    cmd.CommandText = @"insert into t2 (Val) values (?value)";
                    cmd.CommandTimeout = 5;
                    cmd.Parameters.AddWithValue("?value", new Random().Next());
                    cmd.ExecuteNonQuery();
                }
            }
            catch (Exception)
            {
             //throw (my custom exception that will be processed in BL layer)
            }
        }
[13 Mar 16:57] Filipe Silva
Duplicated by Bug#107110.