none
How do you create an empty workflow when hosting the designer

    Question

  • When the WF designer is hosted in VS and you start a new 'Workflow Console Application' project, an empty workflow is created containing a number of useful imports and nothing else. The designer seems quite happy to swallow this workflow, but when you present the same xaml to ActivityXamlServices.Load() and use that as the basis for a new workflow/activity (WorkflowDesigner.Load()) in a hosted designer, it chokes on it with a 'NullReferenceException at System.Activities.Presentation.View.ImportDesigner.OnContextChanged()'.

    Is there some VS magic involved here, or have I just screwed up?

    Regards,

    Nigel
    Wednesday, February 24, 2010 4:39 AM

All replies

  • Nigel,

    Can you please try loading the xaml using WorkflowDesigner.Load() directly specifying the file name ? ( or setup wd.Text to hold xaml and then call Load() ?

    The designer tries to preserve the imports when the activity is empty by attaching it to the ActivityBuilder object that represensts the xaml defining an Activity type.

    Also make sure you have the correct reference assemblies setup in your rehosting app using the context item

    AssemblyContextControlItem ( you can get to this through wd.Context.Items)


    ramrajprabu
    Wednesday, February 24, 2010 5:24 AM
  • Ok, loading the xaml into the Text property and then calling Load() worked perfectly - thanks. What I don't uynderstand is why that would be any different from using ActrivitiesXamlServices.Load() and passing the resultant Activity to the designer in the Load() method? It obviously is, but it doesn't seem as though it should be?

    Regards,

    Nigel Page
    Wednesday, February 24, 2010 10:07 PM