クリックして評価とフィードバックをお寄せください
MSDN
MSDN ライブラリ
.NET 開発
.NET Framework 3.5
.NET Framework 3.5
TransactionAttribute クラス
すべて縮小/すべて展開 すべて縮小
このページは次のバージョンについて記述しています。
Microsoft Visual Studio 2008/.NET Framework 3.5

その他のバージョンについては、以下の情報を参照してください。
.NET Framework クラス ライブラリ
TransactionAttribute クラス

更新 : 2007 年 11 月

属性付きオブジェクトで使用できるトランザクションのタイプを指定します。使用できる値は TransactionOption 列挙体のメンバです。

名前空間 :  System.EnterpriseServices
アセンブリ :  System.EnterpriseServices (System.EnterpriseServices.dll 内)

Visual Basic (宣言)
<ComVisibleAttribute(False)> _
<AttributeUsageAttribute(AttributeTargets.Class, Inherited := True)> _
Public NotInheritable Class TransactionAttribute _
    Inherits Attribute
Visual Basic (使用法)
Dim instance As TransactionAttribute
C#
[ComVisibleAttribute(false)]
[AttributeUsageAttribute(AttributeTargets.Class, Inherited = true)]
public sealed class TransactionAttribute : Attribute
Visual C++
[ComVisibleAttribute(false)]
[AttributeUsageAttribute(AttributeTargets::Class, Inherited = true)]
public ref class TransactionAttribute sealed : public Attribute
J#
/** @attribute ComVisibleAttribute(false) */
/** @attribute AttributeUsageAttribute(AttributeTargets.Class, Inherited = true) */
public final class TransactionAttribute extends Attribute
JScript
public final class TransactionAttribute extends Attribute

トランザクション タイプがこの属性で指定されている場合は、COM+ カタログでトランザクション タイプを変更できません。COM+ カタログでトランザクション タイプが変更された場合、コンポーネントでこの属性を使用して同じトランザクション タイプを指定する必要があります。

属性の使用方法については、「属性を使用したメタデータの拡張」を参照してください。

TransactionAttribute を使用して ServicedComponent をトランザクションとしてマークする方法のコード例を次に示します。

Visual Basic
<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

C#
[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;

    }

}
Visual C++
[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;
   }

};

J#
/** @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
System..::.Object
  System..::.Attribute
    System.EnterpriseServices..::.TransactionAttribute
この型のすべてのパブリック static (Visual Basic では Shared) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。

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

.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。

.NET Framework

サポート対象 : 3.5、3.0、2.0、1.1、1.0
コミュニティ コンテンツ   コミュニティ コンテンツとは
新しいコンテンツの追加 RSS  注釈
Processing
© 2009 Microsoft Corporation. All rights reserved. 使用条件 | 商標 | プライバシー
Page view tracker