Question

I'm having trouble finding any worthwhile documentation on the new version of WorkflowServiceHost that ships with .NET 4 / VS 2010 Beta 2.

The new version of the WorkflowServiceHost now lives in System.ServiceModel.Activities and has different contructors than the old, .NET 3.x version that lived in System.ServiceModel.

I want to be able to load my workflow by passing in the type like this previous constructor in the .NET 3.x version allowed...

public WorkflowServiceHost(Type workflowType, params Uri[] baseAddress)

My issue is that I don't have the information any of the other contructors need at compile time (I was planning to infer the Type of my workflow via Type.GetType(string) as I will only have access to the actual Workflow activities at runtime).

Is there any other way that I can host a workflow that has been loaded at runtime?

Thanks for all your help in advance :)

Was it helpful?

Solution

In WF4 you pass the actual workflow definition as an activity tree instead of a type as you did before. If you have the type creating an object should be simple using something like Activator.CreateInstance(). Using an activity tree instead of a type has some benefits because you can create the objects on the fly of use the ActivityXamlServices.Load() to read a XAML file.

The WCF part of the WorkflowServiceHost can be done completely in the config file if you like. No need to pass a baseAddress in with the constructor.

An alternative to the WorkflowServiceHost is using a WorkflowApplication. This still requires you to add an activity tree into the constructor though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top