locked
DynamicUpdateMap RRS feed

  • Question

  • I have a very simple .xaml workflow... FlowChart>Sequence>Receive>SendReply with a CorrelationInitializer...

    I'm getting error(s) when I use DynamicUpdateServices.PrepareForUpdate(someActivityBuilder ab);

    The error reads:

    XamlObjectWriterException was unhandled

    Cannot create unknown type

    '{http://schemas.microsoft.com/netfx/2009/xaml/activities}Variable({http://schemas.microsoft.com/netfx/2009/xaml/servicemodel}

    When I view the code... I find that it's failing on the CorrelationHandle

    //...

    // Namespaces

    xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:p="http://tempuri.org/" xmlns:p1="http://schemas.microsoft.com/netfx/2009/xaml/servicemodel" xmlns:pp="clr-namespace:datamodels.Process;assembly=datamodels" xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"

    //...

    <p1:Receive x:Name="__ReferenceID1" sap2010:WorkflowViewState.IdRef="Receive_1" OperationName="Operation1" ServiceContractName="p:IService"> <p1:Receive.CorrelationInitializers> <p1:RequestReplyCorrelationInitializer> <p1:RequestReplyCorrelationInitializer.CorrelationHandle> <InArgument x:TypeArguments="p1:CorrelationHandle"> <VariableValue x:TypeArguments="p1:CorrelationHandle" Variable="{x:Reference __ReferenceID0}" /> </InArgument> </p1:RequestReplyCorrelationInitializer.CorrelationHandle> </p1:RequestReplyCorrelationInitializer> </p1:Receive.CorrelationInitializers> <p1:ReceiveParametersContent> <OutArgument x:TypeArguments="pp:DataObject" x:Key="myDataObject" /> </p1:ReceiveParametersContent> </p1:Receive>

    The error is pointing to this line:

    <VariableValue x:TypeArguments="p1:CorrelationHandle" Variable="{x:Reference __ReferenceID0}" />

    the p1 namespace is pointing like this:  xmlns:p1="http://schemas.microsoft.com/netfx/2009/xaml/servicemodel"

    It's breaking here...  The namespace is not providing type information about the CorrelationHandle...

    How can I get the ActivityBuilder to handle this namespace?

    Thanks

     

     

     



    • Edited by deerhaq360 Saturday, January 18, 2014 7:01 PM
    Saturday, January 18, 2014 7:00 PM

Answers

  • // Instead of creating the ActivityBuilder, create the WorkflowService.
    // Please try the code below and let me know how it goes.
    
    using System;
    using System.IO;
    using System.Xaml;
    using System.Activities;
    using System.Activities.Statements;
    using System.Activities.XamlIntegration;
    using System.ServiceModel.Activities;
    using System.Activities.DynamicUpdate;
    
    namespace TestWF
    {
        class Program
        {
            static void Main(string[] args)
            {
                if (args.Length < 1)
                {
                    Console.WriteLine("Must include filename");
                    return;
                }
                string filename = args[0];
                if (!File.Exists(filename))
                {
                    Console.WriteLine(filename + " Does not exist");
                    return;
                }
                XamlXmlReader xmlRdr  = new XamlXmlReader(filename);
                XamlReader xamlRdr    = ActivityXamlServices.CreateBuilderReader(xmlRdr);
                WorkflowService wfSrv = XamlServices.Load(xamlRdr) as WorkflowService;
                if (wfSrv == null)
                {
                    Console.WriteLine(filename + " is not a workflowService");
                    return;
                }
    
                Activity a = wfSrv.Body;
    
                DynamicUpdateServices.PrepareForUpdate(a);
    
                Console.WriteLine("Done!");
            }
        }
    }
    

    Tuesday, February 4, 2014 11:21 PM

All replies

  • A little help here...

    I'm testing a scenario where I need to fix a bug on persisted workflows...

    I'm attempting to use a "DynamicUpdateMap" to update persisted workflow instances.  The documentation describes the process to update persisted workflows as follows:

    1. Prepare workflow for update
    2. Update the workflow definition to reflect the desired changes
    3. Create the update map
    4. Apply the update map to persisted workflow instances

    The tutorial describes this process on a .xaml file...

    //...

    XamlXmlReader xamlReader = new XamlXmlReader("somePath\someActivity.xaml", readerSettings); ActivityBuilder ab = XamlServices.Load(ActivityXamlServices.CreateBuilderReader(xamlReader)) as ActivityBuilder; DynamicUpdateServices.PreparareForUpdate(ab);

    //...

    However, I am using a .xamlx in my scenario... When I try to perform this process using .xamlx, I get an exception on Line 1...  It would seem that ActivityXamlServices.CreateBuilderReader() can only parse "Activity" types (not "WorkflowService" types)

    It's clear to me that I cannot get a "DynamicUpdateMap" from a  "WorkflowService".

    So, How can I correct bugs on persisted WorkflowServices (.xamlx) instances?

    Should I define the entire workflow in a .xaml file, and then drop that .xaml file into the .xamlx?

    What is actually being persisted to the "InstanceStore" when using workflow services (.xamlx)??

    Thanks.


    • Edited by deerhaq360 Saturday, January 18, 2014 3:59 AM
    • Merged by Angie Xu Monday, January 20, 2014 12:38 AM Merge these questions together, it's helpful to find the root of this problem.
    Saturday, January 18, 2014 3:59 AM
  • Hi deerhaq

    The update map contains the information needed by the workflow runtime to update a persisted workflow instance that was started using the original workflow definition contained in the ActivityBuilder so that it completes using the updated workflow definition.

    private static void CreateUpdateMaps(ActivityBuilder wf, string name)
    {
        // Create the UpdateMap.
        DynamicUpdateMap map =
            DynamicUpdateServices.CreateUpdateMap(wf);
    
        // Serialize it to a file.
        string path = Path.Combine(mapPath, name);
        DataContractSerializer sz = new DataContractSerializer(typeof(DynamicUpdateMap));
        using (FileStream fs = System.IO.File.Open(path, FileMode.Create))
        {
            sz.WriteObject(fs, map);
        }
    }
    

    In addition, this is good reference for you, How to: Update the Definition of a Running Workflow Instance

    hope it helps.

    Regards


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, January 22, 2014 2:50 AM
  • Is Dot NET 4.0.3 installed on the machine, which is required for the State Machine Workflows to work?
    Please try http://support.microsoft.com/kb/2600211 and see if it resolves the issue.
    Wednesday, January 22, 2014 10:20 PM
  • Just checking if there is an update?

    Did http://support.microsoft.com/kb/2600211 resolves the issue?

    Friday, January 24, 2014 10:21 PM
  • Thanks for your thoughts... I'm using .net 4.5

    I don't think the problem is with State Machine.

    Please try to repeat the scenario...

    1. Create a Workflow Application
    2. Add Receive/SendReply activity
    3. Try to run "ActivityBuilder" on the .xamlx file

    So far, I have not been able to get Activity Builder to work.  I'm getting exceptions on .xamlx file. (Line1 exception suggests that ActivityBuilder doesn't work on .xamlx... That is, the .xamlx root tag is a "WorkflowService" and the root tag of a .xaml is actually an "Activity")

    On another note:

    When I do the same thing on a .xaml activity...

    I'm getting exception on the CorrelationHandle namespace reference. (ViewCode to see the namespaces and tags)

     

    Saturday, January 25, 2014 3:53 AM
  • // Instead of creating the ActivityBuilder, create the WorkflowService.
    // Please try the code below and let me know how it goes.
    
    using System;
    using System.IO;
    using System.Xaml;
    using System.Activities;
    using System.Activities.Statements;
    using System.Activities.XamlIntegration;
    using System.ServiceModel.Activities;
    using System.Activities.DynamicUpdate;
    
    namespace TestWF
    {
        class Program
        {
            static void Main(string[] args)
            {
                if (args.Length < 1)
                {
                    Console.WriteLine("Must include filename");
                    return;
                }
                string filename = args[0];
                if (!File.Exists(filename))
                {
                    Console.WriteLine(filename + " Does not exist");
                    return;
                }
                XamlXmlReader xmlRdr  = new XamlXmlReader(filename);
                XamlReader xamlRdr    = ActivityXamlServices.CreateBuilderReader(xmlRdr);
                WorkflowService wfSrv = XamlServices.Load(xamlRdr) as WorkflowService;
                if (wfSrv == null)
                {
                    Console.WriteLine(filename + " is not a workflowService");
                    return;
                }
    
                Activity a = wfSrv.Body;
    
                DynamicUpdateServices.PrepareForUpdate(a);
    
                Console.WriteLine("Done!");
            }
        }
    }
    

    Tuesday, February 4, 2014 11:21 PM
  • Hi Shamik

    I finally found time to try out your suggestion... It seem to have work.  That is it created a .map file.

    I am now stuck on the modification part (step 2)...  All of the examples modify the "prepared" workflow in code.

    However, I am using the designer...  Will the DynamicUpdateServices.CreateUpdateMap()  work when I make modifications to the workflow using the designer?  So far, I have not been able to successfully update the persisted workflow.

    Thanks,

    deerhaq

    Saturday, March 1, 2014 3:21 PM
  • Hi Shamik,

    After torching Saturday night, I think I'm one step closer.

    I created a simple Flowchart composed like this:

    1. RECEIVE: Operation1| Parameters: (int)ID, (string)Firstname | CreateInstance=true, CorrelationInitializer: (int)ID
    2. SEND REPLY TO RECEIVE: (This simply echoes the Firstname) then proceed to the DO WHILE
    3. DO WHILE: Condition Status == "In-Work" | This DO WHILE has a PICK with a single branch that contains a RECEIVE: Operation 2 | Parameter: (int)ID, Correlates on (int)ID

    So, I create an instance of this workflow and I want to add a step.

    I modify the workflow to include another DO WHILE (after step 3.) containing a RECEIVE activity that correlates on (int)ID with RECEIVE: Operation 3.

    Something like this...

    I then proceed to update the persisted workflow that is blocking on step 3 (the first DO WHILE). waiting to receive Operation 2.

    The error messages say;

    1. Cannot remove activity '13: VariableValue<CorrelationHandle>' because it is currently executing.
    2. Cannot remove activity '34: EnvironmentLocationReference<String>' because it is currently executing.
    3. Cannot remove activity '35: EnvironmentLocationReference<CorrelationHandle>' because it is currently executing

    Although I'm not making changes to the blocking activities (Operation 2), I'm getting these errors messages. I assumed that simply adding an operation that correlates in the same way the previous operation does would be simple.

    Can you help my understand these error messages?

    Should I use one of the other DynamicUpdateServices.CreateUpdateMap overloads?

    Thanks,

    deerhaq



    • Edited by deerhaq360 Sunday, March 2, 2014 3:31 PM
    Sunday, March 2, 2014 3:28 PM
  • Hi,

    Did you by any chance solve the issue with 'Cannot remove activity..' error. I am getting the same error as above when trying to update the workflows in Instance Store.

    Thanks,

    Waldo

    Tuesday, March 3, 2015 9:32 AM
  • Same problem, any ideas?
    Friday, August 7, 2015 9:52 PM