ContextUtil.ActivityId 属性

定义

获取一个 GUID,它表示包含组件的活动。

public:
 static property Guid ActivityId { Guid get(); };
public static Guid ActivityId { get; }
static member ActivityId : Guid
Public Shared ReadOnly Property ActivityId As Guid

属性值

如果当前上下文是某个活动的一部分,则为该活动的 GUID;否则为 GUID_NULL

例外

没有可用的 COM+ 上下文。

示例

下面的代码示例获取 属性的值 ActivityId

[Synchronization(SynchronizationOption::Required)]
public ref class ContextUtil_ActivityId: public ServicedComponent
{
public:
   void Example()
   {
      // Display the ActivityID associated with the current COM+ context.
      Console::WriteLine( "Activity ID: {0}", ContextUtil::ActivityId );
   }
};
[Synchronization(SynchronizationOption.Required)]
public class ContextUtil_ActivityId : ServicedComponent
{
    public void Example()
    {
        // Display the ActivityID associated with the current COM+ context.
        Console.WriteLine("Activity ID: {0}", ContextUtil.ActivityId);
    }
}
<Synchronization(SynchronizationOption.Required)>  _
Public Class ContextUtil_ActivityId
    Inherits ServicedComponent
    
    Public Sub Example() 
        ' Display the ActivityID associated with the current COM+ context.
        MsgBox("Activity ID: " & ContextUtil.ActivityId.ToString())

    End Sub
End Class

适用于