.NETGURU
0x8004d00e and Distributed Transaction Enlistment
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.component_services.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Michael Primeaux via .Net Guru (VIP)
I'm using the Microsoft .NET Framework 1.1 on Windows 2003 Server, Enterprise Edition and am seeing the following exception:

"System.Runtime.InteropServices.COMException (0x8004D00E): The transaction has already been implicitly or explicitly committed or aborted."

Here are a few data points:

[0] The target server is running Windows 2003 Server and SQL Server 2000 Enterprise Edition.

[1] The client machine is not in the same domain as the SQL Server. Therefore, I've performed the steps contained in this KB: http://support.microsoft.com/?id=827805

[2] My component does not inherit from ServicedComponent. I'm instead using the ServiceConfig class contained in System.EnterpriseServices.

Here is a small repro of the case. As soon as the I try to enlist in the distributed transaction (via EnlistDistributedTransaction) the exception is thrown. For obvious reasons, the exception isn't thrown when I'm accessing SQL on my local machine.

Please note, the connection string will have to be modified.

using System;
using System.Data;
using System.Data.SqlClient;
using System.EnterpriseServices;

namespace ConsoleApplication3
{
    class Class1
    {
        [STAThread]
        static void Main(string[] args)
        {
            ServiceConfig config = new ServiceConfig();
            config.Transaction = TransactionOption.Required;
            config.Synchronization = SynchronizationOption.Required;
            config.TransactionTimeout = 300;
            config.TrackingComponentName = "Test";
            config.TrackingAppName = "Distributed Transaction Test";
            config.TrackingEnabled = true;

            ServiceDomain.Enter(config);

            try
            {
                using(SqlCommand cmd = new SqlCommand("INSERT INTO HierarchyCategory VALUES(@id, @name)"))
                {
                    cmd.Parameters.Add("@id", SqlDbType.UniqueIdentifier);
                    cmd.Parameters["@id"].Value = Guid.Empty;

                    cmd.Parameters.Add("@name", SqlDbType.NVarChar);
                    cmd.Parameters["@name"].Value = "Test";

                    cmd.Connection = new SqlConnection("Enlist=False;Pooling=True;Trusted_Connection=False;User Id=someuser;Password=somepassword;Application Name=pubs;Initial Catalog=Storage_I4;Data Source=targetserver");
                    cmd.Connection.Open();

                    try
                    {
                        if(ContextUtil.IsInTransaction)
                        {
                            cmd.Connection.EnlistDistributedTransaction((ITransaction)ContextUtil.Transaction);
                        }

                        //
                        // Execute the command.
                        //
                        long recordsAffected = System.Convert.ToInt64(cmd.ExecuteNonQuery());
                    }
                    finally
                    {
                        //
                        // Close the connection if necessary.
                        //
                        if(cmd.Connection.State == ConnectionState.Open)
                        {
                            cmd.Connection.Close();
                        }                                
                    }
                }

                if(ContextUtil.IsInTransaction)
                {
                    ContextUtil.SetComplete();
                }

            }
            catch(Exception exception)
            {
                Console.WriteLine(exception.ToString());
                    
                if(ContextUtil.IsInTransaction)
                {
                    ContextUtil.SetAbort();
                }

            }
            finally
            {
                ServiceDomain.Leave();
            }
        }
    }
}

I've been able to find next to nothing on this subject and what I've found hasn't worked.

Thanks,
Michael

--------------------------------
From: Michael Primeaux

-----------------------
Posted by a user from .Net Guru (http://www.dot-net-guru.com/)

<Id>ANqO8IKomkmg2xmnbLJovA==</Id>
Reply to this message...
 
    
Florin Lazar [MSFT] (VIP)
Hi Michael,

Did you enable network transactions on the two machines involved?

Regards,
--
Florin Lazar - Microsoft - [ http://blogs.msdn.com/florinlazar ]
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.

"Michael Primeaux via .Net Guru" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> I'm using the Microsoft .NET Framework 1.1 on Windows 2003 Server,
Enterprise Edition and am seeing the following exception:
[Original message clipped]

http://support.microsoft.com/?id=827805
[Original message clipped]

thrown. For obvious reasons, the exception isn't thrown when I'm accessing
SQL on my local machine.
[Original message clipped]

Id=someuser;Password=somepassword;Application Name=pubs;Initial
Catalog=Storage_I4;Data Source=targetserver");
[Original message clipped]

ction);
[Original message clipped]

Reply to this message...
 
 
System.Console
System.Convert
System.Data.ConnectionState
System.Data.SqlClient.SqlCommand
System.Data.SqlClient.SqlConnection
System.Data.SqlDbType
System.EnterpriseServices.ContextUtil
System.EnterpriseServices.ITransaction
System.EnterpriseServices.ServiceConfig
System.EnterpriseServices.ServicedComponent
System.EnterpriseServices.ServiceDomain
System.EnterpriseServices.SynchronizationOption
System.EnterpriseServices.TransactionOption
System.Guid
System.Runtime.InteropServices.COMException




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification