locked
Wrong xaml representation of an Assign activity when setting enum values RRS feed

  • Question

  • Hello,

    We are using the workflow designer hosted in a custom WPF application to allow end-user workflow creation.

    The workflow definition is stored using the XAML representation, means simply by using the value of the 'Text' property from the 'WorkflowDesigner'
    To load the workflow for execution/re-editing we use 'ActivityXamlServices.Load'.

    Both worked fine until now.


    Now someone created a workflow with a 'Assign' activity and uses this to assign an enum value to a class instance.
    Creating the workflow and saving the workflow definition worked fine, but the resulting XAML string cannot be loaded with 'ActivityXamlServices.Load' anymore.


    The error we are getting is:
    'Character '+' was unexpected in string 'cccdr:MyClass+MyEnum'. Invalid XAML type name.' Line number '74' and line position '36'


    The assign operation in XAML looks pretty similar to this:
     <Assign DisplayName="Assign something" sap:VirtualizedContainerService.HintSize="242,58">
      <Assign.To>
       <OutArgument x:TypeArguments="cccdr:MyClass+MyEnum">[myClassInstance.MyEnumProperty]</OutArgument>
      </Assign.To>
      <Assign.Value>
       <InArgument x:TypeArguments="cccdr:MyClass+MyEnum">[MyNamespace.MyClass.MyEnum.EnumValueOne]</InArgument>
      </Assign.Value>
    </Assign>



    Are there any known issues using the Assign activity to assign enum values?

    Thanks for any advices!

    Thomas
    Wednesday, June 30, 2010 12:31 PM

Answers

  • Hi Thomas,

    I think it is XAML limitation that it does not allow such nested type. The only workaround in my mind is that we don't use XAML in the cases that you need nested types. if you write them in code, they will run pretty well.

    if you read this page, it said no nested type too: http://msdn.microsoft.com/en-us/library/ms753379.aspx

    thanks,

    Anders


    This posting is provided "AS IS" and confers no rights or warranties.
    • Proposed as answer by Anders Liu - MSFT Thursday, July 1, 2010 2:42 AM
    • Marked as answer by Kalvis Thursday, July 1, 2010 7:58 AM
    Thursday, July 1, 2010 2:42 AM

All replies

  • Hi Thomas,

    Is MyEnum a nested type in MyClass? I think nested type is not supported in current designer. Could you try put it out of MyClass? 

    thanks,

    Anders


    This posting is provided "AS IS" and confers no rights or warranties.
    Wednesday, June 30, 2010 2:37 PM
  • Hi Anders,

    thanks for the fast reply, this has been pretty helpful!

    The enum is indeed nested into MyClass.

    And you seem to be fully right by saying nested types are not supported in the designer currently.
    Cause when I created a new class and tested both cases (Enum as nested type and Enum defined outside of the class) the nested Enum always threw the error, while the Enum defined outside of the class works without any issues.

     

    The problem we have now is that workflows have been built in on top of our existing business model, which itself consists of a server and multiple client projects.
    Means changing every nested Enum has a huge impact on a number of VS projects and also our business logic...

    Anyone knows if there are proposed workarounds or solutions to overcome this issue?

    Thanks

    Thomas

    Wednesday, June 30, 2010 4:20 PM
  • Hi Thomas,

    I think it is XAML limitation that it does not allow such nested type. The only workaround in my mind is that we don't use XAML in the cases that you need nested types. if you write them in code, they will run pretty well.

    if you read this page, it said no nested type too: http://msdn.microsoft.com/en-us/library/ms753379.aspx

    thanks,

    Anders


    This posting is provided "AS IS" and confers no rights or warranties.
    • Proposed as answer by Anders Liu - MSFT Thursday, July 1, 2010 2:42 AM
    • Marked as answer by Kalvis Thursday, July 1, 2010 7:58 AM
    Thursday, July 1, 2010 2:42 AM
  • Hi Anders,

    ok, thanks for clarifiyng this!

    As a workaround we'll now verify the defined workflow and make sure nested types are not used in an activity (which also applies to structs we have)

    Thomas
    Thursday, July 1, 2010 7:58 AM