public void InDoubt(Exception e)
        {
            IEnlistmentShim enlistmentShim = null;

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxSinglePhaseEnlistment.InDoubt");
            }
            if (DiagnosticTrace.Warning)
            {
                EnlistmentCallbackNegativeTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentCallback.InDoubt);
            }
            lock (this)
            {
                if (!this.isSinglePhase || (OletxEnlistmentState.SinglePhaseCommitting != this.state))
                {
                    throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
                }
                this.state     = OletxEnlistmentState.InDoubt;
                enlistmentShim = this.EnlistmentShim;
            }
            lock (base.oletxTransaction.realOletxTransaction)
            {
                if (base.oletxTransaction.realOletxTransaction.innerException == null)
                {
                    base.oletxTransaction.realOletxTransaction.innerException = e;
                }
            }
            try
            {
                if (enlistmentShim != null)
                {
                    enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.InDoubt);
                }
            }
            catch (COMException exception)
            {
                if ((System.Transactions.Oletx.NativeMethods.XACT_E_CONNECTION_DOWN != exception.ErrorCode) && (System.Transactions.Oletx.NativeMethods.XACT_E_TMNOTAVAILABLE != exception.ErrorCode))
                {
                    throw;
                }
                if (DiagnosticTrace.Verbose)
                {
                    ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
                }
            }
            finally
            {
                this.FinishEnlistment();
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxSinglePhaseEnlistment.InDoubt");
            }
        }
        public void CommitRequest()
        {
            IEnlistmentShim enlistmentShim = null;
            IEnlistmentNotificationInternal iEnlistmentNotification = null;
            bool flag = false;

            lock (this)
            {
                if (OletxEnlistmentState.Prepared == this.state)
                {
                    this.state = OletxEnlistmentState.Committing;
                    iEnlistmentNotification = this.iEnlistmentNotification;
                }
                else
                {
                    enlistmentShim = this.EnlistmentShim;
                    flag           = true;
                }
            }
            if (iEnlistmentNotification != null)
            {
                if (DiagnosticTrace.Verbose)
                {
                    EnlistmentNotificationCallTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, NotificationCall.Commit);
                }
                iEnlistmentNotification.Commit(this);
            }
            else if (enlistmentShim != null)
            {
                try
                {
                    enlistmentShim.CommitRequestDone();
                }
                catch (COMException exception)
                {
                    if ((System.Transactions.Oletx.NativeMethods.XACT_E_CONNECTION_DOWN != exception.ErrorCode) && (System.Transactions.Oletx.NativeMethods.XACT_E_TMNOTAVAILABLE != exception.ErrorCode))
                    {
                        throw;
                    }
                    flag = true;
                    if (DiagnosticTrace.Verbose)
                    {
                        ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
                    }
                }
                finally
                {
                    if (flag)
                    {
                        this.FinishEnlistment();
                    }
                }
            }
        }
 internal OletxEnlistment(bool canDoSinglePhase, IEnlistmentNotificationInternal enlistmentNotification, Guid transactionGuid, EnlistmentOptions enlistmentOptions, OletxResourceManager oletxResourceManager, OletxTransaction oletxTransaction) : base(oletxResourceManager, oletxTransaction)
 {
     this.transactionGuid         = Guid.Empty;
     this.phase1Handle            = IntPtr.Zero;
     this.enlistmentShim          = null;
     this.phase0Shim              = null;
     this.canDoSinglePhase        = canDoSinglePhase;
     this.iEnlistmentNotification = enlistmentNotification;
     this.state                     = OletxEnlistmentState.Active;
     this.transactionGuid           = transactionGuid;
     this.proxyPrepareInfoByteArray = null;
     if (DiagnosticTrace.Information)
     {
         EnlistmentTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentType.Durable, enlistmentOptions);
     }
     base.AddToEnlistmentTable();
 }
 internal OletxEnlistment(bool canDoSinglePhase, IEnlistmentNotificationInternal enlistmentNotification, Guid transactionGuid, EnlistmentOptions enlistmentOptions, OletxResourceManager oletxResourceManager, OletxTransaction oletxTransaction) : base(oletxResourceManager, oletxTransaction)
 {
     this.transactionGuid = Guid.Empty;
     this.phase1Handle = IntPtr.Zero;
     this.enlistmentShim = null;
     this.phase0Shim = null;
     this.canDoSinglePhase = canDoSinglePhase;
     this.iEnlistmentNotification = enlistmentNotification;
     this.state = OletxEnlistmentState.Active;
     this.transactionGuid = transactionGuid;
     this.proxyPrepareInfoByteArray = null;
     if (DiagnosticTrace.Information)
     {
         EnlistmentTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentType.Durable, enlistmentOptions);
     }
     base.AddToEnlistmentTable();
 }
        public void Prepared()
        {
            int                   num1              = System.Transactions.Oletx.NativeMethods.S_OK;
            IEnlistmentShim       enlistmentShim    = null;
            IPhase0EnlistmentShim shim              = null;
            bool                  fabricateRollback = false;

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxPreparingEnlistment.Prepared");
                EnlistmentCallbackPositiveTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentCallback.Prepared);
            }
            lock (this)
            {
                if (OletxEnlistmentState.Preparing == this.state)
                {
                    enlistmentShim = this.EnlistmentShim;
                }
                else
                {
                    if (OletxEnlistmentState.Phase0Preparing != this.state)
                    {
                        throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
                    }
                    shim = this.Phase0EnlistmentShim;
                    if (base.oletxTransaction.realOletxTransaction.Doomed || this.fabricateRollback)
                    {
                        this.fabricateRollback = true;
                        fabricateRollback      = this.fabricateRollback;
                    }
                }
                this.state = OletxEnlistmentState.Prepared;
            }
            try
            {
                if (enlistmentShim != null)
                {
                    enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.Prepared);
                }
                else if (shim != null)
                {
                    base.oletxTransaction.realOletxTransaction.DecrementUndecidedEnlistments();
                    shim.Phase0Done(!fabricateRollback);
                }
                else
                {
                    fabricateRollback = true;
                }
                if (fabricateRollback)
                {
                    this.AbortRequest();
                }
            }
            catch (COMException exception)
            {
                if ((System.Transactions.Oletx.NativeMethods.XACT_E_CONNECTION_DOWN == exception.ErrorCode) || (System.Transactions.Oletx.NativeMethods.XACT_E_TMNOTAVAILABLE == exception.ErrorCode))
                {
                    if (DiagnosticTrace.Verbose)
                    {
                        ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
                    }
                }
                else
                {
                    if (System.Transactions.Oletx.NativeMethods.XACT_E_PROTOCOL != exception.ErrorCode)
                    {
                        throw;
                    }
                    this.Phase0EnlistmentShim = null;
                    if (DiagnosticTrace.Verbose)
                    {
                        ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
                    }
                }
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxPreparingEnlistment.Prepared");
            }
        }
        public bool PrepareRequest(bool singlePhase, byte[] prepareInfo)
        {
            IEnlistmentShim                 enlistmentShim          = null;
            OletxEnlistmentState            active                  = OletxEnlistmentState.Active;
            IEnlistmentNotificationInternal iEnlistmentNotification = null;
            OletxRecoveryInformation        thingToConvert          = null;

            lock (this)
            {
                if (this.state == OletxEnlistmentState.Active)
                {
                    active = this.state = OletxEnlistmentState.Preparing;
                }
                else
                {
                    active = this.state;
                }
                iEnlistmentNotification = this.iEnlistmentNotification;
                enlistmentShim          = this.EnlistmentShim;
                base.oletxTransaction.realOletxTransaction.TooLateForEnlistments = true;
            }
            if (OletxEnlistmentState.Preparing == active)
            {
                thingToConvert     = new OletxRecoveryInformation(prepareInfo);
                this.isSinglePhase = singlePhase;
                long length = prepareInfo.Length;
                this.proxyPrepareInfoByteArray = new byte[length];
                Array.Copy(prepareInfo, this.proxyPrepareInfoByteArray, length);
                if (this.isSinglePhase && this.canDoSinglePhase)
                {
                    ISinglePhaseNotificationInternal internal3 = (ISinglePhaseNotificationInternal)iEnlistmentNotification;
                    this.state = OletxEnlistmentState.SinglePhaseCommitting;
                    if (DiagnosticTrace.Verbose)
                    {
                        EnlistmentNotificationCallTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, NotificationCall.SinglePhaseCommit);
                    }
                    internal3.SinglePhaseCommit(this);
                    return(true);
                }
                byte[] resourceManagerRecoveryInformation = TransactionManager.ConvertToByteArray(thingToConvert);
                this.state = OletxEnlistmentState.Preparing;
                this.prepareInfoByteArray = TransactionManager.GetRecoveryInformation(base.oletxResourceManager.oletxTransactionManager.CreationNodeName, resourceManagerRecoveryInformation);
                if (DiagnosticTrace.Verbose)
                {
                    EnlistmentNotificationCallTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, NotificationCall.Prepare);
                }
                iEnlistmentNotification.Prepare(this);
                return(false);
            }
            if (OletxEnlistmentState.Prepared == active)
            {
                try
                {
                    enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.Prepared);
                    return(false);
                }
                catch (COMException exception3)
                {
                    OletxTransactionManager.ProxyException(exception3);
                    throw;
                }
            }
            if (OletxEnlistmentState.Done == active)
            {
                try
                {
                    bool flag;
                    try
                    {
                        enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.ReadOnly);
                        flag = true;
                    }
                    finally
                    {
                        this.FinishEnlistment();
                    }
                    return(flag);
                }
                catch (COMException exception2)
                {
                    OletxTransactionManager.ProxyException(exception2);
                    throw;
                }
            }
            try
            {
                enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.Failed);
            }
            catch (COMException exception)
            {
                if (DiagnosticTrace.Verbose)
                {
                    ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
                }
            }
            return(true);
        }
        public void ForceRollback(Exception e)
        {
            IPhase0EnlistmentShim shim           = null;
            IEnlistmentShim       enlistmentShim = null;

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxPreparingEnlistment.ForceRollback");
            }
            if (DiagnosticTrace.Warning)
            {
                EnlistmentCallbackNegativeTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentCallback.ForceRollback);
            }
            lock (this)
            {
                if (OletxEnlistmentState.Preparing == this.state)
                {
                    enlistmentShim = this.EnlistmentShim;
                }
                else
                {
                    if (OletxEnlistmentState.Phase0Preparing != this.state)
                    {
                        throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
                    }
                    shim = this.Phase0EnlistmentShim;
                    if (shim != null)
                    {
                        base.oletxTransaction.realOletxTransaction.DecrementUndecidedEnlistments();
                    }
                }
                this.state = OletxEnlistmentState.Aborted;
            }
            Interlocked.CompareExchange <Exception>(ref base.oletxTransaction.realOletxTransaction.innerException, e, null);
            try
            {
                if (enlistmentShim != null)
                {
                    try
                    {
                        enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.Failed);
                    }
                    finally
                    {
                        HandleTable.FreeHandle(this.phase1Handle);
                    }
                }
                if (shim != null)
                {
                    shim.Phase0Done(false);
                }
            }
            catch (COMException exception)
            {
                if ((System.Transactions.Oletx.NativeMethods.XACT_E_CONNECTION_DOWN != exception.ErrorCode) && (System.Transactions.Oletx.NativeMethods.XACT_E_TMNOTAVAILABLE != exception.ErrorCode))
                {
                    throw;
                }
                if (DiagnosticTrace.Verbose)
                {
                    ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
                }
            }
            finally
            {
                this.FinishEnlistment();
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxPreparingEnlistment.ForceRollback");
            }
        }
        internal OletxEnlistment(IEnlistmentNotificationInternal enlistmentNotification, OletxTransactionStatus xactStatus, byte[] prepareInfoByteArray, OletxResourceManager oletxResourceManager) : base(oletxResourceManager, null)
        {
            this.transactionGuid = Guid.Empty;
            this.phase1Handle = IntPtr.Zero;
            this.enlistmentShim = null;
            this.phase0Shim = null;
            this.canDoSinglePhase = false;
            this.iEnlistmentNotification = enlistmentNotification;
            this.state = OletxEnlistmentState.Active;
            int length = prepareInfoByteArray.Length;
            this.proxyPrepareInfoByteArray = new byte[length];
            Array.Copy(prepareInfoByteArray, this.proxyPrepareInfoByteArray, length);
            byte[] destinationArray = new byte[0x10];
            Array.Copy(this.proxyPrepareInfoByteArray, destinationArray, 0x10);
            this.transactionGuid = new Guid(destinationArray);
            base.transactionGuidString = this.transactionGuid.ToString();
            switch (xactStatus)
            {
                case OletxTransactionStatus.OLETX_TRANSACTION_STATUS_PREPARED:
                    this.state = OletxEnlistmentState.Prepared;
                    lock (oletxResourceManager.reenlistList)
                    {
                        oletxResourceManager.reenlistList.Add(this);
                        oletxResourceManager.StartReenlistThread();
                        goto Label_01CD;
                    }
                    break;

                case OletxTransactionStatus.OLETX_TRANSACTION_STATUS_ABORTED:
                    this.state = OletxEnlistmentState.Aborting;
                    if (DiagnosticTrace.Verbose)
                    {
                        EnlistmentNotificationCallTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, NotificationCall.Rollback);
                    }
                    this.iEnlistmentNotification.Rollback(this);
                    goto Label_01CD;

                case OletxTransactionStatus.OLETX_TRANSACTION_STATUS_COMMITTED:
                    this.state = OletxEnlistmentState.Committing;
                    lock (oletxResourceManager.reenlistList)
                    {
                        oletxResourceManager.reenlistPendingList.Add(this);
                    }
                    if (DiagnosticTrace.Verbose)
                    {
                        EnlistmentNotificationCallTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, NotificationCall.Commit);
                    }
                    this.iEnlistmentNotification.Commit(this);
                    goto Label_01CD;
            }
            if (DiagnosticTrace.Critical)
            {
                InternalErrorTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), System.Transactions.SR.GetString("OletxEnlistmentUnexpectedTransactionStatus"));
            }
            throw TransactionException.Create(System.Transactions.SR.GetString("TraceSourceOletx"), System.Transactions.SR.GetString("OletxEnlistmentUnexpectedTransactionStatus"), null);
        Label_01CD:
            if (DiagnosticTrace.Information)
            {
                EnlistmentTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentType.Durable, EnlistmentOptions.None);
            }
            base.AddToEnlistmentTable();
        }
        internal OletxEnlistment(IEnlistmentNotificationInternal enlistmentNotification, OletxTransactionStatus xactStatus, byte[] prepareInfoByteArray, OletxResourceManager oletxResourceManager) : base(oletxResourceManager, null)
        {
            this.transactionGuid         = Guid.Empty;
            this.phase1Handle            = IntPtr.Zero;
            this.enlistmentShim          = null;
            this.phase0Shim              = null;
            this.canDoSinglePhase        = false;
            this.iEnlistmentNotification = enlistmentNotification;
            this.state = OletxEnlistmentState.Active;
            int length = prepareInfoByteArray.Length;

            this.proxyPrepareInfoByteArray = new byte[length];
            Array.Copy(prepareInfoByteArray, this.proxyPrepareInfoByteArray, length);
            byte[] destinationArray = new byte[0x10];
            Array.Copy(this.proxyPrepareInfoByteArray, destinationArray, 0x10);
            this.transactionGuid       = new Guid(destinationArray);
            base.transactionGuidString = this.transactionGuid.ToString();
            switch (xactStatus)
            {
            case OletxTransactionStatus.OLETX_TRANSACTION_STATUS_PREPARED:
                this.state = OletxEnlistmentState.Prepared;
                lock (oletxResourceManager.reenlistList)
                {
                    oletxResourceManager.reenlistList.Add(this);
                    oletxResourceManager.StartReenlistThread();
                    goto Label_01CD;
                }
                break;

            case OletxTransactionStatus.OLETX_TRANSACTION_STATUS_ABORTED:
                this.state = OletxEnlistmentState.Aborting;
                if (DiagnosticTrace.Verbose)
                {
                    EnlistmentNotificationCallTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, NotificationCall.Rollback);
                }
                this.iEnlistmentNotification.Rollback(this);
                goto Label_01CD;

            case OletxTransactionStatus.OLETX_TRANSACTION_STATUS_COMMITTED:
                this.state = OletxEnlistmentState.Committing;
                lock (oletxResourceManager.reenlistList)
                {
                    oletxResourceManager.reenlistPendingList.Add(this);
                }
                if (DiagnosticTrace.Verbose)
                {
                    EnlistmentNotificationCallTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, NotificationCall.Commit);
                }
                this.iEnlistmentNotification.Commit(this);
                goto Label_01CD;
            }
            if (DiagnosticTrace.Critical)
            {
                InternalErrorTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), System.Transactions.SR.GetString("OletxEnlistmentUnexpectedTransactionStatus"));
            }
            throw TransactionException.Create(System.Transactions.SR.GetString("TraceSourceOletx"), System.Transactions.SR.GetString("OletxEnlistmentUnexpectedTransactionStatus"), null);
Label_01CD:
            if (DiagnosticTrace.Information)
            {
                EnlistmentTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentType.Durable, EnlistmentOptions.None);
            }
            base.AddToEnlistmentTable();
        }
        public void EnlistmentDone()
        {
            bool flag;

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxEnlistment.EnlistmentDone");
                EnlistmentCallbackPositiveTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentCallback.Done);
            }
            IEnlistmentShim       enlistmentShim = null;
            IPhase0EnlistmentShim shim2          = null;
            OletxEnlistmentState  active         = OletxEnlistmentState.Active;
            bool fabricateRollback = false;

            lock (this)
            {
                active = this.state;
                if (this.state == OletxEnlistmentState.Active)
                {
                    shim2 = this.Phase0EnlistmentShim;
                    if (shim2 != null)
                    {
                        base.oletxTransaction.realOletxTransaction.DecrementUndecidedEnlistments();
                    }
                    flag = false;
                }
                else if (OletxEnlistmentState.Preparing == this.state)
                {
                    enlistmentShim = this.EnlistmentShim;
                    flag           = true;
                }
                else if (OletxEnlistmentState.Phase0Preparing == this.state)
                {
                    shim2 = this.Phase0EnlistmentShim;
                    base.oletxTransaction.realOletxTransaction.DecrementUndecidedEnlistments();
                    if (this.fabricateRollback)
                    {
                        flag = true;
                    }
                    else
                    {
                        flag = false;
                    }
                }
                else
                {
                    if (((OletxEnlistmentState.Committing != this.state) && (OletxEnlistmentState.Aborting != this.state)) && (OletxEnlistmentState.SinglePhaseCommitting != this.state))
                    {
                        throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
                    }
                    enlistmentShim = this.EnlistmentShim;
                    flag           = true;
                }
                fabricateRollback = this.fabricateRollback;
                this.state        = OletxEnlistmentState.Done;
            }
            try
            {
                if (enlistmentShim != null)
                {
                    if (OletxEnlistmentState.Preparing == active)
                    {
                        try
                        {
                            enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.ReadOnly);
                            goto Label_01C1;
                        }
                        finally
                        {
                            HandleTable.FreeHandle(this.phase1Handle);
                        }
                    }
                    if (OletxEnlistmentState.Committing != active)
                    {
                        if (OletxEnlistmentState.Aborting != active)
                        {
                            if (OletxEnlistmentState.SinglePhaseCommitting != active)
                            {
                                throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
                            }
                            enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.SinglePhase);
                        }
                        else if (!fabricateRollback)
                        {
                            enlistmentShim.AbortRequestDone();
                        }
                    }
                    else
                    {
                        enlistmentShim.CommitRequestDone();
                    }
                }
                else if (shim2 != null)
                {
                    if (active != OletxEnlistmentState.Active)
                    {
                        if (OletxEnlistmentState.Phase0Preparing != active)
                        {
                            throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
                        }
                        shim2.Phase0Done(true);
                    }
                    else
                    {
                        shim2.Unenlist();
                    }
                }
            }
            catch (COMException exception)
            {
                flag = true;
                if (DiagnosticTrace.Verbose)
                {
                    ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
                }
            }
            finally
            {
                if (flag)
                {
                    this.FinishEnlistment();
                }
            }
Label_01C1:
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxEnlistment.EnlistmentDone");
            }
        }
Beispiel #11
0
        internal OletxEnlistment(
            IEnlistmentNotificationInternal enlistmentNotification,
            OletxTransactionStatus xactStatus,
            byte[] prepareInfoByteArray,
            OletxResourceManager oletxResourceManager
            ) : base( oletxResourceManager, null )
        {
            Guid myGuid = Guid.Empty;

            // This will get set later by the creator of this object after it
            // has enlisted with the proxy.
            this.enlistmentShim = null;
            this.phase0Shim = null;

            this.canDoSinglePhase = false;
            this.iEnlistmentNotification = enlistmentNotification;
            this.state = OletxEnlistmentState.Active;

            // Do this before we do any tracing because it will affect the trace identifiers that we generate.
            Debug.Assert( ( null != prepareInfoByteArray ),  
                "OletxEnlistment.ctor - null oletxTransaction without a prepareInfoByteArray" );

            int prepareInfoLength = prepareInfoByteArray.Length;
            this.proxyPrepareInfoByteArray = new byte[prepareInfoLength];
            Array.Copy(prepareInfoByteArray, proxyPrepareInfoByteArray, prepareInfoLength);

            byte[] txGuidByteArray = new byte[16];
            Array.Copy(proxyPrepareInfoByteArray, txGuidByteArray, 16);

            this.transactionGuid = new Guid( txGuidByteArray );
            this.transactionGuidString = this.transactionGuid.ToString();
            
            // If this is being created as part of a Reenlist and we already know the
            // outcome, then tell the application.
            switch (xactStatus)
            {
                case OletxTransactionStatus.OLETX_TRANSACTION_STATUS_ABORTED:
                {
                    this.state = OletxEnlistmentState.Aborting;
                    if ( DiagnosticTrace.Verbose )
                    {
                        EnlistmentNotificationCallTraceRecord.Trace( SR.GetString( SR.TraceSourceOletx ),
                            this.InternalTraceIdentifier,
                            NotificationCall.Rollback
                            );
                    }

                    iEnlistmentNotification.Rollback( this );
                    break;
                }

                case OletxTransactionStatus.OLETX_TRANSACTION_STATUS_COMMITTED:
                {
                    this.state = OletxEnlistmentState.Committing;
                    // We are going to send the notification to the RM.  We need to put the
                    // enlistment on the reenlistPendingList.  We lock the reenlistList because
                    // we have decided that is the lock that protects both lists.  The entry will
                    // be taken off the reenlistPendingList when the enlistment has
                    // EnlistmentDone called on it.  The enlistment will call
                    // RemoveFromReenlistPending.
                    lock ( oletxResourceManager.reenlistList )
                    {
                        oletxResourceManager.reenlistPendingList.Add( this );
                    }

                    if ( DiagnosticTrace.Verbose )
                    {
                        EnlistmentNotificationCallTraceRecord.Trace( SR.GetString( SR.TraceSourceOletx ),
                            this.InternalTraceIdentifier,
                            NotificationCall.Commit
                            );
                    }

                    iEnlistmentNotification.Commit( this );
                    break;
                }

                case OletxTransactionStatus.OLETX_TRANSACTION_STATUS_PREPARED:
                {
                    this.state = OletxEnlistmentState.Prepared;
                    lock ( oletxResourceManager.reenlistList )
                    {
                        oletxResourceManager.reenlistList.Add( this );
                        oletxResourceManager.StartReenlistThread();
                    }
                    break;
                }

                default:
                {
                    if ( DiagnosticTrace.Critical )
                    {
                        InternalErrorTraceRecord.Trace( SR.GetString( SR.TraceSourceOletx ),
                            SR.GetString( SR.OletxEnlistmentUnexpectedTransactionStatus )
                            );
                    }

                    throw TransactionException.Create( SR.GetString( SR.TraceSourceOletx ), SR.GetString( SR.OletxEnlistmentUnexpectedTransactionStatus ), null );
                }
            }

            if ( DiagnosticTrace.Information )
            {
                EnlistmentTraceRecord.Trace( SR.GetString( SR.TraceSourceOletx ),
                    this.InternalTraceIdentifier,
                    EnlistmentType.Durable,
                    EnlistmentOptions.None
                    );
            }

            // Always do this last in case anything prior to this fails.
            AddToEnlistmentTable();
        }
 public void CommitRequest()
 {
     IEnlistmentShim enlistmentShim = null;
     IEnlistmentNotificationInternal iEnlistmentNotification = null;
     bool flag = false;
     lock (this)
     {
         if (OletxEnlistmentState.Prepared == this.state)
         {
             this.state = OletxEnlistmentState.Committing;
             iEnlistmentNotification = this.iEnlistmentNotification;
         }
         else
         {
             enlistmentShim = this.EnlistmentShim;
             flag = true;
         }
     }
     if (iEnlistmentNotification != null)
     {
         if (DiagnosticTrace.Verbose)
         {
             EnlistmentNotificationCallTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, NotificationCall.Commit);
         }
         iEnlistmentNotification.Commit(this);
     }
     else if (enlistmentShim != null)
     {
         try
         {
             enlistmentShim.CommitRequestDone();
         }
         catch (COMException exception)
         {
             if ((System.Transactions.Oletx.NativeMethods.XACT_E_CONNECTION_DOWN != exception.ErrorCode) && (System.Transactions.Oletx.NativeMethods.XACT_E_TMNOTAVAILABLE != exception.ErrorCode))
             {
                 throw;
             }
             flag = true;
             if (DiagnosticTrace.Verbose)
             {
                 ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
             }
         }
         finally
         {
             if (flag)
             {
                 this.FinishEnlistment();
             }
         }
     }
 }
 public bool PrepareRequest(bool singlePhase, byte[] prepareInfo)
 {
     IEnlistmentShim enlistmentShim = null;
     OletxEnlistmentState active = OletxEnlistmentState.Active;
     IEnlistmentNotificationInternal iEnlistmentNotification = null;
     OletxRecoveryInformation thingToConvert = null;
     lock (this)
     {
         if (this.state == OletxEnlistmentState.Active)
         {
             active = this.state = OletxEnlistmentState.Preparing;
         }
         else
         {
             active = this.state;
         }
         iEnlistmentNotification = this.iEnlistmentNotification;
         enlistmentShim = this.EnlistmentShim;
         base.oletxTransaction.realOletxTransaction.TooLateForEnlistments = true;
     }
     if (OletxEnlistmentState.Preparing == active)
     {
         thingToConvert = new OletxRecoveryInformation(prepareInfo);
         this.isSinglePhase = singlePhase;
         long length = prepareInfo.Length;
         this.proxyPrepareInfoByteArray = new byte[length];
         Array.Copy(prepareInfo, this.proxyPrepareInfoByteArray, length);
         if (this.isSinglePhase && this.canDoSinglePhase)
         {
             ISinglePhaseNotificationInternal internal3 = (ISinglePhaseNotificationInternal) iEnlistmentNotification;
             this.state = OletxEnlistmentState.SinglePhaseCommitting;
             if (DiagnosticTrace.Verbose)
             {
                 EnlistmentNotificationCallTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, NotificationCall.SinglePhaseCommit);
             }
             internal3.SinglePhaseCommit(this);
             return true;
         }
         byte[] resourceManagerRecoveryInformation = TransactionManager.ConvertToByteArray(thingToConvert);
         this.state = OletxEnlistmentState.Preparing;
         this.prepareInfoByteArray = TransactionManager.GetRecoveryInformation(base.oletxResourceManager.oletxTransactionManager.CreationNodeName, resourceManagerRecoveryInformation);
         if (DiagnosticTrace.Verbose)
         {
             EnlistmentNotificationCallTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, NotificationCall.Prepare);
         }
         iEnlistmentNotification.Prepare(this);
         return false;
     }
     if (OletxEnlistmentState.Prepared == active)
     {
         try
         {
             enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.Prepared);
             return false;
         }
         catch (COMException exception3)
         {
             OletxTransactionManager.ProxyException(exception3);
             throw;
         }
     }
     if (OletxEnlistmentState.Done == active)
     {
         try
         {
             bool flag;
             try
             {
                 enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.ReadOnly);
                 flag = true;
             }
             finally
             {
                 this.FinishEnlistment();
             }
             return flag;
         }
         catch (COMException exception2)
         {
             OletxTransactionManager.ProxyException(exception2);
             throw;
         }
     }
     try
     {
         enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.Failed);
     }
     catch (COMException exception)
     {
         if (DiagnosticTrace.Verbose)
         {
             ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
         }
     }
     return true;
 }
 public void Prepared()
 {
     int num1 = System.Transactions.Oletx.NativeMethods.S_OK;
     IEnlistmentShim enlistmentShim = null;
     IPhase0EnlistmentShim shim = null;
     bool fabricateRollback = false;
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxPreparingEnlistment.Prepared");
         EnlistmentCallbackPositiveTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentCallback.Prepared);
     }
     lock (this)
     {
         if (OletxEnlistmentState.Preparing == this.state)
         {
             enlistmentShim = this.EnlistmentShim;
         }
         else
         {
             if (OletxEnlistmentState.Phase0Preparing != this.state)
             {
                 throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
             }
             shim = this.Phase0EnlistmentShim;
             if (base.oletxTransaction.realOletxTransaction.Doomed || this.fabricateRollback)
             {
                 this.fabricateRollback = true;
                 fabricateRollback = this.fabricateRollback;
             }
         }
         this.state = OletxEnlistmentState.Prepared;
     }
     try
     {
         if (enlistmentShim != null)
         {
             enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.Prepared);
         }
         else if (shim != null)
         {
             base.oletxTransaction.realOletxTransaction.DecrementUndecidedEnlistments();
             shim.Phase0Done(!fabricateRollback);
         }
         else
         {
             fabricateRollback = true;
         }
         if (fabricateRollback)
         {
             this.AbortRequest();
         }
     }
     catch (COMException exception)
     {
         if ((System.Transactions.Oletx.NativeMethods.XACT_E_CONNECTION_DOWN == exception.ErrorCode) || (System.Transactions.Oletx.NativeMethods.XACT_E_TMNOTAVAILABLE == exception.ErrorCode))
         {
             if (DiagnosticTrace.Verbose)
             {
                 ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
             }
         }
         else
         {
             if (System.Transactions.Oletx.NativeMethods.XACT_E_PROTOCOL != exception.ErrorCode)
             {
                 throw;
             }
             this.Phase0EnlistmentShim = null;
             if (DiagnosticTrace.Verbose)
             {
                 ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
             }
         }
     }
     if (DiagnosticTrace.Verbose)
     {
         MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxPreparingEnlistment.Prepared");
     }
 }
 public void InDoubt(Exception e)
 {
     IEnlistmentShim enlistmentShim = null;
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxSinglePhaseEnlistment.InDoubt");
     }
     if (DiagnosticTrace.Warning)
     {
         EnlistmentCallbackNegativeTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentCallback.InDoubt);
     }
     lock (this)
     {
         if (!this.isSinglePhase || (OletxEnlistmentState.SinglePhaseCommitting != this.state))
         {
             throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
         }
         this.state = OletxEnlistmentState.InDoubt;
         enlistmentShim = this.EnlistmentShim;
     }
     lock (base.oletxTransaction.realOletxTransaction)
     {
         if (base.oletxTransaction.realOletxTransaction.innerException == null)
         {
             base.oletxTransaction.realOletxTransaction.innerException = e;
         }
     }
     try
     {
         if (enlistmentShim != null)
         {
             enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.InDoubt);
         }
     }
     catch (COMException exception)
     {
         if ((System.Transactions.Oletx.NativeMethods.XACT_E_CONNECTION_DOWN != exception.ErrorCode) && (System.Transactions.Oletx.NativeMethods.XACT_E_TMNOTAVAILABLE != exception.ErrorCode))
         {
             throw;
         }
         if (DiagnosticTrace.Verbose)
         {
             ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
         }
     }
     finally
     {
         this.FinishEnlistment();
     }
     if (DiagnosticTrace.Verbose)
     {
         MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxSinglePhaseEnlistment.InDoubt");
     }
 }
 public void ForceRollback(Exception e)
 {
     IPhase0EnlistmentShim shim = null;
     IEnlistmentShim enlistmentShim = null;
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxPreparingEnlistment.ForceRollback");
     }
     if (DiagnosticTrace.Warning)
     {
         EnlistmentCallbackNegativeTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentCallback.ForceRollback);
     }
     lock (this)
     {
         if (OletxEnlistmentState.Preparing == this.state)
         {
             enlistmentShim = this.EnlistmentShim;
         }
         else
         {
             if (OletxEnlistmentState.Phase0Preparing != this.state)
             {
                 throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
             }
             shim = this.Phase0EnlistmentShim;
             if (shim != null)
             {
                 base.oletxTransaction.realOletxTransaction.DecrementUndecidedEnlistments();
             }
         }
         this.state = OletxEnlistmentState.Aborted;
     }
     Interlocked.CompareExchange<Exception>(ref base.oletxTransaction.realOletxTransaction.innerException, e, null);
     try
     {
         if (enlistmentShim != null)
         {
             try
             {
                 enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.Failed);
             }
             finally
             {
                 HandleTable.FreeHandle(this.phase1Handle);
             }
         }
         if (shim != null)
         {
             shim.Phase0Done(false);
         }
     }
     catch (COMException exception)
     {
         if ((System.Transactions.Oletx.NativeMethods.XACT_E_CONNECTION_DOWN != exception.ErrorCode) && (System.Transactions.Oletx.NativeMethods.XACT_E_TMNOTAVAILABLE != exception.ErrorCode))
         {
             throw;
         }
         if (DiagnosticTrace.Verbose)
         {
             ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
         }
     }
     finally
     {
         this.FinishEnlistment();
     }
     if (DiagnosticTrace.Verbose)
     {
         MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxPreparingEnlistment.ForceRollback");
     }
 }
 public void EnlistmentDone()
 {
     bool flag;
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxEnlistment.EnlistmentDone");
         EnlistmentCallbackPositiveTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentCallback.Done);
     }
     IEnlistmentShim enlistmentShim = null;
     IPhase0EnlistmentShim shim2 = null;
     OletxEnlistmentState active = OletxEnlistmentState.Active;
     bool fabricateRollback = false;
     lock (this)
     {
         active = this.state;
         if (this.state == OletxEnlistmentState.Active)
         {
             shim2 = this.Phase0EnlistmentShim;
             if (shim2 != null)
             {
                 base.oletxTransaction.realOletxTransaction.DecrementUndecidedEnlistments();
             }
             flag = false;
         }
         else if (OletxEnlistmentState.Preparing == this.state)
         {
             enlistmentShim = this.EnlistmentShim;
             flag = true;
         }
         else if (OletxEnlistmentState.Phase0Preparing == this.state)
         {
             shim2 = this.Phase0EnlistmentShim;
             base.oletxTransaction.realOletxTransaction.DecrementUndecidedEnlistments();
             if (this.fabricateRollback)
             {
                 flag = true;
             }
             else
             {
                 flag = false;
             }
         }
         else
         {
             if (((OletxEnlistmentState.Committing != this.state) && (OletxEnlistmentState.Aborting != this.state)) && (OletxEnlistmentState.SinglePhaseCommitting != this.state))
             {
                 throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
             }
             enlistmentShim = this.EnlistmentShim;
             flag = true;
         }
         fabricateRollback = this.fabricateRollback;
         this.state = OletxEnlistmentState.Done;
     }
     try
     {
         if (enlistmentShim != null)
         {
             if (OletxEnlistmentState.Preparing == active)
             {
                 try
                 {
                     enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.ReadOnly);
                     goto Label_01C1;
                 }
                 finally
                 {
                     HandleTable.FreeHandle(this.phase1Handle);
                 }
             }
             if (OletxEnlistmentState.Committing != active)
             {
                 if (OletxEnlistmentState.Aborting != active)
                 {
                     if (OletxEnlistmentState.SinglePhaseCommitting != active)
                     {
                         throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
                     }
                     enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.SinglePhase);
                 }
                 else if (!fabricateRollback)
                 {
                     enlistmentShim.AbortRequestDone();
                 }
             }
             else
             {
                 enlistmentShim.CommitRequestDone();
             }
         }
         else if (shim2 != null)
         {
             if (active != OletxEnlistmentState.Active)
             {
                 if (OletxEnlistmentState.Phase0Preparing != active)
                 {
                     throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
                 }
                 shim2.Phase0Done(true);
             }
             else
             {
                 shim2.Unenlist();
             }
         }
     }
     catch (COMException exception)
     {
         flag = true;
         if (DiagnosticTrace.Verbose)
         {
             ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
         }
     }
     finally
     {
         if (flag)
         {
             this.FinishEnlistment();
         }
     }
 Label_01C1:
     if (DiagnosticTrace.Verbose)
     {
         MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxEnlistment.EnlistmentDone");
     }
 }
Beispiel #18
0
        internal OletxEnlistment(
            bool canDoSinglePhase,
            IEnlistmentNotificationInternal enlistmentNotification,
            Guid transactionGuid,
            EnlistmentOptions enlistmentOptions,
            OletxResourceManager oletxResourceManager,
            OletxTransaction oletxTransaction
            ) : base( oletxResourceManager, oletxTransaction )
        {
            Guid myGuid = Guid.Empty;

            // This will get set later by the creator of this object after it
            // has enlisted with the proxy.
            this.enlistmentShim = null;
            this.phase0Shim = null;

            this.canDoSinglePhase = canDoSinglePhase;
            this.iEnlistmentNotification = enlistmentNotification;
            this.state = OletxEnlistmentState.Active;
            this.transactionGuid = transactionGuid;

            this.proxyPrepareInfoByteArray = null;

            if ( DiagnosticTrace.Information )
            {
                EnlistmentTraceRecord.Trace( SR.GetString( SR.TraceSourceOletx ),
                    this.InternalTraceIdentifier,
                    EnlistmentType.Durable,
                    enlistmentOptions
                    );
            }

            // Always do this last incase anything earlier fails.
            AddToEnlistmentTable();
        }
Beispiel #19
0
        internal OletxEnlistment EnlistDurable(OletxTransaction oletxTransaction, bool canDoSinglePhase, IEnlistmentNotificationInternal enlistmentNotification, EnlistmentOptions enlistmentOptions)
        {
            IResourceManagerShim  resourceManagerShim = null;
            IPhase0EnlistmentShim shim2          = null;
            IEnlistmentShim       enlistmentShim = null;
            IntPtr          zero   = IntPtr.Zero;
            bool            flag3  = false;
            bool            flag2  = false;
            OletxEnlistment target = new OletxEnlistment(canDoSinglePhase, enlistmentNotification, oletxTransaction.RealTransaction.TxGuid, enlistmentOptions, this, oletxTransaction);
            bool            flag   = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                if ((enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None)
                {
                    RuntimeHelpers.PrepareConstrainedRegions();
                    try
                    {
                    }
                    finally
                    {
                        oletxTransaction.RealTransaction.IncrementUndecidedEnlistments();
                        flag2 = true;
                    }
                }
                lock (target)
                {
                    RuntimeHelpers.PrepareConstrainedRegions();
                    try
                    {
                        resourceManagerShim = this.ResourceManagerShim;
                        if (resourceManagerShim == null)
                        {
                            throw TransactionManagerCommunicationException.Create(System.Transactions.SR.GetString("TraceSourceOletx"), null);
                        }
                        if ((enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None)
                        {
                            zero = HandleTable.AllocHandle(target);
                            RuntimeHelpers.PrepareConstrainedRegions();
                            try
                            {
                            }
                            finally
                            {
                                oletxTransaction.RealTransaction.TransactionShim.Phase0Enlist(zero, out shim2);
                                flag3 = true;
                            }
                            target.Phase0EnlistmentShim = shim2;
                        }
                        target.phase1Handle = HandleTable.AllocHandle(target);
                        resourceManagerShim.Enlist(oletxTransaction.RealTransaction.TransactionShim, target.phase1Handle, out enlistmentShim);
                        target.EnlistmentShim = enlistmentShim;
                    }
                    catch (COMException exception)
                    {
                        if (System.Transactions.Oletx.NativeMethods.XACT_E_TOOMANY_ENLISTMENTS == exception.ErrorCode)
                        {
                            throw TransactionException.Create(System.Transactions.SR.GetString("TraceSourceOletx"), System.Transactions.SR.GetString("OletxTooManyEnlistments"), exception);
                        }
                        OletxTransactionManager.ProxyException(exception);
                        throw;
                    }
                    finally
                    {
                        if (target.EnlistmentShim == null)
                        {
                            if ((zero != IntPtr.Zero) && !flag3)
                            {
                                HandleTable.FreeHandle(zero);
                            }
                            if (target.phase1Handle != IntPtr.Zero)
                            {
                                HandleTable.FreeHandle(target.phase1Handle);
                            }
                        }
                    }
                }
                flag = true;
            }
            finally
            {
                if ((!flag && ((enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None)) && flag2)
                {
                    oletxTransaction.RealTransaction.DecrementUndecidedEnlistments();
                }
            }
            return(target);
        }