<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Ron Jacobs</title><link>http://blogs.msdn.com/rjacobs/default.aspx</link><description>The New WCF / WF Evangelist</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Today on endpoint.tv – Windows Server AppFabric in action</title><link>http://blogs.msdn.com/rjacobs/archive/2009/12/14/today-on-endpoint-tv-windows-server-appfabric-in-action.aspx</link><pubDate>Mon, 14 Dec 2009 19:18:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9936689</guid><dc:creator>ronjacobs</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/rjacobs/comments/9936689.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rjacobs/commentrss.aspx?PostID=9936689</wfw:commentRss><description>&lt;p&gt;Before PDC I went to the Channel 9 studio and recorded an episode of endpoint.tv with Ian and Adam two of the program managers on the AppFabric team.&amp;#160; At the time we were still using the code name “Dublin” because we didn’t know for sure what the official name would be.&amp;#160; I had some trouble getting the video uploaded to the site but it is finally there today.&lt;/p&gt;  &lt;p&gt;Be sure to check it out &lt;a href="http://channel9.msdn.com/shows/Endpoint/endpointtv-Windows-Server-AppFabric-in-action-monitoring-and-troubleshooting/"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9936689" width="1" height="1"&gt;</description></item><item><title>WCF Security Spike – Day 2</title><link>http://blogs.msdn.com/rjacobs/archive/2009/12/04/wcf-security-spike-day-2.aspx</link><pubDate>Fri, 04 Dec 2009 19:47:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9932737</guid><dc:creator>ronjacobs</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/rjacobs/comments/9932737.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rjacobs/commentrss.aspx?PostID=9932737</wfw:commentRss><description>&lt;p&gt;&lt;strong&gt;We learn what he have to learn&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;Does that surprise anyone?&amp;#160; Some people have reacted with shock when I said that I don’t know WCF Security very well.&amp;#160; Others said that I was implying that evangelists are somehow inferior to their colleagues on the product teams.&amp;#160; Of course there are people with varying skills in different roles as a part of any organization.&amp;#160; Technical Evangelists must have deep technical skills just like any other developer.&amp;#160; However, the truth remains that when faced with an overwhelming amount of new technology every day we make choices and learn what we have to learn.&lt;/p&gt;  &lt;p&gt;There are a few people who have taken the time to decipher WCF security.&amp;#160; To this point, I have not been one of them because I have not had to learn it.&amp;#160; The evangelist in me wants to focus on new product features and in the area of security there is nothing new in WCF.&amp;#160; Yet because many customers are struggling with it, I felt that it was time… I must take on the beast so here we go for day 2.&amp;#160; I’m writing these notes as I go so who knows what we will find.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Service Principal Name&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Jesse mentioned to me that I needed to use setspn.exe to create a service principal name.&amp;#160; I immediately went to Bing :-) and searched for &lt;strong&gt;WCF setspn&lt;/strong&gt; which lead me to the WCF Security Guidance wiki page on the application scenario &lt;a href="http://wcfsecurity.codeplex.com/wikipage?title=Intranet%20%u2013%20Web%20to%20Remote%20WCF%20Using%20Transport%20Security%20%28Trusted%20Subsystem%2c%20HTTP%29"&gt;Intranet – Web to Remote WCF Using Transport Security (Trusted Subsystem, HTTP)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This article discusses using setspn when hosting the WCF service in an ASP.NET app pool running under a custom domain account.&amp;#160; In my case the app pool is running under Network Service so I wasn’t sure if I needed it or not but I decided to give it a go so I ran the command&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;C:\&amp;gt;&lt;strong&gt;setspn -A http/rojacobs-vid rojacobs-vid&lt;/strong&gt;       &lt;br /&gt;Registering ServicePrincipalNames for CN=ROJACOBS-VID,OU=Workstations,OU=Machines,DC=redmond,DC=corp,DC=microsoft,DC=com       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; http/rojacobs-vid       &lt;br /&gt;Updated object&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;Test It&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I’ve created a local group on my machine called “ServiceUsers”.&amp;#160; The plan is to add accounts to the “ServiceUsers” group and then use IsInRole to determine if the user is a member of the group.&lt;/p&gt;  &lt;p&gt;The test will be to simply invoke the service with the WCF Test Client using two different accounts.&amp;#160; One test will run it under my domain account &lt;strong&gt;REDMOND\rojacobs&lt;/strong&gt; and the other will run it under a local admin account &lt;strong&gt;ROJACOBS-VID\Ron.&lt;/strong&gt;&amp;#160; Both of these accounts are members of ServiceUsers.&lt;/p&gt;  &lt;p&gt;Here is the code for testing the user accounts.&amp;#160; For now I’m commenting out the PrincipalPermission attribute&lt;/p&gt;  &lt;div&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;//[PrincipalPermission(SecurityAction.Demand, Role = &amp;quot;BUILTIN\\Administrators&amp;quot;)]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; AdminOperation()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #006080"&gt;&amp;quot;IsInRole(\&amp;quot;ServiceUsers\&amp;quot;)={0}&amp;quot;&lt;/span&gt;,&lt;br /&gt;        Thread.CurrentPrincipal.IsInRole(&lt;span style="color: #006080"&gt;&amp;quot;ServiceUsers&amp;quot;&lt;/span&gt;));&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;I’ve setup my project in Visual Studio to host the site in my local IIS as well.&lt;/div&gt;

&lt;div&gt;
  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test #1 – using domain account&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I launch the WCF Test Client and add a service reference to my service by giving it the address of my service.&lt;/p&gt;

&lt;p&gt;After clicking Invoke I see that it works returning the following&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;s:Body&lt;/span&gt; &lt;span style="color: #ff0000"&gt;u:Id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;_0&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;AdminOperationResponse&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://tempuri.org/&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;AdminOperationResult&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;IsInRole(&amp;quot;ServiceUsers&amp;quot;)=True&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;AdminOperationResult&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;AdminOperationResponse&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;s:Body&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;This didn’t work yesterday so I think it was the setspn trick that fixed it.&amp;#160; Just to be sure I delete the spn and try it again&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;C:\&amp;gt;&lt;strong&gt;setspn -d http/rojacobs-vid rojacobs-vid&lt;/strong&gt; 

    &lt;br /&gt;Unregistering ServicePrincipalNames for CN=ROJACOBS-VID,OU=Workstations,OU=Machines,DC=redmond,DC=corp,DC=microsoft,DC=com 

    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; http/rojacobs-vid 

    &lt;br /&gt;Updated object&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Well guess what – it still worked.&amp;#160; Strange, I’m sure this didn’t work yesterday…&amp;#160; Perhaps the reboot overnight did it?&amp;#160; Maybe the effects of setspn are still lingering in the worker process?&amp;#160; &lt;/p&gt;

&lt;p&gt;Just to be sure, I do an &lt;strong&gt;iisreset&lt;/strong&gt; command&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;C:\&amp;gt;&lt;strong&gt;iisreset&lt;/strong&gt; &lt;/p&gt;

  &lt;p&gt;Attempting stop... 
    &lt;br /&gt;Internet services successfully stopped 

    &lt;br /&gt;Attempting start... 

    &lt;br /&gt;Internet services successfully restarted&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now to test it again… still works.&amp;#160; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test #2 – using local admin account&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yesterday no matter what I did, the local admin account would never return true for IsInRole.&amp;#160; Wonder what will happen today?&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;s:Body&lt;/span&gt; &lt;span style="color: #ff0000"&gt;u:Id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;_0&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;AdminOperationResponse&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://tempuri.org/&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;AdminOperationResult&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;IsInRole(&amp;quot;ServiceUsers&amp;quot;)=True&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;AdminOperationResult&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;AdminOperationResponse&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;s:Body&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Doh! I can’t believe it…&amp;#160; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test #3 – using PrincipalPermission&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now I’m going to put PrincipalPermission back and try to get it to allow only users in the ServiceUsers group.&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;[PrincipalPermission(SecurityAction.Demand, Role = &lt;span style="color: #006080"&gt;&amp;quot;ServiceUsers&amp;quot;&lt;/span&gt;)]&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; AdminOperation()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #006080"&gt;&amp;quot;IsInRole(\&amp;quot;ServiceUsers\&amp;quot;)={0}&amp;quot;&lt;/span&gt;,&lt;br /&gt;        Thread.CurrentPrincipal.IsInRole(&lt;span style="color: #006080"&gt;&amp;quot;ServiceUsers&amp;quot;&lt;/span&gt;));&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;I test it from both WCF Test Clients (one under REDMOND\rojacobs and the other running as ROJACOBS-VID\Ron) they both succeed.&amp;#160; &lt;/p&gt;

&lt;p&gt;Now I test it from a third local account (ROJACOBS-VID\Andrew) which is not a member of ServiceUsers – this one should fail.&lt;/p&gt;

&lt;p&gt;Yes! Success – it fails.&lt;/p&gt;

&lt;p&gt;I’m still not sure about this – with things not working yesterday, then working today.&amp;#160; I think I need to reboot and run all the tests again just to be sure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test #4 – After Reboot&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;WCF Test client on the same machine running under domain account works&lt;/p&gt;

&lt;p&gt;WCF Test client on the same machine running under local admin account works&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test #5 – Multiple Machines&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ok great, but I wonder will this work across machines?&amp;#160; &lt;/p&gt;

&lt;p&gt;In order to test this using HTTP I need to enable the firewall rule World Wide Web Services (HTTP Traffic-In)&lt;/p&gt;

&lt;p&gt;Once I enabled all the machines in my home office to see each other (by turning on Network Discovery) I could browse to the service and see the WSDL but then I ran into a problem.&lt;/p&gt;

&lt;p&gt;The WSDL used the full name of my machine rojacobs-vid.redmond.corp.microsoft.com in the URIs.&amp;#160; My other machines in my home office could not resolve this address so the WCF Test Client failed.&lt;/p&gt;

&lt;p&gt;Strange that I can navigate to &lt;a href="http://rojacobs-vid"&gt;http://rojacobs-vid&lt;/a&gt; but not &lt;a href="http://rojacobs-vid.redmond.corp.microsoft.com"&gt;http://rojacobs-vid.redmond.corp.microsoft.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is probably an issue because I’m testing this in my home office.&amp;#160; If I had all these machines physically plugged into the corporate network (rather than via DirectAccess) it might work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Day 2 Spike Summary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What have we learned so far?&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The easy way to restrict access by roles is with Windows Groups with PrincipalPermission demands&lt;/li&gt;

  &lt;li&gt;You can do the PrincipalPermission demand with an attribute or in code&lt;/li&gt;

  &lt;li&gt;You can use a local machine groups&lt;/li&gt;

  &lt;li&gt;You do have to use a binding that supports this Intranet scenario (wsHttpBinding or netTcpBinding.&amp;#160; basicHttpBinding wont’ work) &lt;/li&gt;

  &lt;li&gt;You must enable the firewall ports for inbound and outbound traffic when testing&lt;/li&gt;

  &lt;li&gt;Sometimes things just don’t work until you go home for the day and try again the next day :-)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What have we not figured out?&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;How to test from another machine using the WCF Test Client when it cannot access the machine using the full DNS name (for some strange reason)&lt;/li&gt;

  &lt;li&gt;or how to generate WSDL that does not use the full DNS name of the machine in the URI&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some other things to investigate&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;What about Windows Identity Foundation?&amp;#160; Does this make it easier or harder?&amp;#160; Is it appropriate for this scenario?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next Steps&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Review Windows Identity Foundation Whitepaper&lt;/li&gt;

  &lt;li&gt;Do the Windows Identity Foundation WCF Services hands on lab&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9932737" width="1" height="1"&gt;</description></item><item><title>WCF Security Spike – Day 1</title><link>http://blogs.msdn.com/rjacobs/archive/2009/12/03/wcf-security-spike-day-1.aspx</link><pubDate>Thu, 03 Dec 2009 23:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9932258</guid><dc:creator>ronjacobs</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/rjacobs/comments/9932258.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rjacobs/commentrss.aspx?PostID=9932258</wfw:commentRss><description>&lt;p&gt;My first goal was to secure a service.&amp;#160; I’m happy to say I managed to get a service that allowed one user and didn’t allow another by using a PrincipalPermission with wsHttpBinding (I gave up on netTcpBinding for now – one monster at a time right?)&lt;/p&gt;  &lt;p&gt;I created a simple service and declared a service with an endpoint as you see in the web.config (from .NET 4)&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;services&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;service&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Security&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;endpoint&lt;/span&gt; &lt;span style="color: #ff0000"&gt;address&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;binding&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;wsHttpBinding&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;&amp;quot;&lt;/span&gt;&lt;br /&gt;         &lt;span style="color: #ff0000"&gt;contract&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ISecurity&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;service&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Then I implemented my service with a security demand&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;[PrincipalPermission(SecurityAction.Demand, Role=&lt;span style="color: #006080"&gt;&amp;quot;BUILTIN\\Administrators&amp;quot;&lt;/span&gt;)]&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; AdminOperation()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; GetSecurityInfo(&lt;span style="color: #006080"&gt;&amp;quot;AdminOperation&amp;quot;&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Easy huh? Wait a minute… not so fast.&amp;#160; I started testing this.&lt;/p&gt;

&lt;p&gt;The machine is joined to the REDMOND domain and when I tested using my domain account it worked just fine.&lt;/p&gt;

&lt;p&gt;However when I fired up the WCF Test Client using a local machine account that is a member of the Administrators group I get “Access Denied”.&lt;/p&gt;

&lt;p&gt;In fact, if I allow the call and then test for role membership using IsInRole(“SomeGroup”) with any local group, all of them returned false.&amp;#160; The only time I got IsInRole(“Administrators”) to return true was when I used my domain account to call the service.&lt;/p&gt;

&lt;p&gt;Oh the mysterious ways of Active Directory…&amp;#160; Who can plumb the depths of kerberos?&amp;#160; Perhaps I could (&lt;em&gt;should?&lt;/em&gt;) look at Windows Identity Foundation for help…&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9932258" width="1" height="1"&gt;</description></item><item><title>WCF Security Is Hard</title><link>http://blogs.msdn.com/rjacobs/archive/2009/12/03/wcf-security-is-hard.aspx</link><pubDate>Thu, 03 Dec 2009 18:53:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9932115</guid><dc:creator>ronjacobs</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/rjacobs/comments/9932115.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rjacobs/commentrss.aspx?PostID=9932115</wfw:commentRss><description>&lt;p&gt;Ok… I said it.&amp;#160; Let’s just admit the truth for a second.&amp;#160; It is hard.&amp;#160; Recently somebody contacted me about a security problem and asked for me help.&amp;#160; I’m probably the wrong guy to ask.&amp;#160; After all, I’m an evangelist.&amp;#160; That means I create demos, labs etc. none of which use security (typically).&amp;#160; What that means is that while I know a great deal about some aspects of WCF when it comes to security I actually don’t know much.&amp;#160; I know, I know… it’s embarrassing.&lt;/p&gt;  &lt;p&gt;My new years resolution for 2010 is to write some articles, samples and create some videos to help you deal with security.&amp;#160; After all it is vital that we help you to get this right.&amp;#160; I’m tired of waiting for somebody else to fix this.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;strong&gt;[edit: 12/4] &lt;/strong&gt;&lt;/em&gt;By this comment I don’t mean to say that all evangelists are less technically competent that any other programmer.&amp;#160; I work with some very smart guys who are great developers.&amp;#160; I only meant to imply that we tend to learn things that our work requires and mine doesn’t require security very often&lt;/p&gt;  &lt;h2&gt;My First Spike&lt;/h2&gt;  &lt;p&gt;Here is the first security spike.&amp;#160; I’m going to create a WCF service hosted in IIS.&amp;#160; The service will use wsHttpBinding and Windows Credentials.&amp;#160; The goal is to restrict access by role as defined by group membership in active directory.&amp;#160; This should be a no-brainer right?&lt;/p&gt;  &lt;p&gt;Yesterday I searched around looking for resources to help.&amp;#160; I didn’t find much.&amp;#160; Most things I found showed how to secure self-hosted WCF services with console apps.&amp;#160; The security picture with an IIS hosted service is significantly more complex.&amp;#160; You have IIS settings to deal with, plus ASP.NET stuff in web.config and then the myriad of WCF security settings and options.&lt;/p&gt;  &lt;p&gt;I have often referred people to the WCF Security Guide from patterns and practices which is good but even after reading it I found myself confused.&lt;/p&gt;  &lt;p&gt;My first attempt yesterday was to create a service hosted in IIS and then to use netTcpBinding as recommended by the WCF Security Guide to access it.&amp;#160; I didn’t get very far.&amp;#160; Once I hosted the service in IIS I was not able to access it with the netTcpBinding from the client.&amp;#160; I kept getting one of those “machine actively refused the connection” messages.&lt;/p&gt;  &lt;p&gt;Today I’m going to go with the wsHttpBinding so I can simplify things a bit.&amp;#160; I’ll let you know how it goes.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9932115" width="1" height="1"&gt;</description></item><item><title>Where can I get the Workflow Services Lab?</title><link>http://blogs.msdn.com/rjacobs/archive/2009/12/02/where-can-i-get-the-workflow-services-lab.aspx</link><pubDate>Wed, 02 Dec 2009 13:46:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9931397</guid><dc:creator>ronjacobs</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/rjacobs/comments/9931397.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rjacobs/commentrss.aspx?PostID=9931397</wfw:commentRss><description>&lt;p&gt;If you saw the walkthrough of the Workflow Services lab on Channel 9 you might be wondering where you can get the lab code.&amp;#160; This lab will be in the next update of the VS2010 training kit.&amp;#160; Until then I’ve posted a beta version of the lab &lt;a href="http://cid-aabe83468d120033.skydrive.live.com/self.aspx/PDC09%20HOL/IntroToWFServices-Beta2.04.zip"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9931397" width="1" height="1"&gt;</description></item><item><title>How do I clear my AppFabric Databases?</title><link>http://blogs.msdn.com/rjacobs/archive/2009/11/24/how-do-i-clear-my-appfabric-databases.aspx</link><pubDate>Tue, 24 Nov 2009 18:48:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9928159</guid><dc:creator>ronjacobs</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/rjacobs/comments/9928159.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rjacobs/commentrss.aspx?PostID=9928159</wfw:commentRss><description>&lt;p&gt;Once you start to develop apps with Windows Server App Fabric you will quickly find that your AppFabric monitoring and persistence databases become cluttered with stuff.&amp;#160; From time to time you will want to clear out these databases.&lt;/p&gt;  &lt;p&gt;Here is the PowerShell script I use to get the job done.&amp;#160; Just copy these into a file like AppFabricReset.ps1&lt;/p&gt;  &lt;p&gt;(Watch out for line breaks)&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div id="codeSnippet" class="csharpcode"&gt;     &lt;pre class="alt"&gt;# Bring in the App Fabric module&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre class="alteven"&gt;import-module applicationserver&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre class="alteven"&gt;$ConfirmPreference = &amp;quot;None&amp;quot;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre class="alteven"&gt;# Remove the persistence db&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre class="alt"&gt;Remove-ASPersistenceDatabase -Force -Server &amp;quot;.\SQLExpress&amp;quot; -Database &amp;quot;ApplicationServerExtensions&amp;quot; -Confirm:$false&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre class="alt"&gt;# Create the persistence DB&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre class="alteven"&gt;Initialize-ASPersistenceDatabase -Admins $env:computername\AS_Administrators -Readers $env:computername\AS_Observers -Users &amp;quot;BUILTIN\IIS_IUSRS&amp;quot; -Database &amp;quot;ApplicationServerExtensions&amp;quot; &lt;br /&gt;-Server &amp;quot;.\SQLExpress&amp;quot; -Confirm:$false&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre class="alteven"&gt;# Clear the monitoring DB&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre class="alt"&gt;Clear-ASMonitoringDatabase -Database &amp;quot;ApplicationServerExtensions&amp;quot; -Server &amp;quot;.\SQLExpress&amp;quot; -Confirm:$false&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9928159" width="1" height="1"&gt;</description></item><item><title>WF4: How To Access Out Arguments</title><link>http://blogs.msdn.com/rjacobs/archive/2009/09/24/wf4-how-to-access-out-arguments.aspx</link><pubDate>Fri, 25 Sep 2009 01:12:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9899184</guid><dc:creator>ronjacobs</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/rjacobs/comments/9899184.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rjacobs/commentrss.aspx?PostID=9899184</wfw:commentRss><description>&lt;p&gt;To get a value from your workflow you must access the dictionary of output arguments returned from the workflow.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: This example is based on Visual Studio 2010 Beta 2&lt;/p&gt;  &lt;p&gt;Consider a workflow that accepts two arguments&lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="2" width="400"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="133"&gt;&lt;strong&gt;Name&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;&lt;strong&gt;Direction&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;&lt;strong&gt;Argument Type&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;UserName&lt;/td&gt;        &lt;td valign="top" width="133"&gt;In&lt;/td&gt;        &lt;td valign="top" width="133"&gt;String&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;Greeting&lt;/td&gt;        &lt;td valign="top" width="133"&gt;Out&lt;/td&gt;        &lt;td valign="top" width="133"&gt;String&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;The workflow uses an assign activity to set the result of the expression &lt;b&gt;&lt;i&gt;&amp;quot;Hello &amp;quot; &amp;amp; UserName &amp;amp; &amp;quot; from Workflow 4&amp;quot;&lt;/i&gt;&lt;/b&gt; to the Greeting out argument.&amp;#160; The hosting program can access the Greeting out argument from the dictionary of output values returned from the &lt;b&gt;WorkflowInvoker&lt;/b&gt; or &lt;b&gt;WorkflowApplication&lt;/b&gt;.&lt;/p&gt;  &lt;p&gt;Because the values in the output dictionary are stored as objects with a string as the key, there are three possible outcomes when you try to access an argument value.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;The key does not exist in the dictionary &lt;/li&gt;    &lt;li&gt;The key exists but the type of the value is not what you expected &lt;/li&gt;    &lt;li&gt;The key exists and the type is compatible with what you expected &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Whenever you access an out argument you must consider these outcomes. In the event that the key does not exist or the type of the value is not what is expected you may encounter a &lt;b&gt;KeyNotFoundException&lt;/b&gt; or &lt;b&gt;InvalidCastException&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;You can choose to &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Let these exceptions propagate possibly terminating the host with an unhandled exception &lt;/li&gt;    &lt;li&gt;Catch the exceptions &lt;/li&gt;    &lt;li&gt;Code defensively using &lt;strong&gt;TryGetValue&lt;/strong&gt; to access the key from the collection or the C# keyword “&lt;strong&gt;as&lt;/strong&gt;” or VB function &lt;strong&gt;TryCast&lt;/strong&gt; to avoid the invalid cast       &lt;p&gt;&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;h1&gt;Accessing Out Arguments with WorkflowInvoker&lt;/h1&gt;  &lt;p&gt;The following example shows a method that Invokes the SayHello workflow passing in the UserName and accessing the out argument named “Greeting” after the workflow completes.&amp;#160; &lt;/p&gt;  &lt;div&gt;   &lt;p class="noteStyle"&gt;&lt;strong&gt;Watch Out&lt;/strong&gt;      &lt;br /&gt;This example is not coding defensively or catching exceptions so if the key did not exist or the type of the value was not compatible the exception would propagate to the caller. &lt;/p&gt; &lt;/div&gt;  &lt;h2&gt;C#&lt;/h2&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; GetArgumentsFromWorkflowInvoker()&lt;br /&gt;{&lt;br /&gt;    IDictionary&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;object&lt;/span&gt;&amp;gt; output = WorkflowInvoker.Invoke(&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SayHello() { UserName = &lt;span style="color: #006080"&gt;&amp;quot;Test&amp;quot;&lt;/span&gt; });&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; greeting = (&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;)output[&lt;span style="color: #006080"&gt;&amp;quot;Greeting&amp;quot;&lt;/span&gt;];&lt;br /&gt;&lt;br /&gt;    Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;WorkflowInvoker said {0}&amp;quot;&lt;/span&gt;, greeting);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;h2&gt;Visual Basic&lt;/h2&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; GetArgumentsFromWorkflowInvoker()&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; output &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; IDictionary(Of &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;) =&lt;br /&gt;        WorkflowInvoker.Invoke(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; SayHello() &lt;span style="color: #0000ff"&gt;With&lt;/span&gt; {.UserName = &lt;span style="color: #006080"&gt;&amp;quot;Test&amp;quot;&lt;/span&gt;})&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; greeting &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt; = output(&lt;span style="color: #006080"&gt;&amp;quot;Greeting&amp;quot;&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;    Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;WorkflowInvoker said {0}&amp;quot;&lt;/span&gt;, greeting)&lt;br /&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;h1&gt;Accessing Out Arguments with WorkflowApplication&lt;/h1&gt;

&lt;p&gt;WorkflowApplication invokes the workflow on a thread from the CLR threadpool. To capture the outputs you must assign a delegate to the WorkflowApplication.Completed property. Keep in mind that your delegate is called whenever the workflow completes successfully or not. You can check the CompletionState property to find out if the activity closed or faulted. Because accessing the Outputs dictionary may result in an exception you should wrap the access with a try/catch/finally block as shown.&lt;/p&gt;

&lt;h2&gt;C#&lt;/h2&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; GetArgumentsFromWorkflowApplication()&lt;br /&gt;{&lt;br /&gt;    AutoResetEvent sync = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AutoResetEvent(&lt;span style="color: #0000ff"&gt;false&lt;/span&gt;);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; greeting = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;br /&gt;    Exception argException = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    WorkflowApplication wfApp = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; WorkflowApplication(&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SayHello()&lt;br /&gt;        {&lt;br /&gt;            UserName = &lt;span style="color: #006080"&gt;&amp;quot;Test&amp;quot;&lt;/span&gt;&lt;br /&gt;        });&lt;br /&gt;&lt;br /&gt;    wfApp.Completed = (e) =&amp;gt;&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: #008000"&gt;// Did the workflow complete without error?&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (e.CompletionState == ActivityInstanceState.Closed)&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: #0000ff"&gt;try&lt;/span&gt;&lt;br /&gt;                {&lt;br /&gt;                    &lt;span style="color: #008000"&gt;// Accessing the output arguments dictionary&lt;/span&gt;&lt;br /&gt;                    &lt;span style="color: #008000"&gt;// might throw a KeyNotFoundException or&lt;/span&gt;&lt;br /&gt;                    &lt;span style="color: #008000"&gt;// InvalidCastException                            &lt;/span&gt;&lt;br /&gt;                    greeting = (&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;)e.Outputs[&lt;span style="color: #006080"&gt;&amp;quot;Greeting&amp;quot;&lt;/span&gt;];&lt;br /&gt;                }&lt;br /&gt;                &lt;span style="color: #0000ff"&gt;catch&lt;/span&gt; (Exception ex)&lt;br /&gt;                {&lt;br /&gt;                    argException = ex;&lt;br /&gt;                }&lt;br /&gt;                &lt;span style="color: #0000ff"&gt;finally&lt;/span&gt;&lt;br /&gt;                {&lt;br /&gt;                    &lt;span style="color: #008000"&gt;// Must be sure to unblock the main thread&lt;/span&gt;&lt;br /&gt;                    sync.Set();&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        };&lt;br /&gt;&lt;br /&gt;    wfApp.Run();&lt;br /&gt;    sync.WaitOne();&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// Show the exception from the background thread&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (argException != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;br /&gt;        Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;WorkflowApplication error {0}&amp;quot;&lt;/span&gt;, argException.Message);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;br /&gt;        Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;WorkflowApplication said {0}&amp;quot;&lt;/span&gt;, greeting);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;h2&gt;Visual Basic&lt;/h2&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; GetArgumentsFromWorkflowApplication()&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; sync &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; AutoResetEvent = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AutoResetEvent(&lt;span style="color: #0000ff"&gt;False&lt;/span&gt;)&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; greeting &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; argException &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Exception = &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; wfApp &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; WorkflowApplication =&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; WorkflowApplication(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; SayHello() &lt;span style="color: #0000ff"&gt;With&lt;/span&gt; {.UserName = &lt;span style="color: #006080"&gt;&amp;quot;Test&amp;quot;&lt;/span&gt;})&lt;br /&gt;&lt;br /&gt;    wfApp.Completed = &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;(args)&lt;br /&gt;                          &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; (args.CompletionState = &lt;br /&gt;                                         ActivityInstanceState.Closed) &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;                              &lt;span style="color: #0000ff"&gt;Try&lt;/span&gt;&lt;br /&gt;                                  &lt;span style="color: #008000"&gt;' Accessing the output arguments dictionary&lt;/span&gt;&lt;br /&gt;                                  &lt;span style="color: #008000"&gt;' might throw a KeyNotFoundException or&lt;/span&gt;&lt;br /&gt;                                  &lt;span style="color: #008000"&gt;' InvalidCastException                            &lt;/span&gt;&lt;br /&gt;                                  greeting = args.Outputs(&lt;span style="color: #006080"&gt;&amp;quot;Greeting&amp;quot;&lt;/span&gt;)&lt;br /&gt;                              &lt;span style="color: #0000ff"&gt;Catch&lt;/span&gt; ex &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Exception&lt;br /&gt;                                  argException = ex&lt;br /&gt;                              &lt;span style="color: #0000ff"&gt;Finally&lt;/span&gt;&lt;br /&gt;                                  &lt;span style="color: #008000"&gt;' Must be sure to unblock the main thread&lt;/span&gt;&lt;br /&gt;                                  sync.&lt;span style="color: #0000ff"&gt;Set&lt;/span&gt;()&lt;br /&gt;                              &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Try&lt;/span&gt;&lt;br /&gt;                          &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;                          &lt;span style="color: #008000"&gt;' VB requires lambda expressions to return a value&lt;/span&gt;&lt;br /&gt;                          &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt;&lt;br /&gt;                      &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    wfApp.Run()&lt;br /&gt;    sync.WaitOne()&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;' Show the exception from the background thread&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; (argException &lt;span style="color: #0000ff"&gt;Is&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;        Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;WorkflowApplication said {0}&amp;quot;&lt;/span&gt;, greeting)&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;br /&gt;        Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;WorkflowApplication error {0}&amp;quot;&lt;/span&gt;, argException.Message)&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;h1&gt;Accessing Out Arguments with Defensive Coding Style&lt;/h1&gt;

&lt;p&gt;In this example, we are accessing the Out Argument with a defensive coding style that will insure no exceptions are thrown.&lt;/p&gt;

&lt;div&gt;
  &lt;p class="noteStyle"&gt;&lt;b&gt;ContainsKey()&lt;/b&gt; vs. &lt;b&gt;TryGet()&lt;/b&gt;

    &lt;br /&gt;You should use TryGet instead of ContainsKey() to first check for the key and then Get() to access the key. The reason for this is that you will iterate over the collection twice, once to determine if the key is present and again to access the value.&lt;/p&gt;
&lt;/div&gt;

&lt;h2&gt;C#&lt;/h2&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; GetArgumentsFromWorkflowInvokerDefensive()&lt;br /&gt;{&lt;br /&gt;    IDictionary&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;object&lt;/span&gt;&amp;gt; output = WorkflowInvoker.Invoke(&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SayHello() { UserName = &lt;span style="color: #006080"&gt;&amp;quot;Test&amp;quot;&lt;/span&gt; });&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; obj = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; greeting = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (!output.TryGetValue(&lt;span style="color: #006080"&gt;&amp;quot;Greeting&amp;quot;&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; obj))&lt;br /&gt;    {&lt;br /&gt;        Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;Greeting not found&amp;quot;&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;br /&gt;    {&lt;br /&gt;        greeting = obj &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (greeting == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;br /&gt;            Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;Greeting could not be converted to a string&amp;quot;&lt;/span&gt;);&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;br /&gt;            Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;WorkflowInvoker said {0}&amp;quot;&lt;/span&gt;, greeting);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;h2&gt;Visual Basic&lt;/h2&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; GetArgumentsFromWorkflowInvokerDefensive()&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; output &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; IDictionary(Of &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;) =&lt;br /&gt;        WorkflowInvoker.Invoke(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; SayHello() &lt;span style="color: #0000ff"&gt;With&lt;/span&gt; {.UserName = &lt;span style="color: #006080"&gt;&amp;quot;Test&amp;quot;&lt;/span&gt;})&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; obj &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; greeting &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;' TryGetValue will not throw an exception&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; output.TryGetValue(&lt;span style="color: #006080"&gt;&amp;quot;Greeting&amp;quot;&lt;/span&gt;, obj)) &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;        Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;Greeting not found&amp;quot;&lt;/span&gt;)&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #008000"&gt;' Not sure what type it is, try to convert it&lt;/span&gt;&lt;br /&gt;        greeting = &lt;span style="color: #0000ff"&gt;TryCast&lt;/span&gt;(obj, &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; (greeting &lt;span style="color: #0000ff"&gt;Is&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;            Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;Greeting could not be converted to a string&amp;quot;&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;br /&gt;            Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;WorkflowInvoker said {0}&amp;quot;&lt;/span&gt;, greeting)&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9899184" width="1" height="1"&gt;</description></item><item><title>WF4: Passing Arguments to Activities</title><link>http://blogs.msdn.com/rjacobs/archive/2009/09/14/wf4-passing-arguments-to-activities.aspx</link><pubDate>Tue, 15 Sep 2009 03:49:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9895202</guid><dc:creator>ronjacobs</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/rjacobs/comments/9895202.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rjacobs/commentrss.aspx?PostID=9895202</wfw:commentRss><description>&lt;p&gt;In Windows Workflow Foundation .NET 4 (WF4) everything is an &lt;em&gt;Activity&lt;/em&gt;.&amp;#160; That is a class that inherits from System.Activities.Activity.&amp;#160; Activities can have in, out or in/out arguments and do their work then the &lt;strong&gt;Activity.Execute&lt;/strong&gt;() method is called.&amp;#160; You could think of them as being similar to a static method except for the fact that a static method can have only 1 return argument where an Activity can have more than one.&amp;#160; &lt;/p&gt;  &lt;p&gt;Passing arguments to an activity can be done one of two ways.&amp;#160; You can use Initialization syntax when creating the activity to set the input arguments (which are just public properties of type InArgument&amp;lt;T&amp;gt;) or you can pass a Dictionary&amp;lt;string, object&amp;gt; which will be used to initialize the arguments.&lt;/p&gt;  &lt;h2&gt;Passing Arguments with Initialization syntax&lt;/h2&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; [TestMethod]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ShouldReturnGreetingWithName()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     var output = WorkflowInvoker.Invoke(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SayHello()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;             UserName = &lt;span style="color: #006080"&gt;&amp;quot;Test&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;         });&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;     Assert.AreEqual(&lt;span style="color: #006080"&gt;&amp;quot;Hello Test from Workflow 4&amp;quot;&lt;/span&gt;, output[&lt;span style="color: #006080"&gt;&amp;quot;Greeting&amp;quot;&lt;/span&gt;]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This works well except that out arguments (OutArgument&amp;lt;T&amp;gt;) will also show up in the Intellisense window as well as other public properties such as the DisplayName.&amp;#160; In this example from the beta 2 release of the “Introduction to Workflow 4” hands on lab (look for it at the PDC) you will see three properties from Intellisense but only one of them is an in argument suitable for initialization.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/WF4TestingActivityInterfaces_F605/OutArg_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="OutArg" border="0" alt="OutArg" src="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/WF4TestingActivityInterfaces_F605/OutArg_thumb.png" width="470" height="216" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;As you can see initializing an OutArgument looks possible, but if you try it… &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/WF4TestingActivityInterfaces_F605/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/WF4TestingActivityInterfaces_F605/image_thumb_1.png" width="728" height="266" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;What’s going on here?&amp;#160; InArgument&amp;lt;T&amp;gt; will implicitly construct from an argument of type &lt;em&gt;T&lt;/em&gt; but OutArgument&amp;lt;T&amp;gt; won’t do this so even though it appears like you can do this, you can’t because it won’t compile.&amp;#160; But this is a good thing because you shouldn’t initialize an OutArgument anyway.&lt;/p&gt;

&lt;p&gt;In practice, I think most people will wrap activity initialization and (possibly) invocation inside of other methods so that developers who are unfamiliar with workflow can just call those methods to do the work.&amp;#160; &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9895202" width="1" height="1"&gt;</description></item><item><title>WCF Essentials – Great Stuff now online</title><link>http://blogs.msdn.com/rjacobs/archive/2009/09/10/wcf-essentials-great-stuff-now-online.aspx</link><pubDate>Thu, 10 Sep 2009 21:47:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9893804</guid><dc:creator>ronjacobs</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/rjacobs/comments/9893804.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rjacobs/commentrss.aspx?PostID=9893804</wfw:commentRss><description>&lt;p&gt;&lt;a href="http://www.dasblonde.net/"&gt;Michelle Leroux Bustamante&lt;/a&gt; has written some great new papers for MSDN that you really should check out.&amp;#160; They are in the &lt;a href="http://msdn.microsoft.com/en-us/library/ee354181.aspx"&gt;WCF Essentials&lt;/a&gt; series.&lt;/p&gt;  &lt;p&gt;What I like the most about these articles is that she gives really great practical advice.&amp;#160; For example check out this sentence from &lt;a href="http://msdn.microsoft.com/en-us/library/ee354180.aspx"&gt;Getting Started with WCF&lt;/a&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;“The default is &lt;strong&gt;PerSession&lt;/strong&gt; which is typically not the desired setting.”&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Wow – you won’t read that in the MSDN documentation about the &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.instancecontextmode.aspx"&gt;InstanceContextMode Enumeration&lt;/a&gt; but it is probably something that you should know.&amp;#160; It is the kind of advice you can expect from a seasoned WCF developer.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Are you doing WCF Services or SOA in your organization?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;If so, I’d like to talk with you about your solution as a part of some research we are doing for future releases.&amp;#160; Please contact me through my blog if you would be willing to have a short phone discussion with me about your solution and needs. &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9893804" width="1" height="1"&gt;</description></item><item><title>Testing a SendMail activity with WF4</title><link>http://blogs.msdn.com/rjacobs/archive/2009/09/01/testing-a-sendmail-activity-with-wf4.aspx</link><pubDate>Tue, 01 Sep 2009 21:00:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9889990</guid><dc:creator>ronjacobs</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/rjacobs/comments/9889990.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rjacobs/commentrss.aspx?PostID=9889990</wfw:commentRss><description>&lt;p&gt;Many applications send email.&amp;#160; After all it is the preferred binding for async app to human communication.&amp;#160; I noticed that many of my colleagues were creating samples that simulate email by dropping a text file into a directory.&amp;#160; Then they would open the file and copy and paste a GUID into a form.&amp;#160; There is a much better way of course.&amp;#160; In the real world people would send an HTML mail with a link that brings you back to the website with the GUID in place.&lt;/p&gt;  &lt;p&gt;Nearly everyone has done this with a web site where you register with the site, they send you an email to confirm and then you click a link in the email to complete the registration process.&amp;#160; I decided to build out this scenario using a workflow to manage the registration process but then I ran into the issue of how to test the email.&lt;/p&gt;  &lt;p&gt;At first I thought I would just use Hotmail.&amp;#160; This would work for a demonstration but you have to have network connectivity and verifying that the message arrived would require coding to open the mailbox with POP3 and look for a particular message.&amp;#160; Then I found an easier way.&amp;#160; You can configure the SmtpClient to drop mail messages into a folder rather than send them.&lt;/p&gt;  &lt;p&gt;Of course, many of you will say “Duh! I can’t believe Ron didn’t know about this…”.&amp;#160; Well it was news to me so I’m sure that some people didn’t know about it either so here is how it works.&lt;/p&gt;  &lt;p&gt;First off, here is the very simple SendMail activity (using .NET 4 Beta 1)&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; SendMail : CodeActivity&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; InArgument&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&amp;gt; From { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; InArgument&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&amp;gt; Recipients { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; InArgument&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&amp;gt; Subject { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; InArgument&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&amp;gt; Body { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; InArgument&amp;lt;&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt;&amp;gt; IsBodyHtml { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Execute(CodeActivityContext context)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;         SmtpClient client = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SmtpClient();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;         MailMessage message = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MailMessage(From.Get(context),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;             Recipients.Get(context), Subject.Get(context), Body.Get(context));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;         message.IsBodyHtml = IsBodyHtml.Get(context);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;         client.Send(message);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Now I want to test my SendMail class.&amp;#160; So I created a Unit Test project and added an app.config file with the necessary configuration magic.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #800000"&gt;xml&lt;/span&gt; &lt;span style="color: #ff0000"&gt;version&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;encoding&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; ?&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;configuration&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;   &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;system.net&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;mailSettings&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;       &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;smtp&lt;/span&gt; &lt;span style="color: #ff0000"&gt;deliveryMethod&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;SpecifiedPickupDirectory&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;specifiedPickupDirectory&lt;/span&gt; &lt;span style="color: #ff0000"&gt;pickupDirectoryLocation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;c:\maildrop&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;       &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;smtp&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;mailSettings&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;   &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;system.net&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;configuration&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Now all that I need to do is write the test.&amp;#160; I want to be sure that when I send a mail that a file ends up in the c:\maildrop directory.&amp;#160; The file will have a random GUID as the name.&amp;#160; I’m not worried about reading the file to be sure that it contains the correct text.&amp;#160; That would be testing the SmtpClient class which I assume works properly.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; [TestMethod]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; [DeploymentItem(&lt;span style="color: #006080"&gt;&amp;quot;MyActivities.dll&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ShouldSendMail()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;     &lt;span style="color: #008000"&gt;// Remove all files from the drop location&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (Directory.Exists(mailDrop))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;         Directory.Delete(mailDrop, &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;     Directory.CreateDirectory(mailDrop);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;     &lt;span style="color: #008000"&gt;// Create and send the message&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;     WorkflowInvoker.Invoke(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MyActivities.SendMail()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;         From = &lt;span style="color: #006080"&gt;&amp;quot;test@tempuri.org&amp;quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;         Recipients = &lt;span style="color: #006080"&gt;&amp;quot;foo@bar.org, baz@foo.com&amp;quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;         Subject = &lt;span style="color: #006080"&gt;&amp;quot;Test HTML message&amp;quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;         IsBodyHtml = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;         Body = messageBody&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;     });&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;     &lt;span style="color: #008000"&gt;// Find the message in the drop location&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;     var messages = Directory.EnumerateFiles(mailDrop);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt;     Assert.AreEqual(1, messages.Count());&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum24"&gt;  24:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;And the really cool thing is that you can open this file with Windows Live Mail and click the link if you want to demonstrate how it works.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/TestingaSendMailactivitywithWF4_9AC6/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/TestingaSendMailactivitywithWF4_9AC6/image_thumb.png" width="244" height="126" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I decided to screencast this code check it out 
  &lt;br /&gt;&lt;a href="http://channel9.msdn.com/shows/Endpoint/endpointtv-Screencast-Spike-on-Workflow-Managed-Email-Verification/"&gt;endpoint.tv Screencast - Spike on Workflow Managed Email Verification&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9889990" width="1" height="1"&gt;</description></item><item><title>Windows Workflow in .NET 4 and Web Services</title><link>http://blogs.msdn.com/rjacobs/archive/2009/07/29/windows-workflow-in-net-4-and-web-services.aspx</link><pubDate>Wed, 29 Jul 2009 23:33:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9852512</guid><dc:creator>ronjacobs</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/rjacobs/comments/9852512.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rjacobs/commentrss.aspx?PostID=9852512</wfw:commentRss><description>&lt;p&gt;Today I published &lt;a href="http://channel9.msdn.com/shows/10-4/10-4-episode-29-Workflow-Web-Services/"&gt;10-4 episode 29: Workflow Web Services&lt;/a&gt; on our &lt;a href="http://channel9.msdn.com/shows/10-4/"&gt;Channel 9 10-4 Show&lt;/a&gt; about Workflow Services in .NET 4 beta 1.&amp;#160; &lt;/p&gt;  &lt;p&gt;People have asked me why they would want to implement a web service with a workflow rather than with code using WCF.&amp;#160; It is a valid question.&amp;#160; Over the next few blog posts I’ll describe some of the reasons why I find workflows a very interesting solution for implementing web services.&lt;/p&gt;  &lt;h2&gt;Workflows are a simple way to implement web services&lt;/h2&gt;  &lt;p&gt;Remember the ABC’s of web services with WCF?&amp;#160; Every service has an Address, Binding and Contract right?&amp;#160; Well it turns out that this isn’t as simple as it sounds.&amp;#160; With Workflow services I don’t have to bother so much with the ABC’s.&amp;#160; Instead I can focus on a declarative model where I simply create a variable of some type that I want to receive and put it into a receive shape.&lt;/p&gt;  &lt;p&gt;Here is a screenshot of a Declarative Sequential Workflow Service in Visual Studio 2010 Beta 1.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/WindowsWorkflowin.NET4andWebServices_AF85/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/WindowsWorkflowin.NET4andWebServices_AF85/image_thumb.png" width="602" height="638" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This picture is a visualization of XAML that describes a contract.&amp;#160; And what is the contract?&amp;#160; You can see it from the WCF Test Client&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/WindowsWorkflowin.NET4andWebServices_AF85/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/WindowsWorkflowin.NET4andWebServices_AF85/image_thumb_1.png" width="312" height="173" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Ok – so the name is a bit ugly but it is just a property of the receive activity easy to change.&amp;#160; I have a contract with a method named GetData.&amp;#160; And what does the GetData method use as an argument?&amp;#160; The value is an Int32, of course because this is a web service message the value might not be included so the WCF Test Client now allows me to use a Nullable&amp;lt;Int32&amp;gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/WindowsWorkflowin.NET4andWebServices_AF85/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/WindowsWorkflowin.NET4andWebServices_AF85/image_thumb_2.png" width="522" height="148" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;And the workflow definition is just a XAMLX file that I can drop on the web server (along with any assemblies it uses) and have a complete working service.&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Service&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/netfx/2009/xaml/servicemodel&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns:d&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;clr-namespace:DeclarativeSequentialServiceLibrary1;assembly=DeclarativeSequentialServiceLibrary1&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns:p&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/netfx/2009/xaml/activities&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns:sad&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;clr-namespace:System.Activities.Debugger;assembly=System.Activities&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns:x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt;   &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;WorkflowServiceImplementation&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ConfigurationName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Service1&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Service1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;p:Sequence&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Sequential Service&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;sad:XamlDebuggerXmlReader&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;FileName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;c:\scratch\DeclarativeSequentialServiceLibrary1\DeclarativeSequentialServiceLibrary1\Service1.xamlx&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;       &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;p:Sequence.Variables&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;p:Variable&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:TypeArguments&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;CorrelationHandle&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;handle&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;p:Variable&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:TypeArguments&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;x:Int32&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;data&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;       &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;p:Sequence.Variables&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;       &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Receive&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;__ReferenceID0&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;CanCreateInstance&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;True&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ReceiveRequest&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;OperationName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;GetData&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ServiceContractName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Contract1&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ValueType&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;x:Int32&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Receive.AdditionalCorrelations&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;           &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;p:InArgument&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:TypeArguments&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;CorrelationHandle&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Key&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ChannelBasedCorrelation&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;[handle]&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;p:InArgument&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Receive.AdditionalCorrelations&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Receive.KnownTypes&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;           &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;x:Type&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Type&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;x:Int32&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Receive.KnownTypes&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;p:OutArgument&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:TypeArguments&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;x:Int32&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;[data]&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;p:OutArgument&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;       &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Receive&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;       &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;d:TraceActivity&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Message&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;[String.Format(&amp;amp;quot;Received data {0}&amp;amp;quot;, data)]&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;       &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;SendReply&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Request&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{x:Reference __ReferenceID0}&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;SendResponse&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ValueType&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;x:String&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;p:InArgument&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:TypeArguments&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;x:String&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;[data.ToString()]&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;p:InArgument&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;       &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;SendReply&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;p:Sequence&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;   &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;WorkflowServiceImplementation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Service&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This is a pretty cool way to declare a service.&amp;#160; If I want to get a little more complex, I can create a type that is received with multiple properties and such.&amp;#160; This is exactly what we are doing in the Introduction to Workflow Services lab from the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=752CB725-969B-4732-A383-ED5740F02E93&amp;amp;displaylang=en"&gt;Visual Studio 2010 Training Kit&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9852512" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rjacobs/archive/tags/WF4/default.aspx">WF4</category><category domain="http://blogs.msdn.com/rjacobs/archive/tags/WCF4/default.aspx">WCF4</category></item><item><title>Another reason I love Windows 7 - The Network Troubleshooter</title><link>http://blogs.msdn.com/rjacobs/archive/2009/07/28/another-reason-i-love-windows-7-the-network-troubleshooter.aspx</link><pubDate>Tue, 28 Jul 2009 19:46:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9851148</guid><dc:creator>ronjacobs</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/rjacobs/comments/9851148.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rjacobs/commentrss.aspx?PostID=9851148</wfw:commentRss><description>&lt;p&gt;After installing the RTM release of Windows 7 I dropped by the office this morning and when I put the laptop on the docking station I fired up the web browser and got… nothing.&amp;#160; My PC was acting like it had no network connection even though it was connected both to a wired and wireless connection on the corporate network.&lt;/p&gt;  &lt;p&gt;I’ve been through this enough times to know that the issue was probably something to do with the corporate firewall and proxy settings on IE but I decided to test out the Windows 7 Network Troubleshooter.&amp;#160; &lt;/p&gt;  &lt;p&gt;When people say that Windows 7 is just a minor update to Windows Vista they underestimate the great work the Windows team did on this release.&amp;#160; Somebody who doesn’t know the first thing about networking or proxies would have to call the helpdesk to fix this problem but Windows 7 includes troubleshooter “packs” that help you to solve common problems without becoming a networking guru.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/AnotherreasonIloveWindows7TheNetworkTrou_8974/TroubleShoot%20problems_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="TroubleShoot problems" border="0" alt="TroubleShoot problems" src="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/AnotherreasonIloveWindows7TheNetworkTrou_8974/TroubleShoot%20problems_thumb.png" width="854" height="452" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;First I select the Troubleshoot Internet connections &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/AnotherreasonIloveWindows7TheNetworkTrou_8974/Wiz1_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Wiz1" border="0" alt="Wiz1" src="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/AnotherreasonIloveWindows7TheNetworkTrou_8974/Wiz1_thumb.png" width="589" height="450" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Notice that this dialog shows a publisher – I assume this means that others can publish troubleshooting packs though I’m not sure what the process is for this.&amp;#160;&amp;#160;&amp;#160; I click next.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/AnotherreasonIloveWindows7TheNetworkTrou_8974/Wiz2_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Wiz2" border="0" alt="Wiz2" src="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/AnotherreasonIloveWindows7TheNetworkTrou_8974/Wiz2_thumb.png" width="589" height="450" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Since I’m having trouble connecting to any website I’ll use the first option which will test microsoft.com&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/AnotherreasonIloveWindows7TheNetworkTrou_8974/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/AnotherreasonIloveWindows7TheNetworkTrou_8974/image_thumb_1.png" width="589" height="450" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;After short time I got the problem fixed automatically&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/AnotherreasonIloveWindows7TheNetworkTrou_8974/TroubleshootingCompleted_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="TroubleshootingCompleted" border="0" alt="TroubleshootingCompleted" src="http://blogs.msdn.com/blogfiles/rjacobs/WindowsLiveWriter/AnotherreasonIloveWindows7TheNetworkTrou_8974/TroubleshootingCompleted_thumb.png" width="589" height="450" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The problem was that I forgot to install the ISA firewall client that automatically sets up the proxy settings when I’m on corpnet.&amp;#160; I used to do product support many years ago.&amp;#160; How I would have loved a tool like this.&amp;#160; Way to go Windows 7!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9851148" width="1" height="1"&gt;</description></item><item><title>Mocking the Console</title><link>http://blogs.msdn.com/rjacobs/archive/2009/06/09/mocking-the-console.aspx</link><pubDate>Wed, 10 Jun 2009 04:21:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9720298</guid><dc:creator>ronjacobs</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/rjacobs/comments/9720298.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rjacobs/commentrss.aspx?PostID=9720298</wfw:commentRss><description>&lt;p&gt;I’ve posted an update to the &lt;a href="http://code.msdn.microsoft.com/wf4Simulation"&gt;Microsoft.Activities.Simulation&lt;/a&gt; library.&amp;#160; Today at the team meeting I showed the library to the Windows Workflow team and &lt;a href="http://blogs.msdn.com/edpinto/"&gt;Ed Pinto&lt;/a&gt; said “That is cool!” so I must be doing something right.&lt;/p&gt;  &lt;p&gt;Today’s update is a better TestConsole.&amp;#160; This time I’ve had the TestConsole redirect the Console output stream by calling Console.SetOut.&amp;#160; Now the stream will go into a StringWriter backed by a StringBuilder as the buffer.&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; StringBuilder _buffer;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; TestConsole()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;     StringWriter outWriter = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; StringWriter(_buffer);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;     Console.SetOut(outWriter);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This way anything that writes to the console will now be captured and therefore it will become testable.&lt;/p&gt;

&lt;p&gt;When I want to verify that something was written to the console there are two ways I can do it.&amp;#160; I can access the StringBuilder by calling TestConsole.Buffer.ToString() and then look for something in the string.&lt;/p&gt;

&lt;p&gt;Or if I prefer a line oriented approach I can do something like this test.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; Assert.AreEqual(&lt;span style="color: #006080"&gt;&amp;quot;Scope 1 Number is 1&amp;quot;&lt;/span&gt;, results.Console.Lines[0]);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Here I have a SimulationResults type with a TestConsole member named Console.&amp;#160; I can access a string[] named Lines that will return each line from the TestConsole buffer by calling Regex.Split&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;[] Lines&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;     get&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;         &lt;span style="color: #008000"&gt;// Split it only if we need to&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (Buffer.Length != _lastBufferSplit)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;             _lastBufferSplit = Buffer.Length;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;             _lines = Regex.Split(Buffer.ToString(), Environment.NewLine);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; _lines;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Since splitting the buffer is a little work, I only split it if the length of the buffer has changed since the last time I split it.&amp;#160; One side effect of using Regex.Split is that you always get an empty last line.&amp;#160; Since the &lt;a href="http://code.msdn.microsoft.com/wf4CancellationScope"&gt;CancellationScope Activity Sample&lt;/a&gt; also uses this library I put the library in place and found that I had to update all the unit tests that relied on a line count.&amp;#160; If they asserted the count should be 2 I had to change it to 3.&amp;#160; &lt;/p&gt;

&lt;p&gt;I’ m not enough of a Regex guru to know how to work around this.&amp;#160; For now I think it is ok to just say that you will always get one empty line at the end of the array and that is just the way it is.&lt;/p&gt;

&lt;p&gt;If you are interested in the &lt;a href="http://code.msdn.microsoft.com/wf4Simulation"&gt;Microsoft.Activities.Simulation library&lt;/a&gt;, let me know by posting some &lt;a href="http://code.msdn.microsoft.com/wf4Simulation/Thread/List.aspx"&gt;discussion threads&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9720298" width="1" height="1"&gt;</description></item><item><title>How to test WF4 Workflows with Microsoft.Activities.Simulation</title><link>http://blogs.msdn.com/rjacobs/archive/2009/06/05/how-to-test-wf4-workflows-with-microsoft-activities-simulation.aspx</link><pubDate>Fri, 05 Jun 2009 19:10:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9701549</guid><dc:creator>ronjacobs</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/rjacobs/comments/9701549.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rjacobs/commentrss.aspx?PostID=9701549</wfw:commentRss><description>&lt;p&gt;Recently I posted a &lt;a href="http://code.msdn.microsoft.com/wf4CancellationScope"&gt;new sample&lt;/a&gt; for the CancellationScope activity.&amp;#160; Of course, I’m building these samples on .NET 4 Beta 1.&amp;#160; But the team is already making rapid progress towards the next major milestone.&amp;#160; They are checking in changes that may or may not break my sample applications and hands on labs.&amp;#160; How will I know if things are broken?&lt;/p&gt;  &lt;p&gt;Most people rely on manual testing to detect broken code.&amp;#160; The problem is that manual testing is time consuming and expensive.&amp;#160; I wanted to find a way to unit and acceptance test the sample applications and labs.&amp;#160; There are significant challenges to this but I’ve got some ideas that I think will work and I’m going to describe them to you on my blog as I get them in place.&lt;/p&gt;  &lt;h2&gt;Unit Testing A Workflow&lt;/h2&gt;  &lt;p&gt;I’ve covered this on my blog in the past.&amp;#160; In fact, the WF4 Hands On Labs (Lab 1) from the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=752CB725-969B-4732-A383-ED5740F02E93&amp;amp;displaylang=en"&gt;Visual Studio 2010 training kit&lt;/a&gt; includes unit testing.&amp;#160; One issue I did not cover was how to use a &lt;a href="http://xunitpatterns.com/Test%20Double.html"&gt;Test Double&lt;/a&gt; with workflow.&amp;#160; Why would you do this?&amp;#160; Because some activities do things that are not testable or desirable in a unit test.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The WriteLine activity writes text to the console&lt;/li&gt;    &lt;li&gt;A Send activity sends a message to an endpoint that might not be available when testing&lt;/li&gt;    &lt;li&gt;A Receive activity requires a message to cause the workflow to continue.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;One response to things like this is to use &lt;a href="http://martinfowler.com/articles/injection.html"&gt;Dependency Injection&lt;/a&gt; with &lt;a href="http://martinfowler.com/articles/injection.html"&gt;Inversion of Control&lt;/a&gt; containers to replace these troublesome components with something more testable.&amp;#160; The Microsoft patterns &amp;amp; practices group has produced the &lt;a href="http://www.codeplex.com/unity"&gt;Unity container&lt;/a&gt; for this very purpose.&lt;/p&gt;  &lt;p&gt;These solutions do not work with workflow activities because they rely on having some measure of control over the creation of dependencies so they can resolve them at runtime.&amp;#160; &lt;/p&gt;  &lt;h2&gt;Microsoft.Activities.Simulation&lt;/h2&gt;  &lt;p&gt;I found a way to get around this specifically for workflow.&amp;#160; I’m using the term “Simulation” to describe it because in the long run I believe we can build something that would be useful to technical business users for testing workflows.&amp;#160; To understand how it works consider the CancellationScope activity sample.&amp;#160; If I want to test this sample, how would I do it?&lt;/p&gt;  &lt;p&gt;The sample writes data to a console window to show how the cancellation scope allows you to execute activities that will be triggered when a workflow element is cancelled.&amp;#160; It uses the &lt;strong&gt;System.Activities.Statements.WriteLine&lt;/strong&gt; activity to do this.&amp;#160; So what I need is a way to verify that the correct messages are output by WriteLine in the correct order.&amp;#160; What I really wanted to do was to replace &lt;strong&gt;WriteLine&lt;/strong&gt; with another activity I call &lt;strong&gt;MockWriteLine&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;The strategy I use is to modify the XAML for testing.&amp;#160; Consider the following XAML snippet.&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;p:CancellationScope&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Cancellation Scope 1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;p:CancellationScope.CancelHandler&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;       &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;p:WriteLine&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;WriteLine Cancel Scope 1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;[&amp;quot;Cancelling scope 1...&amp;quot;]&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;p:WriteLine&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;p:CancellationScope.CancelHandler&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Here&amp;#160; you can see the solution staring you in the face.&amp;#160; If you could just change &lt;strong&gt;&amp;lt;p:WriteLine&lt;/strong&gt; to &lt;strong&gt;&amp;lt;p:MockWriteLine&lt;/strong&gt; and made the MockWriteLine activity have the same properties as WriteLine then you can do whatever you want from MockWriteLine to make the workflow testable.&lt;/p&gt;

&lt;p&gt;Great, but what should MockWriteLine do?&amp;#160; I want to capture what it would have written to the console.&amp;#160; I need to get data from this activity without modifying the workflow more than I already have.&amp;#160; The solution is to use the &lt;a href="http://xunitpatterns.com/Test%20Spy.html"&gt;Test Spy pattern&lt;/a&gt; with a workflow extension.&lt;/p&gt;

&lt;p&gt;I created a class called &lt;strong&gt;TestConsole&lt;/strong&gt; that will store up the WriteLine output in a buffer that I can verify later.&amp;#160; I can then add this extension to the workflow instance.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; WorkflowInstance workflowInstance = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; WorkflowInstance(wfElement, inputs);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; TestConsole testConsole = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; TestConsole();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt; &lt;span style="color: #008000"&gt;// Add the testConsole to the extensions collection&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt; workflowInstance.Extensions.Add(testConsole);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt; &lt;span style="color: #008000"&gt;// Run the test...&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt; RunTheTest();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt; &lt;span style="color: #008000"&gt;// Check the first line of the buffer&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt; Assert.AreEqual(&lt;span style="color: #006080"&gt;&amp;quot;Some text to verify&amp;quot;&lt;/span&gt;, testConsole.Buffer.ElementAt(0));&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
There is much more to say about this but I’m running out of time.&amp;#160; To see it in action, check out the updated version of the &lt;a href="http://code.msdn.microsoft.com/wf4CancellationScope"&gt;CancellationScope Activity Sample&lt;/a&gt;.

&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9701549" width="1" height="1"&gt;</description></item><item><title>WF / WCF 4 and “Dublin” Resources</title><link>http://blogs.msdn.com/rjacobs/archive/2009/06/02/wf-wcf-4-and-dublin-resources.aspx</link><pubDate>Wed, 03 Jun 2009 01:12:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9687444</guid><dc:creator>ronjacobs</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/rjacobs/comments/9687444.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rjacobs/commentrss.aspx?PostID=9687444</wfw:commentRss><description>&lt;p&gt;Every now and then somebody will ask me about resources for WF/WCF 4.&amp;#160; I usually copy a bunch of links into an email for them.&amp;#160; Today I decided I ought to share these resources with all of you.&amp;#160; I’ll try to remember and come back to this page and add more as we make more.&lt;/p&gt;  &lt;h2&gt;Videos&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://channel9.msdn.com/shows/Endpoint/endpointtv-Windows-Workflow-4/"&gt;endpoint.tv - Windows Workflow 4&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://channel9.msdn.com/shows/Endpoint/endpointtv-Service-Discovery-with-WCF/"&gt;endpoint.tv - Service Discovery with WCF&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://channel9.msdn.com/shows/Endpoint/endpointtv-Dublin-Architecture/"&gt;endpoint.tv - Dublin Architecture&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://channel9.msdn.com/shows/Endpoint/endpointtv-Dublin-what-is-it-and-why-should-I-care/"&gt;endpoint.tv - &amp;quot;Dublin&amp;quot; what is it and why should I care?&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;Code / Samples&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://code.msdn.microsoft.com/wcfwf4"&gt;WF/WCF 4 Hands On Labs&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/rjacobs/archive/2009/06/01/cancellationscope-activity.aspx"&gt;CancellationScope Activity sample&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=752CB725-969B-4732-A383-ED5740F02E93&amp;amp;displaylang=en"&gt;Visual Studio 2010 Training Kit (includes WF/WCF 4 Labs)&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=5aca0622-d87d-4cc9-a22c-0d58205a56b4#tm"&gt;Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4.0 Beta 1&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/netframework/cc896557.aspx"&gt;MSDN – WCF / WF4 Changes&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;Questions&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/threads"&gt;WF4 Pre Release Forum&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://social.msdn.microsoft.com/Forums/en-US/wcfprerelease/threads"&gt;WCF4 Pre Release Forum&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9687444" width="1" height="1"&gt;</description></item></channel></rss>