ExpressionTranslator Error when publishing Workflows

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

When working with Workflows, which running in Workflow Manager (SP devs call it usually SharePoint Workflow) on-premises or in Office 365 you might get following error:

Expression: DateTime.Now.ToString()

"Property access conversion to an activity is not supported for property 'CurrentDomain' defined on type 'System.AppDomain'."

This error occurs during Translation of the workflow. The translation is a step in process of publishing of the Workflow in Workflow Manager. it basically translates all expressions in Workflow Activities in a form
required by XAML, before the workflow is published (installed) to the host.

Following picture shows an expression which will cause described error:

image

The picture left below shows XAML expression which is translated in a bit different expression (picture right below). Note that DateTime.Now.ToString() is in this case not evaluated. It is a pure string like “BLA, BLA”.

   <Assign sap2010:WorkflowViewState.IdRef="Assign_1">
      <Assign.To>
        <OutArgument x:TypeArguments="x:String">
          <mca:CSharpReference 
            x:TypeArguments
="x:String">result</mca:CSharpReference>
        </OutArgument>
      </Assign.To>

      <Assign.Value>
        <InArgument
         x:TypeArguments="x:String">DateTime.Now.ToString()
        </InArgument>

      </Assign.Value>

    </Assign>

image

 

Right now, it is not possible to access properties within Expressions. To make this working you will unfortunately have to define the type to access properties. For example, if you want to access MyCustomTye.MyProp you will have to create the activity like GetMyCustomPropActivity and define InArgument<MyCustomTye> and OutArgument<yourproptrustedtype>. The later one will hold the value of MyProp.
This activity have to extend trusted surface (se URL below) even if the type is common .NET type like DateTime.

How to create custom activities:

http://developers.de/blogs/damir_dobric/archive/2012/09/16/workflow-trusted-surface.aspx

http://msdn.microsoft.com/en-us/library/windowsazure/jj193517(v=azure.10).aspx


Posted Mar 26 2013, 10:43 PM by Damir Dobric
developers.de is a .Net Community Blog powered by daenet GmbH.