Freigeben über


ContextUtil.MyTransactionVote-Eigenschaft

Ruft das consistent-Bit im COM+-Kontext ab oder legt dieses fest.

Namespace: System.EnterpriseServices
Assembly: System.EnterpriseServices (in system.enterpriseservices.dll)

Syntax

'Declaration
Public Shared Property MyTransactionVote As TransactionVote
'Usage
Dim value As TransactionVote

value = ContextUtil.MyTransactionVote

ContextUtil.MyTransactionVote = value
public static TransactionVote MyTransactionVote { get; set; }
public:
static property TransactionVote MyTransactionVote {
    TransactionVote get ();
    void set (TransactionVote value);
}
/** @property */
public static TransactionVote get_MyTransactionVote ()

/** @property */
public static void set_MyTransactionVote (TransactionVote value)
public static function get MyTransactionVote () : TransactionVote

public static function set MyTransactionVote (value : TransactionVote)

Eigenschaftenwert

Einer der TransactionVote-Werte: entweder Commit oder Abort.

Ausnahmen

Ausnahmetyp Bedingung

COMException

Es ist kein COM+-Kontext verfügbar.

PlatformNotSupportedException

Die Plattform ist nicht Windows 2000 oder höher.

Hinweise

Wenn MyTransactionVote auf Commit festgelegt wird, wird das consistent-Bit für COM+ auf true festgelegt, und der COM+-Kontext fordert an, ein Commit für die Transaktion auszuführen. Wenn MyTransactionVote auf Abort festgelegt wird, wird das consistent-Bit auf false festgelegt, und der COM+-Kontext fordert an, die Transaktion abzubrechen. Der Standardwert des consistent-Bits ist true.

Das consistent-Bit löst eine Anforderung aus, ein Commit für die Transaktion, in der es ausgeführt wird, durchzuführen bzw. die Transaktion abzubrechen, und das done-Bit beendet die Anforderung. COM+ untersucht das consistent-Bit, wenn das done-Bit bei Beenden eines Methodenaufrufs auf true festgelegt oder wenn das Objekt deaktiviert wird. Das consistent-Bit eines Objekts kann sich zwar innerhalb jedes einzelnen Methodenaufrufs ändern, es ist jedoch nur die letzte Änderung relevant.

Beispiel

Im folgenden Codebeispiel wird veranschaulicht, wie die MyTransactionVote-Eigenschaft verwendet wird, um eine transaktionale ServicedComponent zu erstellen.

<Transaction()>  _
Public Class TransactionalComponent
    Inherits ServicedComponent
    
    
    Public Sub TransactionalMethod(ByVal data As String) 
        
        ContextUtil.DeactivateOnReturn = True
        ContextUtil.MyTransactionVote = TransactionVote.Abort
        
        ' Do work with data. Return if any errors occur.
        ' Vote to commit. If any errors occur, this code will not execute.
        ContextUtil.MyTransactionVote = TransactionVote.Commit
    
    End Sub 'TransactionalMethod 
End Class 'TransactionalComponent
[Transaction]
public class TransactionalComponent : ServicedComponent
{

    public void TransactionalMethod (string data)
    {

      ContextUtil.DeactivateOnReturn = true;
      ContextUtil.MyTransactionVote = TransactionVote.Abort;

      // Do work with data. Return if any errors occur.

      // Vote to commit. If any errors occur, this code will not execute.
      ContextUtil.MyTransactionVote = TransactionVote.Commit;

    }

}
[assembly:System::Reflection::AssemblyKeyFile("Transaction.snk")];
[Transaction]
public ref class TransactionalComponent: public ServicedComponent
{
public:
   void TransactionalMethod( String^ data )
   {
      ContextUtil::DeactivateOnReturn = true;
      ContextUtil::MyTransactionVote = TransactionVote::Abort;
      
      // do work with data
      ContextUtil::MyTransactionVote = TransactionVote::Commit;
   }

};
/** @attribute Transaction()
 */
public class TransactionalComponent extends ServicedComponent
{
    public void TransactionalMethod(String data)
    {
        ContextUtil.set_DeactivateOnReturn(true);
        ContextUtil.set_MyTransactionVote(TransactionVote.Abort);

        // Do work with data. Return if any errors occur.
        // Vote to commit. If any errors occur, this code will not execute.
        ContextUtil.set_MyTransactionVote(TransactionVote.Commit);
    } //TransactionalMethod 
} //TransactionalComponent

.NET Framework-Sicherheit

  • Volle Vertrauenswürdigkeit für den unmittelbaren Aufrufer. Dieser Member kann von nur teilweise vertrauenswürdigem Code nicht verwendet werden. Weitere Informationen finden Sie unter .

Plattformen

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

ContextUtil-Klasse
ContextUtil-Member
System.EnterpriseServices-Namespace