Windows > .NET Framework 4 Beta 2 Forums > .NET Framework 4: Workflow Foundation - Beta 2 > Saving workflow from a rehosted designer in WF 4.0
Ask a questionAsk a question
 

AnswerSaving workflow from a rehosted designer in WF 4.0

  • Friday, November 06, 2009 3:02 PMvance.souders Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I've rehosted the WF 4.0 designer, and I am able to save out and restore the current state of the designer using WorkflowDesigner.Save() / Load() but what I'm not clear on is how to save the actual workflow represented in the designer in such a way that it can be executed later. 

    I've come across references to .xoml but I'm not sure how to get the rehosted designer to output in this format.  Any help would be much appriciated.

    EDIT:

    I was able to load and execute the exported workflow using the following simple code.  Are there any issues with directly using the file produced from WorkflowDesigner.Save() in this manner?:
     
    Activity a = XamlServices.Load(@"C:\Users\User\Desktop\basic_test") as Activity;
    WorkflowInvoker.Invoke(a);
    • Moved byAndrew_ZhuMSFTMonday, November 09, 2009 2:06 AM (From:Windows Workflow Foundation)
    •  

Answers

  • Monday, November 09, 2009 5:55 AMAndrew Au - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,

    To understand this problem fully, we have to understand there are two types of XAML files.

    The first type of XAML files is representing an activity (in fact, of arbitrary type) object. The API you are using is designed to load those files.
    The second type of XAML files is used to represent an activity class. In our designers (Visual Studio or rehosted), we are actually designing those classes.

    One can recognize the difference of these two types of XAML files by reading the first element. If the XAML file has an x:Class attribute, then it is of the second type.

    To load and execute those second type XAML files, you can use ActivityXamlServices.Load(). This method will return an instance of DynamicActivity, so that you can use WorkflowInvoker to execute it.

    Thanks,
    Andrew

All Replies

  • Monday, November 09, 2009 5:55 AMAndrew Au - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,

    To understand this problem fully, we have to understand there are two types of XAML files.

    The first type of XAML files is representing an activity (in fact, of arbitrary type) object. The API you are using is designed to load those files.
    The second type of XAML files is used to represent an activity class. In our designers (Visual Studio or rehosted), we are actually designing those classes.

    One can recognize the difference of these two types of XAML files by reading the first element. If the XAML file has an x:Class attribute, then it is of the second type.

    To load and execute those second type XAML files, you can use ActivityXamlServices.Load(). This method will return an instance of DynamicActivity, so that you can use WorkflowInvoker to execute it.

    Thanks,
    Andrew