Returning a Custom Type OutArgument From WF 4.0
In Workflow 4.0 it is easy to return values. All you have to do is create a set of out arguments and provide the arguments with values. The values will be available in a dictionary in the WorkflowApplicationCompletedEventArgs parameter of the Completed handler.
There is one simple step that is often being forgotten, that is to create an instance of the value to return.
If the OutArgument is of type string (or other primitive) all you have to do is set the string value to the argument. But if the argument is of a custom type you have to create an instance of this type as a variable (in the relevant scope) and set this variable to the OutArgument.
When thinking of it this is exactly what we do in code but when working in the designer we would expect the designer to automatically create the instance of the OutArgument for us. Unfortunately this is not the case.
Manu