<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Windows Workflow Foundation</title>
        <link>http://geekswithblogs.net/SoftwareDoneRight/category/7415.aspx</link>
        <description>Windows Workflow Foundation</description>
        <language>en-US</language>
        <copyright>ChrisD</copyright>
        <managingEditor>chris@wtfsolutions.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Faulting Handling for Dynamic Workflows - Part 1.</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/02/01/faulting-handling-for-dynamic-workflows---part-1.aspx</link>
            <description>&lt;p&gt;&lt;em&gt;"There is no joy in Mudville - the mighty Casey has struck out."&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;I've been spending some time lately reviewing and bolstering my old WF Execution code.  Part of this refactoring included a revamped approach at Exception handling.  With so many different kinds of activities, implementing a "standard" fault handler is proving more challenging than I had originally thought.   Managing exceptions in base workflow activities is one thing, but handling exceptions in custom business activities is quite another. &lt;/p&gt;  &lt;p&gt;Unfortunately, I haven't found a way to activity bind dynamically added properties in windows workflow.  As a result, I've developed a custom activity generator that I can point to an exe or dll and have it selectively generate custom activities from exposed public methods .  The generated activities support dynamic, strongly typed parameters for the method's input, output and return values.  There are also a handful of helpful "converter" activities that will convert objects from one type to another, storing the results in strongly typed generated fields.    This approach has a nice side benefit of being able to generate unit tests and ensure coverage of my business activities without relying on workflow execution-- but I digress.  The generated activities have no intrinsic  error handling of their own, but rather bubble up the thrown exceptions up the activity hierarchy to the workflow. &lt;/p&gt;  &lt;p&gt;Left unhandled, an exception in a custom activity will fault the workflow, terminating workflow execution and tear down and unload the workflow from the runtime.  Sometimes terminating workflow execution is the proper response, but not usually.  All my workflows are dynamic.  They are all XAML activated workflows with a root activity that points to my compiled base workflow.  My goal was to implement a root level fault handling routine in my base workflow (a compiled workflow), that would act as a "safety net" for all the dynamic workflows that it hosts.&lt;/p&gt;  &lt;p&gt;I implemented a basic fault handler via the workflow designer and ran my first unit test.  The workflow failed validation. In fact, every workflow was now failing validation.  Digging into the error stack I discovered the cause: &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;"Can not add activity in a CompositeActivity which has built in children."&lt;/em&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;So there's evidently a design decision that was made that states "if the composite activity has children, it cannot be modified at runtime."  The composite activity its referring to is the base workflow itself.  The children activities is actually the fault handler activity (it gets added like another activity to the workflow's children collection).  This means I cannot support any activities (even fault handlers) in my base workflow.&lt;/p&gt;  &lt;p&gt;For now, I've removed the fault handling code (at least my workflows pass validation and execute again). &lt;/p&gt;  &lt;p&gt;My next idea is to change the root activity in my xaml workflows from the concrete class to a dynamic class, or possibly write something to set the internal CanModifyActivities flag during workflow load...&lt;/p&gt;  &lt;p&gt;Got a thought?  I'd love to hear from you. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=119167"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=119167" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/119167.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/02/01/faulting-handling-for-dynamic-workflows---part-1.aspx</guid>
            <pubDate>Fri, 01 Feb 2008 08:36:02 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/119167.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/02/01/faulting-handling-for-dynamic-workflows---part-1.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/119167.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/119167.aspx</trackback:ping>
        </item>
        <item>
            <title>Persisting Workflows using the NetDataContract Serializer</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/01/26/persisting-workflows-using-the-netdatacontract-serializer.aspx</link>
            <description>&lt;p&gt;I'm currently working on a WCF/WF project where we've replaced .NET's DataContractSerializer default with the NetDataContractSerializer.   The following is from the MSDN help file:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;The NetDataContractSerializer differs from the DataContractSerializer in one important way: the NetDataContractSerializer includes CLR type information in the serialized XML, whereas the DataContractSerializer does not. Therefore, the NetDataContractSerializer can be used only if both the serializing and deserializing ends share the same CLR types.&lt;/em&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Given the addition of the CLR information in serialized XML, we needed a custom Serialization Surrogate to use for Workflow Persistence.  My first attempt used a BinaryReader to read and write the serialization data&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ContractSurrogateSelector &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;SurrogateSelector
&lt;/span&gt;{
    &lt;span style="color: blue"&gt;public override &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ISerializationSurrogate &lt;/span&gt;GetSurrogate(&lt;span style="color: #2b91af"&gt;Type &lt;/span&gt;type, &lt;span style="color: #2b91af"&gt;StreamingContext &lt;/span&gt;context, &lt;span style="color: blue"&gt;out &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ISurrogateSelector &lt;/span&gt;selector)
    {
        &lt;span style="color: green"&gt;//check to see if type has NetDataContractAttribute
        &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(type.IsDefined(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(NetDataContractAttribute), &lt;span style="color: blue"&gt;false&lt;/span&gt;))
        {
            selector = &lt;span style="color: blue"&gt;this&lt;/span&gt;;
            &lt;span style="color: blue"&gt;return new &lt;/span&gt;NetDataContractSerializationSurrogate();
        }
        &lt;span style="color: blue"&gt;return base&lt;/span&gt;.GetSurrogate(type, context, &lt;span style="color: blue"&gt;out &lt;/span&gt;selector);
    }
}
&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;NetDataContractSerializationSurrogate &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;ISerializationSurrogate
&lt;/span&gt;{
    [&lt;span style="color: #2b91af"&gt;Serializable&lt;/span&gt;]
    &lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;DataContractRef&lt;/span&gt;&amp;lt;T&amp;gt; : &lt;span style="color: #2b91af"&gt;IObjectReference
    &lt;/span&gt;{
        &lt;span style="color: blue"&gt;#region &lt;/span&gt;IObjectReference Members
        
        &lt;span style="color: blue"&gt;public object &lt;/span&gt;GetRealObject(&lt;span style="color: #2b91af"&gt;StreamingContext &lt;/span&gt;context)
        {

            XmlDictionaryReader r = XmlDictionaryReader.CreateBinaryReader(objectData, XmlDictionaryReaderQuotas.Max);
            &lt;span style="color: blue"&gt;object &lt;/span&gt;ret = &lt;span style="color: blue"&gt;null&lt;/span&gt;;
            Message m = Message.CreateMessage(r, 2048, MessageVersion.Soap11WSAddressing10);
            ret = m.GetBody&amp;lt;T&amp;gt;();
            &lt;span style="color: blue"&gt;return &lt;/span&gt;ret;
        }
        &lt;span style="color: blue"&gt;byte&lt;/span&gt;[] objectData;
        &lt;span style="color: blue"&gt;#endregion
    &lt;/span&gt;}
    &lt;span style="color: blue"&gt;#region &lt;/span&gt;ISerializationSurrogate Members

    &lt;span style="color: blue"&gt;public void &lt;/span&gt;GetObjectData(&lt;span style="color: blue"&gt;object &lt;/span&gt;obj, &lt;span style="color: #2b91af"&gt;SerializationInfo &lt;/span&gt;info, &lt;span style="color: #2b91af"&gt;StreamingContext &lt;/span&gt;context)
    {

     
        Message msg = Message.CreateMessage(MessageVersion.Soap11WSAddressing10, &lt;span style="color: #a31515"&gt;"whocares"&lt;/span&gt;, obj, &lt;span style="color: blue"&gt;new &lt;/span&gt;NetDataContractSerializer(obj.GetType()));
        &lt;span style="color: #2b91af"&gt;MemoryStream &lt;/span&gt;ms = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MemoryStream&lt;/span&gt;();
        XmlDictionaryWriter writer = XmlDictionaryWriter.CreateBinaryWriter(ms);
        msg.WriteMessage(writer);
        writer.Flush();
        ms.Flush();
        ms.Seek(0, &lt;span style="color: #2b91af"&gt;SeekOrigin&lt;/span&gt;.Begin);
       
        info.AddValue(&lt;span style="color: #a31515"&gt;"objectData"&lt;/span&gt;, ms.GetBuffer());
        &lt;span style="color: #2b91af"&gt;Type &lt;/span&gt;t = &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(DataContractRef&amp;lt;&amp;gt;).MakeGenericType(obj.GetType());
        info.SetType(t);
    }

    &lt;span style="color: blue"&gt;public object &lt;/span&gt;SetObjectData(&lt;span style="color: blue"&gt;object &lt;/span&gt;obj, &lt;span style="color: #2b91af"&gt;SerializationInfo &lt;/span&gt;info, &lt;span style="color: #2b91af"&gt;StreamingContext &lt;/span&gt;context, &lt;span style="color: #2b91af"&gt;ISurrogateSelector &lt;/span&gt;selector)
    {
        &lt;span style="color: blue"&gt;return null&lt;/span&gt;;


    }

    &lt;span style="color: blue"&gt;#endregion
    
&lt;/span&gt;}&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;The Data looked to serialize fine,and was getting persisted into my SQL Server database tables via the SqlServerPersistenceService that ships with WF.   However, when I attempt to resumed a persisted workflow,  Deserialization failed with an XMLException stating "the input source is not correctly formatted".   The exception was being raised when the Reader began parsing the xml stream of serialized data.   Not what I would have expected considering I'm using a binary serializer for both reading and writing the data.  Clearly something was getting lost in translation. &lt;/p&gt;

&lt;p&gt;After much struggling, I finally discovered that the problem was around the message encoding. I was trying to use BinaryMessageEncodingBindingElement. I switched to use the MtomMessageEncodingBindingElement and it worked like a champ.  The MTOM format correctly encodes the CLR type information needed by the NetDataContractSerializer.   My serialization surrogate code ended up looking like this:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="code"&gt;[&lt;span style="color: #2b91af"&gt;Serializable&lt;/span&gt;]
&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;NetDataContractRef&lt;/span&gt;&amp;lt;T&amp;gt; : &lt;span style="color: #2b91af"&gt;IObjectReference
&lt;/span&gt;{
    &lt;span style="color: blue"&gt;#region &lt;/span&gt;IObjectReference Members
    
    &lt;span style="color: blue"&gt;public object &lt;/span&gt;GetRealObject(&lt;span style="color: #2b91af"&gt;StreamingContext &lt;/span&gt;context)
    {
      
            
            &lt;span style="color: blue"&gt;object &lt;/span&gt;ret = &lt;span style="color: blue"&gt;null&lt;/span&gt;;
            &lt;span style="color: #2b91af"&gt;XmlDictionaryReader &lt;/span&gt;r = &lt;span style="color: #2b91af"&gt;XmlDictionaryReader&lt;/span&gt;.CreateMtomReader(objectData, 0, objectData.Length, &lt;span style="color: #2b91af"&gt;Encoding&lt;/span&gt;.UTF8, &lt;span style="color: #2b91af"&gt;XmlDictionaryReaderQuotas&lt;/span&gt;.Max);
            &lt;span style="color: #2b91af"&gt;XmlObjectSerializer &lt;/span&gt;serializer = GetSerializer(&lt;span style="color: blue"&gt;typeof &lt;/span&gt;(T));
            &lt;span style="color: #2b91af"&gt;Message &lt;/span&gt;m = &lt;span style="color: #2b91af"&gt;Message&lt;/span&gt;.CreateMessage(r, 1024 , &lt;span style="color: #2b91af"&gt;MessageVersion&lt;/span&gt;.Soap11WSAddressing10); 
            ret = m.GetBody&amp;lt;T&amp;gt;(serializer);                    
            &lt;span style="color: blue"&gt;return &lt;/span&gt;ret;
        
    }

    &lt;span style="color: blue"&gt;private byte&lt;/span&gt;[] objectData = &lt;span style="color: blue"&gt;null&lt;/span&gt;;
    &lt;span style="color: blue"&gt;#endregion
&lt;/span&gt;}

&lt;span style="color: blue"&gt;#region &lt;/span&gt;ISerializationSurrogate Members

&lt;span style="color: blue"&gt;public void &lt;/span&gt;GetObjectData(&lt;span style="color: blue"&gt;object &lt;/span&gt;obj, &lt;span style="color: #2b91af"&gt;SerializationInfo &lt;/span&gt;info, &lt;span style="color: #2b91af"&gt;StreamingContext &lt;/span&gt;context)
{

    &lt;span style="color: blue"&gt;try
    &lt;/span&gt;{
        &lt;span style="color: #2b91af"&gt;MemoryStream &lt;/span&gt;ms = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MemoryStream&lt;/span&gt;();
        &lt;span style="color: #2b91af"&gt;XmlObjectSerializer &lt;/span&gt;serializer = GetSerializer(obj.GetType());
        &lt;span style="color: #2b91af"&gt;Message &lt;/span&gt;msg = &lt;span style="color: #2b91af"&gt;Message&lt;/span&gt;.CreateMessage(&lt;span style="color: #2b91af"&gt;MessageVersion&lt;/span&gt;.Soap11WSAddressing10, &lt;span style="color: #a31515"&gt;"whocares"&lt;/span&gt;, obj, serializer);
        &lt;span style="color: #2b91af"&gt;XmlDictionaryWriter &lt;/span&gt;writer = &lt;span style="color: #2b91af"&gt;XmlDictionaryWriter&lt;/span&gt;.CreateMtomWriter(ms, &lt;span style="color: #2b91af"&gt;Encoding&lt;/span&gt;.UTF8, &lt;span style="color: #2b91af"&gt;Int32&lt;/span&gt;.MaxValue, &lt;span style="color: #a31515"&gt;"text/xml"&lt;/span&gt;);
        msg.WriteMessage(writer);
        writer.Flush();
        ms.Flush();
        ms.Seek(0, &lt;span style="color: #2b91af"&gt;SeekOrigin&lt;/span&gt;.Begin);

        info.AddValue(&lt;span style="color: #a31515"&gt;"objectData"&lt;/span&gt;, ms.GetBuffer());
        &lt;span style="color: #2b91af"&gt;Type &lt;/span&gt;t = &lt;span style="color: blue"&gt;typeof &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;NetDataContractRef&lt;/span&gt;&amp;lt;&amp;gt;).MakeGenericType(obj.GetType());
        info.SetType(t);
    }
    &lt;span style="color: blue"&gt;catch &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Exception &lt;/span&gt;ex)
    {
        &lt;span style="color: #2b91af"&gt;Trace&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Workflow Persistence Serialization Exception: - " &lt;/span&gt;+ ex.ToString());
    }
}

&lt;span style="color: blue"&gt;public object &lt;/span&gt;SetObjectData(&lt;span style="color: blue"&gt;object &lt;/span&gt;obj, &lt;span style="color: #2b91af"&gt;SerializationInfo &lt;/span&gt;info, &lt;span style="color: #2b91af"&gt;StreamingContext &lt;/span&gt;context, &lt;span style="color: #2b91af"&gt;ISurrogateSelector &lt;/span&gt;selector)
{
    &lt;span style="color: blue"&gt;return null&lt;/span&gt;;


}

&lt;span style="color: blue"&gt;#endregion


public static &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlObjectSerializer &lt;/span&gt;GetSerializer(&lt;span style="color: #2b91af"&gt;Type &lt;/span&gt;type)
{
    &lt;span style="color: blue"&gt;return new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;NetDataContractSerializer&lt;/span&gt;();
}&lt;/pre&gt;
  &lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/blockquote&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;If anyone else has had a similar experience, please post a comment, I'd love to talk more about the how's and why's. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=118946"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=118946" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/118946.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/01/26/persisting-workflows-using-the-netdatacontract-serializer.aspx</guid>
            <pubDate>Sat, 26 Jan 2008 19:54:33 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/118946.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/01/26/persisting-workflows-using-the-netdatacontract-serializer.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/118946.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/118946.aspx</trackback:ping>
        </item>
        <item>
            <title>.NET 3.5 Certification Exam Beta is Still Available</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/01/25/.net-3.5-certification-exam-beta-is-still-available.aspx</link>
            <description>&lt;p&gt;&lt;img height="160" src="http://www.ekampf.com/blog/content/binary/WinFX.png" width="160" align="left" /&gt; Microsoft has extended the deadline for the .NET 3.5 technologies certification exam betas.  There are certification tests available for WCF, WPF and Windows Workflow.  You can take the exams for free, if you pass they will count towards your overall MS certification.  Interested?  Read more about it &lt;a href="http://blogs.msdn.com/trika/archive/2008/01/14/wpf-wcf-workflow-beta-exams-extended.aspx"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=118913"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=118913" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/118913.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/01/25/.net-3.5-certification-exam-beta-is-still-available.aspx</guid>
            <pubDate>Fri, 25 Jan 2008 18:57:32 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/118913.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/01/25/.net-3.5-certification-exam-beta-is-still-available.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/118913.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/118913.aspx</trackback:ping>
        </item>
        <item>
            <title>HowTo: Set up your project for Window's Workflow (C# style)</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/01/19/howto-set-up-your-project-for-windows-workflow-c-style.aspx</link>
            <description>&lt;p&gt;Any C#  project can contain Workflow definitions.  They're just code file and/or XAML files.  The trick is getting Visual Studio to recognize the project as supporting worfklows for design-time support and compilation.&lt;/p&gt;  &lt;p&gt;To enable a project for Windows Workflow,:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Open the project in visual studio.  &lt;/li&gt;    &lt;li&gt;If you're using source control check out the project file so it becomes writable &lt;/li&gt;    &lt;li&gt;In the Solution Explorer, right click and select &lt;strong&gt;Unload Project&lt;/strong&gt; .  The project tree will disappear from the solution explorer and is replaced with a single node of the project name followed by the phrase &lt;strong&gt;(Unloaded). &lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Right click on the unloaded project node in the Solution Explorer again, and select Edit Project.  This will open the project file in Visual Studio. The project file is just an XML file, so we can edit it manually. &lt;/li&gt;    &lt;li&gt;Find the entry named &lt;strong&gt;&amp;lt;ProjectTypeGuids&amp;gt;&lt;/strong&gt; and make sure it includes these id's &lt;/li&gt;    &lt;ul&gt;     &lt;ul&gt;       &lt;li&gt;&lt;i&gt;&amp;lt;ProjectTypeGuids&amp;gt;{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}&amp;lt;/ProjectTypeGuids&amp;gt;&lt;/i&gt;&lt;/li&gt;     &lt;/ul&gt;      &lt;li&gt;This tells visual studio its a C# project and a workflow project.  Both are necessary to get design time support in your visual studio project.  If you forget to include these project guid's you'll like end with an error like this when you try to edit a workflow file&lt;/li&gt;      &lt;ul&gt;       &lt;li&gt;&lt;i&gt;&lt;font color="#004080"&gt;The service 'System.Workflow.ComponentModel.Design.IIdentifierCreationService' must be installed for this operation to succeed. Ensure that this service is available.&lt;/font&gt;&lt;/i&gt;&lt;/li&gt;     &lt;/ul&gt;      &lt;li&gt;Finally we have to tell Visual Studio to include the workflow compilation build targets for MSBuild when the project compiles.  Add the following entry to your project's xml file inside the &lt;strong&gt;&amp;lt;Project&amp;gt;&lt;/strong&gt; node&lt;/li&gt;      &lt;ul&gt;       &lt;li&gt;&lt;i&gt;&amp;lt;Import Project="$(MSBuildExtensionsPath)\Microsoft\Windows Workflow Foundation\v3.0\Workflow.Targets" /&amp;gt;&lt;/i&gt;&lt;/li&gt;     &lt;/ul&gt;   &lt;/ul&gt;    &lt;li&gt;Save and close the project xml file.&lt;/li&gt;    &lt;li&gt;Right click on the project node in the Solution Explorer again and select &lt;strong&gt;Reload Project&lt;/strong&gt;&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;Your project is now Workflow-capable.  You should be able to edit and compile Windows Workflow files.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=118696"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=118696" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/118696.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/01/19/howto-set-up-your-project-for-windows-workflow-c-style.aspx</guid>
            <pubDate>Sat, 19 Jan 2008 16:31:08 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/118696.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/01/19/howto-set-up-your-project-for-windows-workflow-c-style.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/118696.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/118696.aspx</trackback:ping>
        </item>
        <item>
            <title>Hide Custom Activity Properties from the WF Designer &amp; Property Grid</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2007/12/12/hide-custom-activity-properties-from-the-wf-designer--property.aspx</link>
            <description>&lt;p&gt;Sometimes too many options is a bad thing. After all just because I create a property in my custom activity doesn't mean I want it displayed on the design surface.  &lt;/p&gt;
&lt;p&gt;To Microsoft's credit, most of the design behavior of workflow is customizable and often pluggable, making it possible and practical to extend the user experience.  Microsoft provides a Browseable attribute which can be placed on properties that according to the help file :&lt;/p&gt;
&lt;blockquote dir="ltr" style="MARGIN-RIGHT: 0px"&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;/font&gt;&lt;em&gt; specifies whether a property or event should be displayed in a Properties window. &lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p dir="ltr" style="MARGIN-RIGHT: 0px"&gt;Placing this attribute on your public property works. sometimes. To be clear, the attribute seems to work but its not always picked up by the compiler.&lt;/p&gt;
&lt;p dir="ltr" style="MARGIN-RIGHT: 0px"&gt;The other problem with the declarative approach is it forces me to set the visibility of the property once and only once.  This assumes that the browsable value I specify is the value I want all the time. &lt;/p&gt;
&lt;p dir="ltr" style="MARGIN-RIGHT: 0px"&gt;Consider the case of a sub classed activity.  Maybe in the base class I want to expose the property, but hide it in a sub class.  This isn't a supported scenario using the declarative Browseable attribute (even if it did work).&lt;/p&gt;
&lt;p dir="ltr" style="MARGIN-RIGHT: 0px"&gt;My preferred way to hide unwanted properties is to hook into the PreFilterProperties method in the activity designer.  &lt;/p&gt;
&lt;p dir="ltr" style="MARGIN-RIGHT: 0px"&gt;&lt;font color="#333399"&gt; &lt;/font&gt;&lt;font face="Arial" color="#333399"&gt; protected override void PreFilterProperties(IDictionary properties)&lt;br /&gt;
        {&lt;br /&gt;
            base.PreFilterProperties(properties);&lt;br /&gt;
            string[] propertiesToHide = { "Order", "ErrorMessage" };&lt;br /&gt;
            ActivityDesignerHelper.HidePropertiesInDesigner(propertiesToHide, properties, this.GetType());&lt;br /&gt;
        }&lt;/font&gt;&lt;/p&gt;
&lt;p dir="ltr" style="MARGIN-RIGHT: 0px"&gt;here's the code of my MidePropertiesInDesigner which I liberated from another developer (I'm sorry I dont recall the original source of this code).  I've modified it slightly to override any existing browseable attributes&lt;/p&gt;
&lt;blockquote dir="ltr" style="MARGIN-RIGHT: 0px"&gt;
&lt;p&gt;&lt;font face="Arial"&gt; &lt;font color="#000080"&gt;public static IDictionary HidePropertiesInDesigner(string[] propertiesToHide,IDictionary properties, Type designerType )&lt;br /&gt;
        {&lt;br /&gt;
            foreach (string propname in propertiesToHide)&lt;br /&gt;
            {&lt;br /&gt;
                PropertyDescriptor prop = (PropertyDescriptor)properties[propname];&lt;br /&gt;
                if (prop != null)&lt;br /&gt;
                {&lt;br /&gt;
                    AttributeCollection runtimeAttributes = prop.Attributes;                    &lt;br /&gt;
                    bool hasBrowsable = false;&lt;br /&gt;
                    for (int i = 0; i &amp;lt; runtimeAttributes.Count; i++ )&lt;br /&gt;
                    {&lt;br /&gt;
                        BrowsableAttribute browseAttr = runtimeAttributes[i] as BrowsableAttribute;&lt;br /&gt;
                        if (browseAttr != null)&lt;br /&gt;
                        {&lt;br /&gt;
                            hasBrowsable = true;&lt;br /&gt;
                            break;&lt;br /&gt;
                        }&lt;br /&gt;
                    }&lt;br /&gt;
                    // make a copy of the original attributes &lt;br /&gt;
                    // but make room for one extra attribute&lt;br /&gt;
                    Attribute[] attrs = new Attribute[runtimeAttributes.Count + (hasBrowsable?0:1)];&lt;br /&gt;
                    //runtimeAttributes.CopyTo(attrs, 0);&lt;br /&gt;
                    // now selectively copy the attributes to a new array &lt;br /&gt;
                    int attrCnt = 0;&lt;br /&gt;
                    for (int i = 0; i &amp;lt; runtimeAttributes.Count; i++)&lt;br /&gt;
                    {&lt;br /&gt;
                        Attribute attr = runtimeAttributes[i];&lt;br /&gt;
                        // if this attribute is the browseable attribute, skip it&lt;br /&gt;
                        if (attr is BrowsableAttribute)&lt;br /&gt;
                            continue;&lt;br /&gt;
                        attrs[attrCnt] = attr;&lt;br /&gt;
                        attrCnt++;&lt;br /&gt;
                    }&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial" color="#000080"&gt;                    // add in a new browseable(false) attribute &lt;br /&gt;
                    attrs[runtimeAttributes.Count] = new BrowsableAttribute(false);&lt;br /&gt;
                    prop = TypeDescriptor.CreateProperty(designerType, propname, prop.PropertyType, attrs);&lt;br /&gt;
                    properties[propname] = prop;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            return properties;&lt;/font&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p dir="ltr"&gt;&lt;font face="Arial" color="#000080"&gt;            &lt;br /&gt;
        }&lt;/font&gt;&lt;/p&gt;
&lt;p dir="ltr"&gt;&lt;font face="Arial" color="#000080"&gt;&lt;br /&gt;
&lt;/font&gt;The code iterates through the property's existing attributes, ignoring the browsable attribute (if it exists) and then copies them to a new attribute array, inserts the browseable attribute value specified and assigns it back to the property.&lt;/p&gt;
&lt;p dir="ltr"&gt;This code works 100% of the time for me, and allows me to decide on a case-by-case basis which properties to hide and which ones to show in the design surface.&lt;/p&gt;
&lt;blockquote dir="ltr" style="MARGIN-RIGHT: 0px"&gt;
&lt;p&gt; &lt;/p&gt;
&lt;/blockquote&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=117622"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=117622" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/117622.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2007/12/12/hide-custom-activity-properties-from-the-wf-designer--property.aspx</guid>
            <pubDate>Wed, 12 Dec 2007 15:54:53 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/117622.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2007/12/12/hide-custom-activity-properties-from-the-wf-designer--property.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/117622.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/117622.aspx</trackback:ping>
        </item>
        <item>
            <title>Breakpoints in XAML Activated Workflows</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2007/12/12/breakpoints-in-xaml-activated-workflows.aspx</link>
            <description>&lt;p&gt;XAML only workflows (those are xoml files without a code attribute and code beside file), do not support debugger breakpoints.  Right clicking on the activity in the workflow and selecting insert breakpoint does (as far as I can tell) nothing. &lt;/p&gt;
&lt;p&gt;Since XAML only workflows have no associated code and therefore no IL, it makes sense that you can't set a breakpoint, after all what exactly are you attaching the breakpoint to?&lt;/p&gt;
&lt;p&gt;XAML only workflows are all about process orchestration and flow control, we really want to debug into the code inside of the custom activities used in the workflow.&lt;/p&gt;
&lt;p&gt;With the out-of-the-box breakpoint functionality not available, how can we set breakpoints in our workflows?  My answer to this problem is a custom activity;  &lt;font color="#2b91af" size="2"&gt;DebuggerBreakpointActivity&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;The activity is straightforward and comes down to a single conditional statement:&lt;/p&gt;
&lt;br /&gt;
&lt;font color="#2b91af" size="2"&gt;
&lt;p&gt;&lt;font face="Arial" color="#008000" size="2"&gt;    [ToolboxBitmap(typeof(DebuggerBreakpointActivity), “DebuggerBreakpointActivity.DebuggerBreakpointActivityLogo.png")]&lt;br /&gt;
    [ActivityValidator(typeof (DebuggerBreakpointActivityValidator))]&lt;br /&gt;
    [Designer(typeof (DebuggerBreakpointActivityDesigner), typeof (IDesigner))]&lt;br /&gt;
    public class DebuggerBreakpointActivity : Activity&lt;br /&gt;
    {    &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial" color="#008000" size="2"&gt;        protected override ActivityExecutionStatus Execute(ActivityExecutionContext ctx)&lt;br /&gt;
        {&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial" color="#008000" size="2"&gt;            try&lt;br /&gt;
            {&lt;br /&gt;
                if (System.Diagnostics.Debugger.IsAttached)&lt;br /&gt;
                    System.Diagnostics.Debugger.Break();&lt;br /&gt;
                &lt;br /&gt;
            }&lt;br /&gt;
            catch&lt;br /&gt;
            {&lt;br /&gt;
            }&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial" color="#008000" size="2"&gt;            // mark this activity as closed. &lt;br /&gt;
            return ActivityExecutionStatus.Closed;&lt;br /&gt;
        }&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial" color="#008000" size="2"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;/font&gt;
&lt;p&gt;When executing, the activity checks to see if the debugger is attached, if so, it programmatically inserts a breakpoint.  From here I can step through all my custom activity code and can monitor my workflow execution paths.&lt;/p&gt;
&lt;p&gt;When not running in debug mode, the debugger is not present and the activity completes with no action taken. &lt;/p&gt;
&lt;p&gt;A side note:  when I drag this activity onto my design surface, I set the activity name to something useful.  this way I can monitor my execution flow by simply checking the name value of the activity (which appears automatically in the locals window). &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=117621"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=117621" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/117621.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2007/12/12/breakpoints-in-xaml-activated-workflows.aspx</guid>
            <pubDate>Wed, 12 Dec 2007 15:18:20 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/117621.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2007/12/12/breakpoints-in-xaml-activated-workflows.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/117621.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/117621.aspx</trackback:ping>
        </item>
    </channel>
</rss>