Example #1
0
        internal static byte[] GetTransmitterPropagationToken(
            OletxTransaction oletxTx
            )
        {
            byte[]          propagationToken       = null;
            CoTaskMemHandle propagationTokenBuffer = null;
            UInt32          tokenSize = 0;

            try
            {
                oletxTx.realOletxTransaction.TransactionShim.GetPropagationToken(
                    out tokenSize,
                    out propagationTokenBuffer);
                propagationToken = new byte[tokenSize];
                Marshal.Copy(propagationTokenBuffer.DangerousGetHandle(), propagationToken, 0, Convert.ToInt32(tokenSize));
            }
            catch (COMException comException)
            {
                OletxTransactionManager.ProxyException(comException);
                throw;
            }
            finally
            {
                if (null != propagationTokenBuffer)
                {
                    propagationTokenBuffer.Close();
                }
            }

            return(propagationToken);
        }
Example #2
0
        internal static byte[] GetTransmitterPropagationToken(OletxTransaction oletxTx)
        {
            CoTaskMemHandle propgationToken = null;

            byte[] destination         = null;
            uint   propagationTokeSize = 0;

            try
            {
                oletxTx.realOletxTransaction.TransactionShim.GetPropagationToken(out propagationTokeSize, out propgationToken);
                destination = new byte[propagationTokeSize];
                Marshal.Copy(propgationToken.DangerousGetHandle(), destination, 0, Convert.ToInt32(propagationTokeSize));
            }
            catch (COMException exception)
            {
                OletxTransactionManager.ProxyException(exception);
                throw;
            }
            finally
            {
                if (propgationToken != null)
                {
                    propgationToken.Close();
                }
            }
            return(destination);
        }
Example #3
0
        public static byte[] GetExportCookie(Transaction transaction, byte[] whereabouts)
        {
            if (!TransactionManager._platformValidated)
            {
                TransactionManager.ValidatePlatform();
            }
            byte[] destination = null;
            if (null == transaction)
            {
                throw new ArgumentNullException("transaction");
            }
            if (whereabouts == null)
            {
                throw new ArgumentNullException("whereabouts");
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "TransactionInterop.GetExportCookie");
            }
            byte[] destinationArray = new byte[whereabouts.Length];
            Array.Copy(whereabouts, destinationArray, whereabouts.Length);
            whereabouts = destinationArray;
            int              cookieIndex  = 0;
            uint             cookieSize   = 0;
            CoTaskMemHandle  cookieBuffer = null;
            OletxTransaction transaction2 = ConvertToOletxTransaction(transaction);

            try
            {
                transaction2.realOletxTransaction.TransactionShim.Export(Convert.ToUInt32(whereabouts.Length), whereabouts, out cookieIndex, out cookieSize, out cookieBuffer);
                destination = new byte[cookieSize];
                Marshal.Copy(cookieBuffer.DangerousGetHandle(), destination, 0, Convert.ToInt32(cookieSize));
            }
            catch (COMException exception)
            {
                OletxTransactionManager.ProxyException(exception);
                throw TransactionManagerCommunicationException.Create(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
            }
            finally
            {
                if (cookieBuffer != null)
                {
                    cookieBuffer.Close();
                }
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "TransactionInterop.GetExportCookie");
            }
            return(destination);
        }
Example #4
0
        public static byte[] GetExportCookie(
            Transaction transaction,
            byte[] whereabouts
            )
        {
            if (!TransactionManager._platformValidated)
            {
                TransactionManager.ValidatePlatform();
            }

            byte[] cookie = null;

            if (null == transaction)
            {
                throw new ArgumentNullException("transaction");
            }

            if (null == whereabouts)
            {
                throw new ArgumentNullException("whereabouts");
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx),
                                               "TransactionInterop.GetExportCookie"
                                               );
            }

            // Copy the whereabouts so that it cannot be modified later.
            byte[] whereaboutsCopy = new byte[whereabouts.Length];
            Array.Copy(whereabouts, whereaboutsCopy, whereabouts.Length);
            whereabouts = whereaboutsCopy;

            int             cookieIndex  = 0;
            UInt32          cookieSize   = 0;
            CoTaskMemHandle cookieBuffer = null;

            // First, make sure we are working with an OletxTransaction.
            OletxTransaction oletxTx = TransactionInterop.ConvertToOletxTransaction(transaction);

            try
            {
                oletxTx.realOletxTransaction.TransactionShim.Export(
                    Convert.ToUInt32(whereabouts.Length),
                    whereabouts,
                    out cookieIndex,
                    out cookieSize,
                    out cookieBuffer);

                // allocate and fill in the cookie
                cookie = new byte[cookieSize];
                Marshal.Copy(cookieBuffer.DangerousGetHandle(), cookie, 0, Convert.ToInt32(cookieSize));
            }
            catch (COMException comException)
            {
                OletxTransactionManager.ProxyException(comException);

                // We are unsure of what the exception may mean.  It is possible that
                // we could get E_FAIL when trying to contact a transaction manager that is
                // being blocked by a fire wall.  On the other hand we may get a COMException
                // based on bad data.  The more common situation is that the data is fine
                // (since it is generated by Microsoft code) and the problem is with
                // communication.  So in this case we default for unknown exceptions to
                // assume that the problem is with communication.
                throw TransactionManagerCommunicationException.Create(SR.GetString(SR.TraceSourceOletx), comException);
            }
            finally
            {
                if (null != cookieBuffer)
                {
                    cookieBuffer.Close();
                }
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx),
                                              "TransactionInterop.GetExportCookie"
                                              );
            }

            return(cookie);
        }