MSDTC.exe terminating unexpectedly everytime I run a simple code to do a distributed transaction

0

I am trying a very simple distributed transaction on Windows 10 PC, but MSDTC.exe keeps dying every time I run the code. I've configured everything for it from giving authorization to Network Service (User) to the folders that are related to MSDTC (dlls involved with it, app running the distributed transaction, etc.), and disabled firewalls. I have searched Google for 3 days and cannot find a cure. Could you please help? Thanks!

class Program
{
    static void Main(string[] args)
    {
        string connstr = "this str works for non-distributed transactions";
        PerformTransaction(connstr);
    }
    private static void PerformTransaction(string connstr)
    {
        bool first_tx_result = false;
        bool second_tx_result = false;
        try
        {
            using (TransactionScope ts = new TransactionScope())
            {
                using (OleDbConnection con = new OleDbConnection(connstr))
                {
                    con.Open();
                    using (OleDbCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.CommandText = string.Format("INSERT INTO T84073 ( NO, NAME, SAL) VALUES (3000, 'king', 1000)");
                        cmd.ExecuteNonQuery();
                        first_tx_result = cmd.ExecuteNonQuery() == 1;
                    }
                    // throw new Exception("Transaction not working out");

                    using (OleDbCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.CommandText = string.Format("INSERT INTO T84073 ( NO, NAME, SAL) VALUES (3000, 'ksdg', 1000)");
                        cmd.ExecuteNonQuery();
                        second_tx_result = cmd.ExecuteNonQuery() == 1;
                    }
                    if (first_tx_result && second_tx_result)
                    {
                        ts.Complete();
                    }
                }
            }
        }
        catch
        {
            //rolling back is taken care of by transaction scope
        }
    }
}

}

Error messages: -0x8004D01B: ("XACT_E_TMNOTAVAILABLE", "The transaction manager is not available."),

-0x8004D01D: ("XACT_E_CONNECTION_DENIED", "A request to establish a connection with the transaction manager was denied."),

-from the Event Viewer The XA Transaction Manager attempted to load the XA resource manager DLL. The call to LOADLIBRARY for the XA resource manager DLL failed: DLL=C:\Users\swx\Desktop\dll, HR=0x8007007e, File=com\complus\dtc\dtc\xatm\src\xarmconn.cpp Line=2503.

oledb
distributed
msdtc
xa
asked on Stack Overflow Jul 27, 2018 by Sung Woo Kim

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0