예제 #1
0
 internal virtual void ChangeStatePromotedPhase0(InternalTransaction tx)
 {
     if (DiagnosticTrace.Error)
     {
         InvalidOperationExceptionTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "");
     }
     throw new InvalidOperationException();
 }
예제 #2
0
 internal virtual void RestartCommitIfNeeded(InternalTransaction tx)
 {
     if (DiagnosticTrace.Error)
     {
         InvalidOperationExceptionTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "");
     }
     throw new InvalidOperationException();
 }
예제 #3
0
 internal virtual void InDoubtFromEnlistment(InternalTransaction tx)
 {
     if (DiagnosticTrace.Error)
     {
         InvalidOperationExceptionTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "");
     }
     throw new InvalidOperationException();
 }
 internal static Exception CreateTransactionCompletedException(string traceSource)
 {
     if (DiagnosticTrace.Error)
     {
         InvalidOperationExceptionTraceRecord.Trace(traceSource, System.Transactions.SR.GetString("TransactionAlreadyCompleted"));
     }
     return(new InvalidOperationException(System.Transactions.SR.GetString("TransactionAlreadyCompleted")));
 }
 internal static Exception CreateInvalidOperationException(string traceSource, string message, Exception innerException)
 {
     if (DiagnosticTrace.Error)
     {
         InvalidOperationExceptionTraceRecord.Trace(traceSource, message);
     }
     return(new InvalidOperationException(message, innerException));
 }
 internal static Exception CreateEnlistmentStateException(string traceSource, Exception innerException)
 {
     if (DiagnosticTrace.Error)
     {
         InvalidOperationExceptionTraceRecord.Trace(traceSource, System.Transactions.SR.GetString("EnlistmentStateException"));
     }
     return(new InvalidOperationException(System.Transactions.SR.GetString("EnlistmentStateException"), innerException));
 }
예제 #7
0
        internal static Exception CreateEnlistmentStateException(string traceSource, Exception innerException, Guid distributedTxId)
        {
            string messagewithTxId = SR.EnlistmentStateException;

            if (IncludeDistributedTxId(distributedTxId))
            {
                messagewithTxId = string.Format(SR.DistributedTxIDInTransactionException, messagewithTxId, distributedTxId);
            }

            if (DiagnosticTrace.Error)
            {
                InvalidOperationExceptionTraceRecord.Trace(traceSource, messagewithTxId);
            }
            return(new InvalidOperationException(messagewithTxId, innerException));
        }
예제 #8
0
        internal static Exception CreateTransactionCompletedException(string traceSource, Guid distributedTxId)
        {
            string messagewithTxId = SR.TransactionAlreadyCompleted;

            if (IncludeDistributedTxId(distributedTxId))
            {
                messagewithTxId = string.Format(SR.DistributedTxIDInTransactionException, messagewithTxId, distributedTxId);
            }

            if (DiagnosticTrace.Error)
            {
                InvalidOperationExceptionTraceRecord.Trace(traceSource, messagewithTxId);
            }

            return(new InvalidOperationException(messagewithTxId));
        }
        public void Dispose()
        {
            bool flag = false;

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), "TransactionScope.Dispose");
            }
            if (this.disposed)
            {
                if (DiagnosticTrace.Verbose)
                {
                    MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), "TransactionScope.Dispose");
                }
            }
            else
            {
                if (this.scopeThread != Thread.CurrentThread)
                {
                    if (DiagnosticTrace.Error)
                    {
                        InvalidOperationExceptionTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), System.Transactions.SR.GetString("InvalidScopeThread"));
                    }
                    throw new InvalidOperationException(System.Transactions.SR.GetString("InvalidScopeThread"));
                }
                Exception exception = null;
                try
                {
                    this.disposed = true;
                    TransactionScope currentScope       = this.threadContextData.CurrentScope;
                    Transaction      contextTransaction = null;
                    Transaction      transaction        = Transaction.FastGetTransaction(currentScope, this.threadContextData, out contextTransaction);
                    if (!this.Equals(currentScope))
                    {
                        if (currentScope == null)
                        {
                            Transaction committableTransaction = this.committableTransaction;
                            if (committableTransaction == null)
                            {
                                committableTransaction = this.dependentTransaction;
                            }
                            committableTransaction.Rollback();
                            flag = true;
                            throw TransactionException.CreateInvalidOperationException(System.Transactions.SR.GetString("TraceSourceBase"), System.Transactions.SR.GetString("TransactionScopeInvalidNesting"), null);
                        }
                        if ((currentScope.interopOption == EnterpriseServicesInteropOption.None) && (((null != currentScope.expectedCurrent) && !currentScope.expectedCurrent.Equals(transaction)) || ((null != transaction) && (null == currentScope.expectedCurrent))))
                        {
                            if (DiagnosticTrace.Warning)
                            {
                                TransactionTraceIdentifier transactionTraceId;
                                TransactionTraceIdentifier empty;
                                if (null == transaction)
                                {
                                    empty = TransactionTraceIdentifier.Empty;
                                }
                                else
                                {
                                    empty = transaction.TransactionTraceId;
                                }
                                if (null == this.expectedCurrent)
                                {
                                    transactionTraceId = TransactionTraceIdentifier.Empty;
                                }
                                else
                                {
                                    transactionTraceId = this.expectedCurrent.TransactionTraceId;
                                }
                                TransactionScopeCurrentChangedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), transactionTraceId, empty);
                            }
                            exception = TransactionException.CreateInvalidOperationException(System.Transactions.SR.GetString("TraceSourceBase"), System.Transactions.SR.GetString("TransactionScopeIncorrectCurrent"), null);
                            if (null != transaction)
                            {
                                try
                                {
                                    transaction.Rollback();
                                }
                                catch (TransactionException)
                                {
                                }
                                catch (ObjectDisposedException)
                                {
                                }
                            }
                        }
                        while (!this.Equals(currentScope))
                        {
                            if (exception == null)
                            {
                                exception = TransactionException.CreateInvalidOperationException(System.Transactions.SR.GetString("TraceSourceBase"), System.Transactions.SR.GetString("TransactionScopeInvalidNesting"), null);
                            }
                            if (DiagnosticTrace.Warning)
                            {
                                if (null == currentScope.expectedCurrent)
                                {
                                    TransactionScopeNestedIncorrectlyTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), TransactionTraceIdentifier.Empty);
                                }
                                else
                                {
                                    TransactionScopeNestedIncorrectlyTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), currentScope.expectedCurrent.TransactionTraceId);
                                }
                            }
                            currentScope.complete = false;
                            try
                            {
                                currentScope.InternalDispose();
                            }
                            catch (TransactionException)
                            {
                            }
                            currentScope  = this.threadContextData.CurrentScope;
                            this.complete = false;
                        }
                    }
                    else if ((this.interopOption == EnterpriseServicesInteropOption.None) && (((null != this.expectedCurrent) && !this.expectedCurrent.Equals(transaction)) || ((null != transaction) && (null == this.expectedCurrent))))
                    {
                        if (DiagnosticTrace.Warning)
                        {
                            TransactionTraceIdentifier identifier;
                            TransactionTraceIdentifier identifier2;
                            if (null == transaction)
                            {
                                identifier2 = TransactionTraceIdentifier.Empty;
                            }
                            else
                            {
                                identifier2 = transaction.TransactionTraceId;
                            }
                            if (null == this.expectedCurrent)
                            {
                                identifier = TransactionTraceIdentifier.Empty;
                            }
                            else
                            {
                                identifier = this.expectedCurrent.TransactionTraceId;
                            }
                            TransactionScopeCurrentChangedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), identifier, identifier2);
                        }
                        if (exception == null)
                        {
                            exception = TransactionException.CreateInvalidOperationException(System.Transactions.SR.GetString("TraceSourceBase"), System.Transactions.SR.GetString("TransactionScopeIncorrectCurrent"), null);
                        }
                        if (null != transaction)
                        {
                            try
                            {
                                transaction.Rollback();
                            }
                            catch (TransactionException)
                            {
                            }
                            catch (ObjectDisposedException)
                            {
                            }
                        }
                        this.complete = false;
                    }
                    flag = true;
                }
                finally
                {
                    if (!flag)
                    {
                        this.PopScope();
                    }
                }
                this.InternalDispose();
                if (exception != null)
                {
                    throw exception;
                }
                if (DiagnosticTrace.Verbose)
                {
                    MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), "TransactionScope.Dispose");
                }
            }
        }