VS2008 SP1 Beta is quite a package. By default the installation downloads the packages as needed and when needed. Now that is just fine if you only need to install a single machine. But when you need to install multiple, possibly virtual, machines like I have to it just wastes a lot of bandwidth and time Sad. Fortunately there is a solution and it can be found here in the blog post by Heath Stewart.

Enjoy! 

The Dutch Microsoft office has posted the first of the Community DevCast we recorded. The host is Alex Thissen who actually does most of the work as he also edits the screencasts so don't forget to thank him next week when you run into him at the Dutch DevDays.

I am happy to say that amongst the first 6 screencasts released are no less that 4 I did with Alex about Workflow Foundation. And there are more to come so stay tuned.

The other two are about C# and done by Dennis Vroegop again with Alex as the host.

You can find the Community DevCast here. Keep in mind they are for a Dutch audience so they where recorded in Dutch!

Enjoy!

www.TheProblemSolver.nl
http://wiki.WindowsWorkflowFoundation.eu

By default every custom workflow activity shows the same icon. And using an icon that help understand what the activity actually does makes life so much easier for the user of your activity. And remember he is a developer so some day he might just return the favor Smile

 

The default looks like this.

image

 

So changing the icon isn't hard there are just a few steps that might catch you if you aren't careful.

This is what my demo project looks like:

image

 

  1. Add the new image to the project. In my case I added a folder named Images and dropped the PushpinHS.png in there. This PushpinHS.png can be found in the standard VS2008ImageLibrary.zip located in C:\Program Files\Microsoft Visual Studio 9.0\Common7\VS2008ImageLibrary\1033.
  2. Change the build action for PushpinHS.png to Embedded Resource.
  3. Next go to the Activity1.cs file and add the ToolboxBitmap attribute to the Activity1 class. We need to specify two parameters, the first is a type in which assembly the PushpinHS.png is located and the second is the name of the resource to use. These two are related because the resource name us relative to the namespace of the type used.
  4. [ToolboxBitmap(typeof(Activity1), "Images.PushpinHS.png")]
    public partial class Activity1: SequenceActivity
    {

    }

And now we have a nice new icon in the activity like this:

image

 

One problem is that the resource name is actually relative to the class specified. Using relfector makes it easy to see all the actual names, including the namespace used.

image

 

So what to do if your activity is in another namespace and a direct reference to the resource isn't possible?

The easiest way is to add another class outside of all namespaces and fully specify the resource name like this:

using System.Drawing;
using System.Workflow.Activities;

internal class ResourceLoader
{ }

namespace WorkflowConsoleApplication1.MyActivities
{
    [ToolboxBitmap(typeof(ResourceLoader), "WorkflowConsoleApplication1.Images.PushpinHS.png")]
    public partial class Activity1: SequenceActivity
    {
        public Activity1()
        {
            InitializeComponent();
        }
    }
}

 

Note the ResourceLoader used in the ToolboxBitmap attribute is not included in any namespace to we need to specify the full resource name "WorkflowConsoleApplication1.Images.PushpinHS.png".

 

Enjoy!

with no comments
Filed under: , , , ,

 When I tried I received the following very helpful System.ServiceModel.ProtocolException with Message="The remote server returned an unexpected response: (407) Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )."

And this in turn contained an inner exception of type System.Net.WebException and Message="The remote server returned an error: (407) Proxy Authentication Required.".

Now I cannot find any way to add the required authentication but it turns out that setting the wsHttpBinding useDefaultWebProxy to false works just fine Smile

Enjoy! 

with no comments
Filed under: , , , ,

For some reason a lot of people seem to think that only a single WorkflowRuntime object can be created in an AppDomain. And it isn't just the average Joe out there who seems to think so, no even book authors describe this behavior as the Workflow Foundation book I am reading now does so.

Just to set the record straight I will shout this out once more:

You can have multiple WorkflowRuntime objects in a single .NET AppDomain

Now I know where this perception comes from and its the original beta of Workflow Foundation way back before .NET 3.0 was released. Back then the WF team decided that only a single WorkflowRuntime would be enough for an AppDomain and created this restriction. I am not sure if they actually had a requirement or not but when people objected they listened and lifted the restriction.

The removal of this restriction is a good thing as multiple WorkflowRuntime objects can be useful. The main reason is that different workflow's can have different, and conflicting, requirements of runtime services. And as a single WorkflowRuntime can have only a single runtime service configuration, and that should never be changed while the WorkflowRuntime is active. For example just think of one workflow that is long running and needs a WorkflowPersistenceService while a second is short running and should never be persisted.

Enjoy!

www.TheProblemSolver.nl
http://wiki.WindowsWorkflowFoundation.eu

with no comments
Filed under: , , , ,

The ReplicatorActivity is one of the more interesting Workflow Foundation activities to work with when you have a collection of data and want to iterate over each item. Basically just think of it as a For Each statement in regular code.

To demonstrate the behavior I have created a very small workflow that looks like this in the designer:

image

Or in case you prefer the XOML like this:

<SequentialWorkflowActivity x:Class="WorkflowConsoleApplication5.Workflow1"
                            x:Name="Workflow1"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow">
  <ReplicatorActivity x:Name="replicatorActivity1"
                      ChildInitialized="SetupChildData"
                      Initialized="SetupData"
                      ExecutionType="Sequence">
    <ReplicatorActivity.UntilCondition>
      <CodeCondition Condition="RepeatUntill" />
    </ReplicatorActivity.UntilCondition>
    <CodeActivity x:Name="codeActivity1"
                  ExecuteCode="codeActivity1_ExecuteCode" />
  </ReplicatorActivity>
</SequentialWorkflowActivity>

The codebehind file I used looks like this:

Public Class Workflow1
    Inherits SequentialWorkflowActivity

    Private Sub codeActivity1_ExecuteCode(ByVal sender As Object, _
                                          ByVal e As EventArgs)
        Dim current As CodeActivity = sender
        Dim data = GetCurrentData(current.Parent)
        Console.WriteLine("The data is '{0}'", data)
    End Sub

    Private Sub SetupData(ByVal sender As Object, _
                          ByVal e As EventArgs)
        Dim replicator As ReplicatorActivity = sender

        Dim data() As String = _
        {"One", "Two", "Stop here", "Three"}

        replicator.InitialChildData = data
    End Sub

    Private Sub RepeatUntill(ByVal sender As Object, _
                             ByVal e As ConditionalEventArgs)
        Dim replicator As ReplicatorActivity = sender
        Dim data = GetCurrentData(sender)
        Console.WriteLine("Testing with data '{0}'", data)
        If data = "Stop here" Then
            e.Result = True
        ElseIf replicator.AllChildrenComplete Then
            e.Result = True
        End If
    End Sub

    Private Sub SetupChildData(ByVal sender As Object, _
                               ByVal e As ReplicatorChildEventArgs)
        Console.WriteLine("Starting child with '{0}'", _
                          e.InstanceData)
    End Sub

    Private Function GetCurrentData(ByVal sender As Object)
        Dim replicator As ReplicatorActivity = sender
        Dim result = replicator.CurrentChildData(replicator.CurrentIndex)
        Return result
    End Function
End Class

Using the without an UntilCondition is actually quite simple. The main thing to be aware of the ExecutionType property. In this case I didn't set it and it defaults to Sequence. This means that each iteration comes after the next iteration and we can use the CurrentIndex and CurrentChildData to retrieve the piece of data we are working with. When we set the ExecutionType to Parallel the ReplicatorActivity behaves very different. In that case each branch is started at the same time so the CurrentIndex, which is scoped to the ReplicatorActivity, doesn't help you. In fact it will return the last item of the collection every time you try.

In the case of parallel execution the way to get at the data is the ChildInitialized event. This event has a parameter of type ReplicatorChildEventArgs which in turn contains a property InstanceData which is the data this iteration is going to work with. its your responsibility to pass this InstanceData on to the activity inside the ReplicatorActivity. The usual thing to do here is create a custom, possibly sequence, activity with an extra property to hold the data and store it there in the ChildInitialized event.

 

There are a few interesting, and unexpected, thing to be a aware of when you use an UntilCondition with a ReplicatorActivity. When I run this simple test workflow I receive the following output:

image

There are a couple of interesting things to note:

  1. The first time the UntilCondition is called is before the first ChildInitialized event and when we retrieve the current data it actually returns the last item. As far as I can tell there is no standard way to see this is case so if could be a problem you need to take care of it yourself. As far as I am concerned this is a serious shortcoming of the ReplicatorActivity
  2. The UntilCondition fires after and not before each loop is executed. Basically this means it is easy to use the execution result of an iteration and decide to stop further iterations but hard to prevent all remaining iteration, including the current, based on the input data. Again you would need to add some conditional logic inside the ReplicatorActivity. No problem and actually quite a nice behavior but something to be aware of.
  3. The ReplicatorActivity never stops if you don't tell it to. This is the behavior I most dislike with the ReplicatorActivity. Instead of just stopping and continuing with the next activity when all data is processed it just stops Sad. Now this isn't the case when you don't have an UntilCondition, in that case every item is processed and when done it proceeds with the next activity just as you would expect. No with an UntilCondition you are responsible for stopping and to do so the UntilCondition is actually called one more time after the last item has been processed. The thing to check for is the AllChildrenComplete property of the ReplicatorActivity. When this is true all the data has been processed and you are responsible for stopping the ReplicatorActivity. Now this might not be hard but it always is a major point of confusion and, I presume, catches everyone at least the first time. And worse I can see no benefit at all for this behavior as the ReplicatorActivity just stops and the next activity is never scheduled. As far as I am concerned this is a big "bug" in the behavior of the ReplicatorActivity.

Removing the test for the "Stop here" in the UntilCondition result in the following output:

image

As you can see there is one additional UntilCondition at the end at which time the AllChildrenComplete property is set to true.

 

Enjoy!

www.TheProblemSolver.nl
http://wiki.WindowsWorkflowFoundation.eu

with no comments
Filed under: , , , ,

The recent release of the .NET 3.5 and Visual Studio 2008 beta Service Pack 1 has started an interesting discussion over on Microsoft Watch. Joe Wilcox writes about how some of these posts seem predated and about seeing some blog post before being published, under embargo, just as previously happened with press releases. he raises an interesting question: are blog posts degraded to just just another marketing outlet and, possibly, not even written by the people under whose name they are published?

There may well be some truth in this as blog are an important communication feature. And why would a pr or marketing person ignore such an obvious opportunity. So I am sure that some blog posts are really just PR. But than again I also believe that the vast majority is real and, other that the writers conviction that MS is the best thing since sliced bread, is trying to be objective.

Read the full article by Joe Wilcox here.

Enjoy!

www.TheProblemSolver.nl
http://wiki.WindowsWorkflowFoundation.eu

with no comments
Filed under: , , ,

I recently received a copy of Pro WCF: Practical Microsoft SOA Implementation so I could review it. So did I like the book? Not really Sad

ProWcf

The problem with the book is that it wants to cover far too much and diverse material. Now covering a lot of material in a book isn't a bad thing per se but in this case it resulted in a book that doesn't really server a purpose.

Basically the book is divided into three parts. The first part is titled Introducing Windows Communication Foundation. In fact quite a large section is not about WCF but about SOA. Now there is nothing bad about discussing SOA but WCF isn't SOA or vice versa so starting a WCF book with a SOA discussion isn't a good thing as far as I am concerned.

The second part is titled Programming with WCF and this is the part that actually introduces the reader to the basics of WCF and how to use it. I found the examples and text not all that clear. For example the chapter about hosting has a section about self hosting a WCF service and another about hosting the service inside of IIS. The self hosting section seemed to be more concerned with writing a Windows service and the accompanying installer that the actual use of WCF. And the IIS hosting part seems to be more about the differences of all the IIS versions. Admittedly something that is important but I would have preferred more coverage of the WCF specific issues.

The third part is titled Advanced topics in WCF and is actually half the book. The authors cover quite a lot of material in these chapters. The result is that, although a lot is covered, most of the material is not covered to the level needed when actually doing advanced work. So basically the authors let us know about the possibilities without giving a full coverage.

Another, although minor issues, is that the book is written using Visual Studio 2005. This means that for those readers using Visual Studio 2008 some of the steps described are no longer valid.

One thing that did surprise me where the names of the technical reviewers named in the book. It appears two of the three are also part of the team of authors. So much for pear reviews Sad

So can I recommend this book? No not really as I don't think this one is up to the standard I have come to expect from the Apress  Pro series. Both for the novice and experienced WCF developer there are better books out there.

www.TheProblemSolver.nl
wiki.WindowsWorkflowFoundation.eu

with 2 comment(s)
Filed under: , ,

Attached are the session slides and samples from my Visual Studio Tools for Office session I did in Galway earlier today. Hope you enjoyed the presentation as much as I did Smile

Download them here.

www.TheProblemSolver.nl
http://wiki.WindowsWorkflowFoundation.eu

with 1 comment(s)
Filed under: , , ,

Attached are the session slides and samples from my Workflow Foundation in a Service Oriented world I did earlier today in Galway, Ireland. Hope you enjoyed the presentation as much as I did Smile

Download them here.

www.TheProblemSolver.nl
http://wiki.WindowsWorkflowFoundation.eu

Wat gebeurt er allemaal voor .NET ontwikkelaars in Nederland? Best veel geloof dat maar. En niet alleen de opvallende zaken als een DevDays of een SDC maar er zijn veel meer bijeenkomsten. Alleen hoe weet je wat er allemaal georganiseerd word en door wie?

Tot nu toe moest je daar een hele serie websites en blogs voor nalopen, niet echt handig als je het mij vraagt. Daarom heb ik besloten die informatie te verzamelen op een enkele plaats. Zeg maar een one stop shop voor .NET bijeenkomsten die interessant zijn voor Nederlandse .NET ontwikkelaars. EN waar kan je dat dan wel vinden? Op de site www.DotNetEvents.nl! Mooi in een overzicht per maand dus de manier om te zien of er iets interessants georganiseerd wordt waar je ook naar toe wil.

Uiteraard kan het zijn dat er bijeenkomsten zijn waar ik ook niets van weet. Als je er een weet die niet op het overzicht staat stuur me dan even een berichtje zodat ik die toe kan voegen aan de lijst.

Tot de volgende bijeenkomst!

with no comments
Filed under: ,

A few days ago I blogged about the "Publish as Web Service" feature not working for me with VS2008. It turns out this is another case if Vista and VS2008 not being quite compatible Sad.

I was running VS2008 normally and I have User Account Control (UAC) enabled. Not that I am a big fan of UAC but I believe it is a useful step along the security road and people should leave it turned on. And I do as I preach.

But if you start VS2008 with administrator privileges, ie right click and select "Run as administrator", the "Publish as Web Service" feature works just fine.

Enjoy!

www.TheProblemSolver.nl
http://wiki.WindowsWorkflowFoundation.eu

More Posts Next page »