.NET Framework 4.5 中 Windows Workflow Foundation 的新功能What's New in Windows Workflow Foundation in .NET Framework 4.5

.NET Framework 4.5 中 Windows Workflow Foundation (WF) 引進許多新功能,例如新的活動、設計工具功能和工作流程開發模型。Windows Workflow Foundation (WF) in .NET Framework 4.5 introduces many new features, such as new activities, designer capabilities, and workflow development models. 重新裝載的工作流程設計工具支援在 .NET Framework 4.5 中引進的許多新工作流程功能。Many, but not all, of the new workflow features introduced in .NET Framework 4.5 are supported in the re-hosted workflow designer. 如需有關支援之新功能的詳細資訊,請參閱 重新裝載工作流程設計工具中新的 Workflow Foundation 4.5 功能支援For more information about the new features that are supported, see Support for New Workflow Foundation 4.5 Features in the Rehosted Workflow Designer. 如需將 .NET Framework 3.0 和 .NET Framework 3.5 工作流程應用程式遷移為使用最新版本的詳細資訊,請參閱 遷移指引For more information about migrating .NET Framework 3.0 and .NET Framework 3.5 workflow applications to use the latest version, see Migration Guidance. 本文概述 .NET Framework 4.5 中引進的新工作流程功能。This article provides an overview of the new workflow features introduced in .NET Framework 4.5.

警告

以舊版 Framework 為目標的專案無法使用 .NET Framework 4.5 中引進的新 Windows Workflow Foundation 功能。The new Windows Workflow Foundation features introduced in .NET Framework 4.5 are not available for projects that target previous versions of the framework. 如果以 .NET Framework 4.5 為目標的專案被覆位為舊版架構,則可能會發生數個問題。If a project that targets .NET Framework 4.5 is retargeted to a previous version of the framework, several issues can occur.

  • C # 運算式將在設計工具中取代,並在 XAML 中設定訊息值C# expressions will be replaced in the designer with the message Value was set in XAML.
  • 會出現許多建置錯誤,包括下列錯誤。Many build errors will occur, including the following error.

檔案格式與目前的目標 framework 不相容。若要轉換檔案格式,請明確地儲存檔案。當您儲存檔案並重新開啟設計工具之後,此錯誤訊息會消失。The file format is not compatible with current targeting framework. To convert the file format, please explicitly save the file. This error message will go away after you save the file and reopen the designer.

工作流程版本控制Workflow Versioning

.NET Framework 4.5 根據新的類別引進了數個新的版本控制功能 WorkflowIdentity.NET Framework 4.5 introduced several new versioning features based around the new WorkflowIdentity class. WorkflowIdentity 提供工作流程應用程式作者一個機制,用於對持續性的工作流程執行個體與其定義。WorkflowIdentity provides workflow application authors a mechanism for mapping a persisted workflow instance with its definition.

活動Activities

內建活動程式庫包含新的活動及現有活動的新功能。The built-in activity library contains new activities and new features for existing activities.

NoPersist 範圍NoPersist Scope

NoPersistScope 是新的容器活動,當 NoPersistScope 的子活動還在執行時,可防止工作流程持續進行。NoPersistScope is a new container activity that prevents a workflow from being persisted when the NoPersistScope’s child activities are executing. 在不適合工作流程持續的情況下 (例如,當工作流程使用檔案控制代碼等特定電腦資源或在資料庫交易期間時),此活動非常有用。This is useful in scenarios where it is not appropriate for the workflow to be persisted, such as when the workflow is using machine-specific resources such as file handles, or during database transactions. 以往為防止在活動執行期間發生持續的狀況,就需要使用 NativeActivity 的自訂 NoPersistHandlePreviously, to prevent persistence from occurring during an activity's execution, a custom NativeActivity that used a NoPersistHandle was required.

新的流程圖功能New Flowchart Capabilities

流程圖已針對 .NET Framework 4.5 進行更新,並具有下列新功能:Flowcharts are updated for .NET Framework 4.5 and have the following new capabilities:

  • DisplayNameFlowSwitch<T> 活動的 FlowDecision 屬性皆可編輯。The DisplayName property of a FlowSwitch<T> or FlowDecision activity is editable. 這會讓活動設計工具顯示更多關於活動用途的資訊。This will let the activity designer show more information about the activity's purpose.

  • 流程圖有一個新的屬性,稱為 ValidateUnconnectedNodes,此屬性的預設值是 FalseFlowcharts have a new property called ValidateUnconnectedNodes; the default for this property is False. 如果此屬性設為 True,則未連接的流程圖節點會產生驗證錯誤。If this property is set to True, then unconnected flowchart nodes will produce validation errors.

支援部分信任Support for Partial Trust

.NET Framework 4 中的工作流程需要完全信任的應用程式域。Workflows in .NET Framework 4 required a fully trusted application domain. 在 .NET Framework 4.5 中,工作流程可以在部分信任環境中運作。In .NET Framework 4.5, workflows can operate in a partial trust environment. 在部分信任環境中,可以使用協力廠商元件,而不將主機資源的完整存取權限授與這些元件。In a partial trust environment, third-party components can be used without granting them full access to the resources of the host. 以下是一些有關在部分信任環境中執行工作流程的疑慮:Some concerns about running workflows in partial trust are as follows:

  1. 在部分信任下,不支援使用 Interop 活動中包含的舊版元件 (包括規則)。Using legacy components (including Rules) contained in the Interop activity is not supported under partial trust.

  2. 不支援在 WorkflowServiceHost 中於部分信任環境下執行工作流程。Running workflows in partial trust in WorkflowServiceHost is not supported.

  3. 部分信任案例中的持續例外狀況是潛在的安全性威脅。Persisting exceptions in a partial-trust scenario is a potential security threat. 若要停用持續例外狀況,必須在專案中加入 ExceptionPersistenceExtension 型別的擴充,才能選擇退出持續例外狀況。To disable persisting of exceptions, an extension of type ExceptionPersistenceExtension must be added to the project in order to opt out of persisting exceptions. 下列程式碼範例示範如何實作此型別。The following code example demonstrates how to implement this type.

    public class ExceptionPersistenceExtension
    {
        public ExceptionPersistenceExtension()
        {
            this.PersistExceptions = false;
        }
        public bool PersistExceptions { get; set; }
    }
    

    如果不將例外情況序列化,請務必在 NoPersistScope 內使用例外狀況。If exceptions are not to be serialized, ensure that exceptions are used within a NoPersistScope.

  4. 活動作者應該覆寫 CacheMetadata,避免工作流程執行階段自動針對型別執行反映。Activity authors should override CacheMetadata to avoid having the workflow runtime automatically execute reflection against the type. 引數和子活動不可為 null,且必須明確地呼叫 BindArguments and child activities must be non-null, and Bind must be called explicitly. 如需覆寫的詳細資訊 CacheMetadata ,請參閱 使用 CacheMetadata 公開資料For more information on overriding CacheMetadata, see Exposing data with CacheMetadata. 此外,必須在中明確建立型別為或私用的引數實例, internal private CacheMetadata 以避免由反映建立。Also, instances of arguments that are of a type that is internal or private must be explicitly created in CacheMetadata to avoid being created by reflection.

  5. 型別將不會使用 ISerializableSerializableAttribute 進行序列化,要序列化的型別必須支援 DataContractSerializerTypes will not use ISerializable or SerializableAttribute for serialization; types that are to be serialized must support DataContractSerializer.

  6. 使用 LambdaValue<TResult> 的運算式需要 RestrictedMemberAccess,因此不能在部分信任下運作。Expressions that use LambdaValue<TResult> require RestrictedMemberAccess, and thus will not work under partial trust. 使用 LambdaValue<TResult> 的工作流程應將這些運算式改為從 CodeActivity<TResult> 衍生而來的活動。Workflows that use LambdaValue<TResult> should replace those expressions with activities that derive from CodeActivity<TResult>. ..

  7. 在部分信任下不能使用 TextExpressionCompiler 或裝載 Visual Basic 的編譯器來編譯運算式,但可以執行先前編譯的運算式。Expressions cannot be compiled using TextExpressionCompiler or the Visual Basic hosted compiler in partial trust, but previously compiled expressions can be run.

  8. 使用 層級2透明度 的單一元件無法在 .NET Framework 4、 .NET Framework 4.6.1.NET Framework 4.6.1 完全信任和部分信任中使用 .NET Framework 4.6.1.NET Framework 4.6.1A single assembly that uses Level 2 Transparency cannot be used in .NET Framework 4, .NET Framework 4.6.1.NET Framework 4.6.1 in full trust, and .NET Framework 4.6.1.NET Framework 4.6.1 in partial trust.

新的設計工具功能New Designer Capabilities

為使大型工作流程更好管理,現在可透過關鍵字搜尋工作流程。To make larger workflows more manageable, workflows can now be searched by keyword. 這項功能僅適用于 Visual Studio;這項功能在重新裝載設計工具中無法使用。This feature is only available in Visual Studio; this feature is not available in a rehosted designer. 您可使用兩種搜尋功能:There are two kinds of searches available:

  • 快速尋找,以 Ctrl + F 或 [ 編輯]、[ 尋找和取代]、[ 快速尋找] 來起始。Quick Find, initiated with either Ctrl+F or Edit, Find and Replace, Quick Find.

  • 在檔案中尋找,以 Ctrl + Shift + F 或 [ 編輯]、[ 尋找和取代]、[檔案 中尋找] 來啟動。Find in Files, initiated with either Ctrl+Shift+F or Edit, Find and Replace, Find in Files.

請注意,不支援 [取代] 功能。Note that Replace is not supported.

快速尋找Quick Find

在工作流程中搜尋的關鍵字將比對下列設計工具項目:Keywords searched in workflows will match the following designer items:

快速尋找會在設計工具的 ModelItem 樹狀結構中執行。Quick Find is performed on the designer's ModelItem tree. [快速尋找] 不會找出匯入工作流程定義中的命名空間。Quick Find will not locate namespaces imported in the workflow definition.

檔案中尋找Find in Files

在工作流程中搜尋的關鍵字會比對工作流程檔案的實際內容。Keywords searched in workflows will match the actual content of the workflow files. 搜尋結果會顯示在 Visual Studio 的 [尋找結果] 檢視窗格中。The search results will be shown in Visual Studio Find Results view pane. 按兩下結果項目會巡覽至工作流程設計工具中包含相符項目的活動。Double-clicking the result item will navigate to the activity which contains the match in workflow designer.

刪除變數和引數設計工具中的內容功能表項目Delete context menu item in variable and argument designer

在 .NET Framework 4 中,只能使用鍵盤在設計工具中刪除變數和引數。In .NET Framework 4, variables and arguments could only be deleted in the designer using the keyboard. 從 .NET Framework 4.5 開始,可以使用內容功能表刪除變數和引數。Starting with .NET Framework 4.5, variables and arguments can be deleted using the context menu.

下列螢幕擷取畫面顯示變數和引數設計工具內容功能表。The following screenshot shows the variable and argument designer context menu.

變數和引數設計工具內容功能表

使用序列自動環繞Auto-surround with Sequence

由於工作流程或特定容器活動 (如 NoPersistScope) 只能包含單一主體活動,因此開發人員必須先刪除第一個活動、加入 Sequence 活動,然後將這兩個活動同時加入序列活動中,才能加入第二個活動。Since a workflow or certain container activities (such as NoPersistScope) can only contain a single body activity, adding a second activity required the developer to delete the first activity, add a Sequence activity, and then add both activities to the sequence activity. 從 .NET Framework 4.5 開始,當您將第二個活動加入至設計工具介面時,系統會 Sequence 自動建立活動以包裝這兩個活動。Starting with .NET Framework 4.5, when adding a second activity to the designer surface, a Sequence activity will be automatically created to wrap both activities.

下列螢幕擷取畫面顯示 WriteLine 活動,此活動位在 BodyNoPersistScope 中。The following screenshot shows a WriteLine activity in the Body of a NoPersistScope.

NoPersistScope 活動主體中的 WriteLine 活動。

當第二個 Sequence 降到第一個之下時,下列螢幕擷取畫面會顯示在 Body 中自動建立的 WriteLine 活動。The following screenshot shows the automatically created Sequence activity in the Body when a second WriteLine is dropped below the first.

NoPersistScope 主體中自動建立的序列。

平移模式Pan Mode

若要更輕鬆地在設計工具中巡覽大型工作流程,可以啟用移動瀏覽模式,讓開發人員能夠透過按一下與拖曳方式來移動工作流程的可見部分,而不需使用捲軸。To more easily navigate a large workflow in the designer, pan mode can be enabled, allowing the developer to click and drag to move the visible portion of the workflow, rather than needing to use the scroll bars. 啟用移動瀏覽模式的按鈕位於設計工具的右下角。The button to activate pan mode is in the lower right corner of the designer.

下列螢幕擷取畫面顯示位於工作流程設計工具右下角的移動瀏覽按鈕。The following screenshot shows the pan button which is located at the bottom right corner of the workflow designer.

工作流程設計工具中醒目提示的平移按鈕。

您也可以使用滑鼠中鍵或空白鍵移動瀏覽工作流程設計工具。The middle mouse button or space bar can also be used to pan the workflow designer.

多重選取Multi-select

可以拖放矩形選取所要的活動 (未啟用移動瀏覽模式時),或是按住 Ctrl 鍵並依序按一下所需的活動,同時選取多個活動。Multiple activities can be selected at one time, either by dragging a rectangle around them (when pan mode is not enabled), or by holding down Ctrl and click the desired activities one by one.

您也可以在設計工具中拖放多個活動選取項目,或者使用內容功能表與選取項目互動。Multiple activity selections can also be dragged and dropped within the designer, and can also be interacted with using the context menu.

工作流程專案大綱檢視Outline view of workflow items

為簡化階層工作流程的巡覽功能,工作流程的元件會顯示在樹狀大綱檢閱中。In order to make hierarchical workflows easier to navigate, components of a workflow are shown in a tree-style outline view. 大綱視圖會顯示在 [ 檔大綱 ] 視圖中。The outline view is displayed in the Document Outline view. 若要開啟此視圖,請從頂端功能表中選取 [ view]、[ 其他視窗]、[ 檔大綱],或按 Ctrl W、U。To open this view, from the top menu, select View, Other Windows, Document Outline, or press Ctrl W,U. 按一下大綱檢視中的節點,會巡覽至工作流程設計工具中對應的活動,且大綱檢視會更新以顯示在設計工具中選取的活動。Clicking on a node in outline view will navigate to the corresponding activity in the workflow designer, and the outline view will be updated to show activities that are selected in the designer.

下列螢幕擷取畫面顯示 消費者入門教學 課程中已完成的工作流程,顯示具有連續工作流程的大綱視圖。The following screenshot of the completed workflow from the Getting Started Tutorial shows the outline view with a sequential workflow.

大綱視圖的螢幕擷取畫面,其中包含 Visual Studio 中的連續工作流程。

C # 運算式C# Expressions

在 .NET Framework 4.5 之前,工作流程中的所有運算式只能以 Visual Basic 撰寫。Prior to .NET Framework 4.5, all expressions in workflows could only be written in Visual Basic. 在 .NET Framework 4.5 中,Visual Basic 的運算式只會用於使用 Visual Basic 所建立的專案。In .NET Framework 4.5, Visual Basic expressions are only used for projects created using Visual Basic. Visual C# 專案現在使用 C# 來撰寫運算式。Visual C# projects now use C# for expressions. 提供功能完整的 C# 運算式編輯器,可使用反白顯示文法及 Intellisense 等功能。A fully functional C# expression editor is provided which capabilities such as grammar highlighting and intellisense. 在舊版中使用 Visual Basic 運算式建立的 C# 工作流程專案仍可繼續運作。C# workflow projects created in previous versions that use Visual Basic expressions will continue to work.

C# 運算式會在設計階段進行驗證。C# expressions are validated at design-time. C# 運算式中的錯誤會用紅色的波浪底線標記。Errors in C# expressions will be marked with a red wavy underline.

如需 c # 運算式的詳細資訊,請參閱 c # 運算式For more information about C# expressions, see C# Expressions.

對 shell 列和標頭專案的可見度有更多的控制More control of visibility of shell bar and header items

在重新裝載的設計工具中,部分標準 UI 控制項可能對特定工作流程沒有意義,而且可能是關閉狀態。In a rehosted designer, some of the standard UI controls may not have meaning for a given workflow, and may be turned off. 在 .NET Framework 4 中,只有設計工具底部的 shell 列才支援這個自訂。In .NET Framework 4, this customization is only supported by the shell bar at the bottom of the designer. 在 .NET Framework 4.5 中,設計工具頂端的 shell 標頭專案可見度可透過設定適當的值來調整 WorkflowShellHeaderItemsVisibility ShellHeaderItemsVisibilityIn .NET Framework 4.5, the visibility of shell header items at the top of the designer can be adjusted by setting WorkflowShellHeaderItemsVisibility with the appropriate ShellHeaderItemsVisibility value.

流程圖和狀態機器工作流程中的自動連接和自動插入Auto-connect and auto-insert in Flowchart and State Machine workflows

在 .NET Framework 4 中,必須手動新增流程圖工作流程中節點之間的連接。In .NET Framework 4, connections between nodes in a Flowchart workflow had to be added manually. 在 .NET Framework 4.5 中,當活動從 [工具箱] 拖曳到設計工具介面上時,[流程圖] 和 [狀態] 機器節點具有自動連接點,可供看到。In .NET Framework 4.5, Flowchart and State Machine nodes have auto-connect points that become visible when an activity is dragged from the toolbox onto the designer surface. 將活動拖曳到其中一點上,會自動加入該活動及必要的連接。Dropping an activity on one of these points automatically adds the activity along with the necessary connection.

下列螢幕擷取畫面顯示從工具箱拖曳活動時顯示的附加點。The following screenshot shows the attachment points that become visible when an activity is dragged from the toolbox.

顯示自動連接點的流程圖開始節點

您也可以將活動拖曳到流程圖節點和狀態之間的連接,以在其他兩個節點之間自動插入該節點。Activities can also be dragged onto connections between flowchart nodes and states to auto-insert the node between two other nodes. 下列螢幕擷取畫面顯示反白顯示的連接線,在此可以從工具箱中拖曳及放置活動。The following screenshot shows the highlighted connecting line where activities can be dragged from the toolbox and dropped.

用於置放活動的自動插入控點

設計工具批註Designer Annotations

為方便開發大型工作流程,設計工具現已支援加入標註,以追蹤設計流程。To facilitate developing larger workflows, the designer now supports adding annotations to help keep track of the design process. 您可以在活動、狀態、流程圖節點、變數和引數中加入標註。Annotation can be added to activities, states, flowchart nodes, variables and arguments. 下列螢幕擷取畫面顯示用來將標註加入設計工具的操作功能表。The following screenshot shows the context menu used to add annotations to the designer.

顯示用於新增批註之功能表的螢幕擷取畫面。

偵錯狀態Debugging states

在 .NET Framework 4 中,非活動元素無法支援 debug 中斷點,因為它們不是執行的單位。In .NET Framework 4, non-activity elements could not support debug breakpoints since they were not units of execution. 此版本提供一種機制,可在 State 物件中加入中斷點。This release provides a mechanism for adding breakpoints to State objects. State 中設定中斷點時,若在排定輸入活動或觸發程序前轉換狀態,就會中斷執行。When a breakpoint is set on a State, execution will break when the state is transitioned to, before its entry activities or triggers are scheduled.

在設計工具中定義和使用 ActivityDelegate 物件Define and consume ActivityDelegate objects in the designer

.NET Framework 4 中的活動使用 ActivityDelegate 物件來公開執行點,也就是工作流程的其他部分可以與工作流程的執行互動,但是使用這些執行點通常需要相當大量的程式碼。Activities in .NET Framework 4 used ActivityDelegate objects to expose execution points where other parts of the workflow could interact with a workflow's execution, but using these execution points usually required a fair amount of code. 在這個版本中,開發人員可以使用工作流程設計工具來定義及取用活動委派。In this release, developers can define and consume activity delegates using the workflow designer. 如需詳細資訊,請參閱 如何:定義和使用工作流程設計工具中的活動委派For more information, see How to: Define and consume activity delegates in the Workflow Designer.

組建階段驗證Build-time validation

在 .NET Framework 4 中,在工作流程專案的組建期間,工作流程驗證錯誤不會視為組建錯誤。In .NET Framework 4, workflow validation errors weren’t counted as build errors during the build of a workflow project. 這表示,即使有工作流程驗證錯誤,仍可能成功建置工作流程專案。This meant that building a workflow project could succeed even when there were workflow validation errors. 在 .NET Framework 4.5 中,工作流程驗證錯誤會導致組建失敗。In .NET Framework 4.5, workflow validation errors cause the build to fail.

設計階段背景驗證Design-time background validation

在 .NET Framework 4 中,工作流程是以前景進程的形式進行驗證,這可能會在複雜或耗時的驗證過程中封鎖 UI。In .NET Framework 4, workflows were validated as a foreground process, which could potentially block the UI during complex or time-consuming validation processes. 現在,工作流程驗證會在背景執行緒中進行,因此不會封鎖 UI。Workflow validation now takes place on a background thread, so that the UI is not blocked.

查看位於 XAML 檔案中不同位置的狀態View state located in a separate location in XAML files

在 .NET Framework 4 中,工作流程的檢視狀態資訊會儲存在多個不同位置的 XAML 檔案中。In .NET Framework 4, the view state information for a workflow is stored across the XAML file in many different locations. 對於想要直接讀取 XAML 或撰寫程式碼來移除檢視狀態資訊的開發人員來說,這樣很不方便。This is inconvenient for developers who want to read XAML directly, or write code to remove the view state information. 在 .NET Framework 4.5 中,會將 XAML 檔案中的檢視狀態資訊序列化為 XAML 檔案中的個別元素。In .NET Framework 4.5, the view state information in the XAML file is serialized as a separate element in the XAML file. 開發人員可以輕鬆地尋找和編輯活動的檢視狀態資訊,或完全移除檢視狀態。Developers can easily locate and edit the view state information of an activity, or remove the view state altogether.

運算式擴充性Expression extensibility

在 .NET Framework 4.5 中,我們為開發人員提供了一種方法,可讓開發人員建立自己的運算式和運算式撰寫經驗,以插入工作流程設計工具中。In .NET Framework 4.5, we provide a way for developers to create their own expression and expression authoring experience that can be plugged into the workflow designer.

在重新裝載設計工具中加入工作流程4.5 功能Opt-in for Workflow 4.5 features in rehosted designer

為了維持回溯相容性,重新裝載 designer 預設不會啟用 .NET Framework 4.5 中包含的一些新功能。To preserve backward compatibility, some new features included in .NET Framework 4.5 are not enabled by default in the rehosted designer. 這是為了確保現有的應用程式 (使用重新裝載設計工具) 不會因為更新至最新版本而中斷。This is to ensure that existing applications that use the rehosted designer are not broken by updating to the latest version. 若要在重新裝載的設計工具中啟用新功能,請將 TargetFrameworkName 設為 ".NET Framework 4.5",或者設定 DesignerConfigurationService 的個別成員以啟用個別功能。To enable new features in the rehosted designer, either set TargetFrameworkName to ".NET Framework 4.5", or set individual members of DesignerConfigurationService to enable individual features.

新的工作流程開發模型New Workflow Development Models

除了流程圖和循序工作流程開發模型外,此版本還包括狀態機器工作流程和合約優先工作流程服務。In addition to flowchart and sequential workflow development models, this release includes State Machine workflows, and contract-first workflow services.

狀態機器工作流程State machine workflows

狀態機器工作流程是在 Microsoft .NET Framework 4 Platform Update 1的 .NET Framework 4 4.0.1 版中引進的一部分。State machine workflows were introduced as part of the .NET Framework 4, version 4.0.1 in the Microsoft .NET Framework 4 Platform Update 1. 此更新包括若干新類別和活動,可讓開發人員建立狀態機器工作流程。This update included several new classes and activities which allowed developers to create state machine workflows. 這些類別和活動已針對 .NET Framework 4.5 進行更新。These classes and activities have been updated for .NET Framework 4.5. 更新包括:Updates include:

  1. 可設定狀態中斷點的功能The ability to set breakpoints on states

  2. 可在工作流程設計工具中複製和貼上轉換的功能The ability to copy and paste transitions in the workflow designer

  3. 設計工具支援建立共用的觸發程序轉換Designer support for shared trigger transition creation

  4. 用來建立狀態機器工作流程的活動包括:StateMachineStateTransitionActivities used to create State Machine workflows, including: StateMachine, State, and Transition

下列螢幕擷取畫面顯示 消費者入門教學 課程步驟 如何:建立狀態機器工作流程中的已完成狀態機器工作流程。The following screenshot shows the completed state machine workflow from the Getting Started Tutorial step How to: Create a State Machine Workflow.

顯示已完成狀態機器工作流程的圖例。

如需建立狀態機器工作流程的詳細資訊,請參閱 狀態機器工作流程For more information on creating state machine workflows, see State Machine Workflows.

合約優先工作流程開發Contract-first workflow development

合約優先工作流程開發工具可讓開發人員在 code first 中設計合約,然後在 Visual Studio 中按幾下滑鼠,就會在 [工具箱] 中自動產生代表每個作業的活動範本。The contract-first workflow development tool allows the developer to design a contract in code first, then, with a few clicks in Visual Studio, automatically generate an activity template in the toolbox representing each operation. 之後,這些活動可以用於建立工作流程,以實作合約所定義的作業。These activities are then used to create a workflow that implements the operations defined by the contract. 工作流程設計工具將會驗證工作流程服務,以確保這些作業都有進行實作且工作流程的簽章與合約簽章相符。The workflow designer will validate the workflow service to ensure that these operations are implemented and the signature of the workflow matches the contract signature. 開發人員也可以在工作流程服務與實作合約的集合之間建立關聯。The developer can also associate a workflow service with a collection of implemented contracts. 如需有關合約優先工作流程服務開發的詳細資訊,請參閱 如何:建立使用現有服務合約的工作流程服務For more information on contract-first workflow service development, see How to: Create a workflow service that consumes an existing service contract.