Validation error message: "An error occurred while attempting to extract the target object of type 'System.Activites.InArgument' from the method call expression .Get"
When using the (non-Generic) version of InArgument, you may see the following error message during validation:
The private implementation of activity '<activity>' has the following validation error: "An error occurred while attempting to extract the target object of type 'System.Activites.InArgument' from the method call expression <activity><property>.Get". Note that the expression determining the object of type 'System.Activities.InArgument' must not require the runtime context.
Error: The sub-expression for the object of type 'System.Activities.InArgument' resulted in a location reference that is not visible at this scope.
The cause for this error is that the default reflection logic that happens during CacheMetadata to tell the runtime about the signature of an activity only looks for arguments with generic types.
Two solutions for this problem are:
- Use the generic version of InArgument with the anticipated type
- Override CacheMetadata and add the InArgument to the activity signature explicitly, as in the following code snippet:
protected override void CacheMetadata(ActivityMetadata metadata)
this.myValue = MyValue ?? new InArgument<object>();
RuntimeArgument arg = new RuntimeArgument("MyValue", this.myValue.ArgumentType, ArgumentDirection.In);