Microsoft KB Archive/935354

= Microsoft Windows Workflow Foundation Step by Step Comments and Corrections =

Article ID: 935354

Article Last Modified on 5/16/2007

-

APPLIES TO


 * Microsoft Windows Workflow Foundation Step by Step, ISBN 0-7356-2335-X

-



SUMMARY
This article contains comments, corrections, and information about known errors relating to the Microsoft Press book Microsoft Windows Workflow Foundation Step by Step, 0-7356-2335-X.

The following topics are covered:


 * CD-ROM: Revised Code for Chapters 6, 8, and 14
 * Page xxvii: Reference to Online Companion Content is incorrect
 * Page 7: Correction to Windows SDK download location
 * Page 19: Missing characters from regular expressions
 * Page 24: Correction to WorkflowRuntime instance
 * Page 28: Correction To WorkflowRuntime Instance
 * Page 36: _waitHandle should be waitHandle
 * Page 38: &quot;Create a single instance of Workflow-Runtime per AppDomain&quot; should be &quot;Create an instance of Workflow-Runtime&quot;
 * Page 50: Correction to step 2
 * Page 50: Delete Tip box
 * Page 61: “class MyClass” should be “class MyClass : DependencyObject”
 * Page 76: ActivityTrackingPoint should be ActivityTrackPoint
 * Page 88: GetWorkflowRuntime should be WorkflowRuntime
 * Page 89: Delete step 2
 * Page 90: SqlTrackingService should be SqlTrackingQuery
 * Page 92: Add &quot;using System.Workflow.ComponentModel&quot; to step 2
 * Page 113: System.Workflow.Activity should be System.Workflow.Activities
 * Page 114: Correction to step 14
 * Page 116: First character of type must be upper-case
 * Page 122: WorkingStore should be WorkflowStore
 * Page 123: Correction to script names
 * Page 159: First &quot;base constructor&quot; should be &quot;constructor&quot;
 * Page 162: MVDataconnector.cs should be MVDataConnector.cs
 * Page 179: Workflow2.Workflow1 should be Workflow2.Workflow2
 * Page 194: Incorrect property name
 * Page 200: Method should be Property
 * Page 200: Method should be Event
 * Page 236: if (_service == null) should be if (value != null)
 * Page 264: setlevel1 should be setLevel1
 * Page 280: Extra bracket in code
 * Page 286: WorkflowComplete should WorkflowCompleted
 * Page 332: Correction to last paragraph
 * Page 352: DefaultSettings should be DefaultSettingsSection
 * Page 386: &quot;select Workflow Activity Library&quot; should be &quot;select Workflow&quot;
 * Page 396: CorrelationIntializer should be CorrelationInitializer
 * Page 432: Shift+F5 should be Ctrl+F5
 * Page 469: Shift+F5 should be Ctrl+F5



CD-ROM: Revised Code for Chapters 6, 8, and 14
CD-ROM: After you install the sample code from the CD, the sample codes for various chapters are placed, by default, in the \My Documents\Microsoft Press folder on the hard disk.

We have updated sample code for Chapters 6, 8 and 14. Please download the updated sample code to replace the sample code on the hard disk for these chapters.

WF6-8-14.exe

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

Page xxvii: Reference to Online Companion Content is incorrect
On page xxvii, the section titled &quot;Online Companion Content&quot; reads:

&quot;Online Companion Content

The online companion content page has content and links related to this book, including a link to the Microsoft Press Technology Updates Web page. The online companion content page for this book can be found at www.microsoft.com/mspress/companion/0-7356-2335-4/&quot;

Disregard this entire section as there is no companion content website for this title.

Page 7: Correction to Windows SDK download location
On page 7, in the first bullet, the URL for downloading the Windows SDK has changed.

Change:

“http://www.microsoft.com/downloads/details.aspx?familyid=7614FE22-8A64-4DFB-AA0C-DB53035F40A0&displaylang=en”

To:

“http://www.microsoft.com/downloads/details.aspx?familyid=C2B1E300-F358-4523-B479-F53D234CDCCF&displaylang=en”

Page 19: Missing characters from regular expressions
On page 19, the first two lines of code in step 4 are missing some characters.

Change:

string USCode = @&quot;^(\d{5}$)|(\d{5}$\-\d{4}$)&quot;; string CanadianCode = @&quot;[ABCEGHJKLMNPRSTVXY]\d[A-Z] \d[A-Z]\d&quot;;

To:

string USCode = @&quot;^(\d{5}$)|(\d{5}-\d{4}$)&quot;; string CanadianCode = @&quot;^[ABCEGHJKLMNPRSTVXY]\d[A-Z] \d[A-Z]\d$&quot;;

Page 24: Correction to WorkflowRuntime instance
On page 24, in the first paragraph, the statement about WorkflowRuntime instance is incorrect.

Change:

“The WF runtime and your application execute together in a .NET AppDomain, and there can be only one instance of WorkflowRuntime per AppDomain. Attempting to create a second instance of WorkflowRuntime in a single AppDomain results in an InvalidOperationException.”

To:

“The WF runtime and your application execute together in a .NET AppDomain. Although early in WF’s history there could be only a single instance of the WorkflowRuntime per AppDomain, contemporary versions allow multiple instances.”

Page 28: Correction To WorkflowRuntime Instance
On page 28, under &quot;Building a Workflow Runtime Factory&quot;, the statement about WorkflowRuntime is incorrect.

Change:

“I mentioned this previously in the chapter, but it is important enough to mention again—there can be only a single instance of WorkflowRuntime per AppDomain. And because the majority of .NET applications use only a single AppDomain, it necessarily follows that you can generally use only a single instance of WorkflowRuntime in your application. Whenever I hear “use only a single instance,” I naturally think of using a combination of the singleton and factory patterns. The singleton pattern, if you’re unfamiliar with patterns, is simply a mechanism for assuring that no matter how many times your application requests instances of the singleton object, only one instance of the singleton is ever given out. This is typically done for objects that are considered “expensive” to create, such as objects that consume a large number of resources or take a significant amount of time to be created.”

To:

“When I started writing this book, there could be only a single instance of WorkflowRuntime per AppDomain. And because the majority of .NET applications use only a single AppDomain, it necessarily followed that you could generally use only a single instance of WorkflowRuntime in your application. Since its release, WF allows more than one WorkflowRuntime instance per AppDomain, but I find the workflow factory I show here to still be a useful tool, if only because you can collect runtime customizations (discussed in later chapters) in one place and have a single place in your code to shut it down. Whenever I hear “use only a single instance,” even though we’re allowed more than one instance in this case, I naturally think of using a combination of the singleton and factory patterns. The singleton pattern, if you’re unfamiliar with patterns, is simply a mechanism for assuring that no matter how many times your application requests instances of the singleton object, only one instance of the singleton is ever given out. This is typically done for objects that are considered “expensive” to create, such as objects that consume a large number of resources or take a significant amount of time to be created.”

Page 36: _waitHandle should be waitHandle
On page 36, in point 6, the underscore in _waitHandle shouldbe be deleted.

Change:

&quot;6. We'll need to create the _waitHandle object&quot;

To:

&quot;6. We'll need to create the waitHandle object&quot;

Page 38: &quot;Create a single instance of Workflow-Runtime per AppDomain&quot; should be &quot;Create an instance of Workflow-Runtime&quot;
On page 38, under &quot;Chapter 2 Quicke Reference&quot;, &quot;Create a single instance of Workflow-Runtime per AppDomain&quot; should be &quot;Create an instance of Workflow-Runtime&quot;.

Change:

“Add a reference to the System.Workflow.Runtime assembly. Create a single instance of Workflow- Runtime per AppDomain, and start the runtime by calling WorkflowRuntime.StartRuntime or by creating a workflow instance.”

To:

“Add a reference to the System.Workflow.Runtime assembly. Create an instance of Workflow- Runtime. Start the runtime by calling WorkflowRuntime.StartRuntime or by creating a workflow instance.”

Page 50: Correction to step 2
On page 50, in step 2, it states:

&quot;2. If we were to compile the application now, WorkflowHost would fail to compile...&quot;

But at this time the code isn't there, it has to be typed in in the next steps. So compiling causes no error.

To fix this, move step 2 down, making it step 5. The current steps 3 – 5 would then become steps 2 – 4.

Page 50: Delete Tip box
On page 50, the text in the Tip box doesn't help. Bacuse it is not possible to select simultanous entries on two tabs. If you change the tab and click OK, the first selected references will not be inserted. Because of this the tip box should be deleted.

Page 61: “class MyClass” should be “class MyClass : DependencyObject”
On page 61, there is correction to the code sample at the top of the page.

Change:

class MyClass

To:

class MyClass : DependencyObject

Page 76: ActivityTrackingPoint should be ActivityTrackPoint
On page 76, in the last paragraph, &quot;ActivityTrackingPoint&quot; should be &quot;ActivityTrackPoint&quot;.

Page 88: GetWorkflowRuntime should be WorkflowRuntime
On page 88, in step 6, GetWorkflowRuntime should be WorkflowRuntime.

Change:

“...following the line of code calling GetWorkflowRuntime.“

To:

“...following the line of code that creates a new instance of WorkflowRuntime.“

Page 89: Delete step 2
On page 89, delete step 2 because the incomplete example file already contains these using-directives.

Delete:

&quot;2. Add the using statements for configuration and workflow tracking to the top of the file: using System.Configuration; using System.Workflow.Runtime.Tracking; &quot;

Page 90: SqlTrackingService should be SqlTrackingQuery
On page 90 in the middle of the page, there is an incorrect class name:

Change:

&quot;The query is performed by SqlTrackingService.TryGetWorkflow.&quot;

To:

&quot;The query is performed by SqlTrackingQuery.TryGetWorkflow.&quot;

Page 92: Add &quot;using System.Workflow.ComponentModel&quot; to step 2
On page 92, in step 2, the &quot;using System.Workflow.ComponentModel&quot; should be added to the code.

Change: using System.Data; using System.Data.SqlClient; using System.Globalization; using System.IO;

To: using System.Data; using System.Data.SqlClient; using System.Globalization; using System.IO; using System.Workflow.ComponentModel;

Page 113: System.Workflow.Activity should be System.Workflow.Activities
On page 113, in step 11, &quot;System.Workflow.Activity&quot; should be &quot;System.Workflow.Activities&quot;.

Page 114: Correction to step 14
On page 114, in step 4,

Change:

&quot;(the method containing the code we added in the preceding step)&quot;

To:

&quot;(the method containing the code we'll add in the next step)&quot;

Page 116: First character of type must be upper-case
On page 116, in step 18, the first character of type must be upper-case.

Change: string conn

To: String conn

Page 122: WorkingStore should be WorkflowStore
On page 122, in step 9, the database name is wrong.

Change:

&quot;This should be enought time to examine the WorkingStore InstanceState database table.&quot;

To:

&quot;This should be enought time to examine the WorkflowStore InstanceState database table.&quot;

Page 123: Correction to script names
On page 123, under &quot;Chapter 6 Quick Reference&quot;, the scripts have the wrong names (remove &quot;workflow&quot; in the names).

Change:

&quot;You'll need to execute both the SqlWorkflowPersistenceService_Schema.sql script and the SqlWorkflowPersistenceService_Logic.sql script.&quot;

To:

&quot;You'll need to execute both the SqlPersistenceService_Schema.sql script and the SqlPersistenceService_Logic.sql script.&quot;

Page 159: First &quot;base constructor&quot; should be &quot;constructor&quot;
On page 159, in the third paragraph, the first reference to &quot;base constructor&quot; should be &quot;constructor&quot;.

Change:

&quot;we must provide a base constructor that accepts the instance ID (a Guid), which in turn passes the instance ID to the base constructor,&quot;

To:

&quot;we must provide a constructor that accepts the instance ID (a Guid), which in turn passes the instance ID to the base constructor,&quot;

Page 162: MVDataconnector.cs should be MVDataConnector.cs
On page 162, at the bottom of the page, the title of Listing 8-3 is incorrect.

Change:

&quot;Listing 8-3 MVDataconnector.cs completed&quot;

To:

&quot;Listing 8-3 MVDataConnector.cs completed&quot;

Page 179: Workflow2.Workflow1 should be Workflow2.Workflow2
On page 179, in step 10, there is an error in the name.

Change:

&quot;(Workflow2.Workflow1 is the fully qualified name)&quot;

To:

&quot;(Workflow2.Workflow2 is the fully qualified name)&quot;

Page 194: Incorrect property name
On page 194, in the Tip box, the property name is incorrect.

Change:

&quot;...response property directly&quot;

To:

&quot;...responses property directly&quot;

Page 200: Method should be Property
On page 200, in Table 9-1, the left column heading is incorrect.

Change:

&quot;Method&quot;

To:

&quot;Property&quot;.

Page 200: Method should be Event
On page 200, in Table 9-2, the left column heading is incorrect.

Change:

&quot;Method&quot;

To:

&quot;Event&quot;.

Page 236: if (_service
null) should be if (value != null) ===

On page 236, in Listing 10-1, there is an error in the code sample.

Change: if (_service == null)

To: if (value != null)

Note: there are two instances of this code, both need to be changed.

Page 264: setlevel1 should be setLevel1
On page 264, in point 29, in line 3, there is an incorrect property name.

Change:

&quot;bound setlevel1’s Level property &quot;

To:

&quot;bound setLevel1’s Level property &quot;

Page 280: Extra bracket in code
On page 280, in the code sample above the heading &quot;Explicit Chaining&quot;, there is an extra bracket in the line of code.

Change: [RuleWrite(&quot;Discount&quot;)]]

To: [RuleWrite(&quot;Discount&quot;)]

Page 286: WorkflowComplete should WorkflowCompleted
On page 286, in point 8, in lines 5 and 6, the event name is incorrect.

Change:

&quot;WorkflowComplete event&quot;

To:

&quot;WorkflowCompleted event&quot;

Page 332: Correction to last paragraph
On page 332, in the last paragraph,

Change:

“This doesn’t affect the workflow, but rather resets the user interface buttons.”

To:

“This causes the application to restart, which reloads the workflow runtime (since we hit a terminal condition, after all) and resets the user interface. (Note that a real soda machine would return to the initial state to wait for another customer, but I wanted to show a terminal state in action.)”

Page 352: DefaultSettings should be DefaultSettingsSection
On page 352, in the last Note box, the settting name is incorrect.

Change:

&quot;System.Transactions.Configuration.DefaultSettings.Timeout&quot;

To:

&quot;System.Transactions.Configuration.DefaultSettingsSection.Timeout&quot;

Page 386: &quot;select Workflow Activity Library&quot; should be &quot;select Workflow&quot;
On page 386, in step 4, there is an error.

Change:

&quot;select Workflow Activity Library&quot;

To:

&quot;select Workflow&quot;

Page 396: CorrelationIntializer should be CorrelationInitializer
On page 396, in the second line from from bottom, the attribute name is missing a letter i.

Change:

&quot;CorrelationIntializer&quot;

To:

&quot;CorrelationInitializer&quot;

Page 432: Shift+F5 should be Ctrl+F5
On page 432, in step 39, the key name is wrong.

Change:

&quot;To execute the application, press Shift+F5&quot;

To:

&quot;To execute the application, press Ctrl+F5&quot;

Page 469: Shift+F5 should be Ctrl+F5
On page 469, in step 8, the key name is wrong.

Change:

&quot;To execute the application, press Shift+F5&quot;

To:

&quot;To execute the application, press Ctrl+F5&quot;

Microsoft Press is committed to providing informative and accurate books. All comments and corrections listed above are ready for inclusion in future printings of this book. If you have a later printing of this book, it may already contain most or all of the above corrections.

Additional query words: 0-7356-2335-X 978-0-7356-2335-4

Keywords: KB935354

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.