共用方式為


ThrowActivity 建構函式

定義

初始化 ThrowActivity 類別的新執行個體。

多載

ThrowActivity()

初始化 ThrowActivity 類別的新執行個體。

ThrowActivity(String)

初始化 ThrowActivity 類別的新執行個體,並初始化其名稱。

ThrowActivity()

初始化 ThrowActivity 類別的新執行個體。

public:
 ThrowActivity();
public ThrowActivity ();
Public Sub New ()

範例

以下程式碼顯示使用工作流程中的單一擲回活動來實作例外狀況處理。 這個範例包括叫用建構函式。 這個程式碼範例是 ThrowWorkflow.cs 檔案中<擲回 SDK>範例的一部分。 如需詳細資訊,請參閱 使用 Throw

public sealed partial class ThrowWorkflow : SequentialWorkflowActivity
{
    [System.Diagnostics.DebuggerNonUserCode()]
    private void InitializeComponent()
    {
        this.CanModifyActivities = true;
        System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
        this.throwActivity1 = new System.Workflow.ComponentModel.ThrowActivity();
        activitybind1.Name = "ThrowWorkflow";
        activitybind1.Path = "ThrownException";
        //
        // throwActivity1
        //
        this.throwActivity1.Name = "throwActivity1";
        this.throwActivity1.SetBinding(System.Workflow.ComponentModel.ThrowActivity.FaultProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
        //
        // ThrowWorkflow
        //
        this.Activities.Add(this.throwActivity1);
        this.Name = "ThrowWorkflow";
        this.CanModifyActivities = false;
    }

    private Exception thrownExceptionValue = new System.Exception("My Exception Message.");

    public Exception ThrownException
    {
        get { return thrownExceptionValue; }
        set { thrownExceptionValue = value; }
    }

    private ThrowActivity throwActivity1;
}
Partial Public NotInheritable Class ThrowWorkflow
    Inherits SequentialWorkflowActivity

    <System.Diagnostics.DebuggerNonUserCode()> _
                                        Private Sub InitializeComponent()

        Me.CanModifyActivities = True
        Dim activitybind1 As New System.Workflow.ComponentModel.ActivityBind()
        Me.throwActivity1 = New System.Workflow.ComponentModel.ThrowActivity()
        activitybind1.Name = "ThrowWorkflow"
        activitybind1.Path = "ThrownException"
        ' 
        ' throwActivity1
        ' 
        Me.throwActivity1.Name = "throwActivity1"
        Me.throwActivity1.SetBinding(System.Workflow.ComponentModel.ThrowActivity.FaultProperty, activitybind1)
        ' 
        ' ThrowWorkflow
        ' 
        Me.Activities.Add(Me.throwActivity1)
        Me.Name = "ThrowWorkflow"
        Me.CanModifyActivities = False

    End Sub

    Private thrownExceptionValue As New System.Exception("My Exception Message.")

    Public Property ThrownException() As Exception
        Get
            Return thrownExceptionValue
        End Get
        Set(ByVal value As Exception)
            thrownExceptionValue = value
        End Set
    End Property

    Private throwActivity1 As ThrowActivity

End Class

適用於

ThrowActivity(String)

初始化 ThrowActivity 類別的新執行個體,並初始化其名稱。

public:
 ThrowActivity(System::String ^ name);
public ThrowActivity (string name);
new System.Workflow.ComponentModel.ThrowActivity : string -> System.Workflow.ComponentModel.ThrowActivity
Public Sub New (name As String)

參數

name
String

使用者定義的活動名稱。

例外狀況

identifier 為 null 參考 (在 Visual Basic 中為 Nothing)。

適用於