Custom activity: setting value of bound parameter fails  
Author Message
RonaldK





PostPosted: Windows Workflow Foundation, Custom activity: setting value of bound parameter fails Top

Hi all,

We have created a DSL and from that we generate a workflow definition using XOML.

All activities in the workflow 'work' on a private member of the workflow. The private member is derived from a base class 'DomainObject'.
The workflow accepts a parameter (input and output) of the same type as the private member.

We created a custom activity containing 3 properties for binding the parameter, binding the private member and a boolean indicating whether to assign the parameter to the member or vice versa.

At runtime, when the activity assigns the 'property bound to the private member' to the 'property bound to the value of the parameter' an exception occurs:

An exception of type 'System.Reflection.TargetException' occurred in mscorlib.dll but was not handled in user code

Additional information: Object does not match target type.

Assigning the 'property bound to the parameter' to the 'property bound to the private member' does work well.

Q: Am i trying the impossible (I sure don't think so), or what am I doing wrong, or is there a better solution to do what I want (without writing code beside)

The code of workflow definition:
<StateMachineWorkflow ...>
<
StateMachineWorkflow.Parameters>
<
wcm:ParameterDeclaration Name="DomeinObject" Type="Verzekeraar.Producten.AutoOfferte" Direction="Ref" xmlns:wcm="ComponentModel" />
</
StateMachineWorkflow.Parameters>
...
<
State ID="Varianten_Overzicht">
<
EventDriven ID="OfferteAanmakenEventDriven">
...
<
Mapping XmlNamespace="Certigo_Activities" ClrNamespace="Certigo.Activities" Assembly="Certigo.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" >
<
ns0:ParamPropertySyncActivity ParamToProperty="False" ID="OfferteAanmaken_ParamPropertySyncActivity" xmlns:ns0="Certigo_Activities">
<
ns0:ParamPropertySyncActivity.DomeinObjectParameter>
<
wcm:ActivityBind Path="Parameters[&quot;DomeinObject&quot;].Value" ID="{/Workflow}" xmlns:wcm="ComponentModel" />
</
ns0:ParamPropertySyncActivity.DomeinObjectParameter>
<
ns0:ParamPropertySyncActivity.DomeinObjectProperty>
<
wcm:ActivityBind Path="_domeinObject" ID="{/Workflow}" xmlns:wcm="ComponentModel" />
</
ns0:ParamPropertySyncActivity.DomeinObjectProperty>
</
ns0:ParamPropertySyncActivity>
<
SetState TargetState="Eind_1" ID="OfferteAanmakenSetState" />
</
EventDriven>
...
</
State>
</
StateMachineWorkflow>

Implementation of the activity:

-- Function Execute
protected
override Status Execute(ActivityExecutionContext context)
{
if (_paramToProperty == true)
{
DomeinObjectProperty = DomeinObjectParameter;
}
else
{
DomeinObjectParameter = DomeinObjectProperty;
}
return Status.Closed;
}

-- Properties
public static DependencyProperty DomeinObjectParameterProperty = DependencyProperty.Register("DomeinObjectParameter", typeof(System.Object), typeof(Certigo.Activities.ParamPropertySyncActivity));
[
DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[
ValidationVisibilityAttribute(ValidationVisibility.Optional)]
[
BrowsableAttribute(true)]
public object DomeinObjectParameter
{
get
{
return ((Object)(base.GetValue(Certigo.Activities.ParamPropertySyncActivity.DomeinObjectParameterProperty)));
}
set
{
base.SetValue(Certigo.Activities.ParamPropertySyncActivity.DomeinObjectParameterProperty, value);
}
}
public static DependencyProperty DomeinObjectPropertyProperty = DependencyProperty.Register("DomeinObjectProperty", typeof(System.Object), typeof(Certigo.Activities.ParamPropertySyncActivity));
[
DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[
ValidationVisibilityAttribute(ValidationVisibility.Optional)]
[
BrowsableAttribute(true)]
public object DomeinObjectProperty
{
get
{
return ((Object)(base.GetValue(Certigo.Activities.ParamPropertySyncActivity.DomeinObjectPropertyProperty)));
}
set
{
base.SetValue(Certigo.Activities.ParamPropertySyncActivity.DomeinObjectPropertyProperty, value);
}
}



Software Development for Windows Vista8  
 
 
Angel Azcarraga - MSFT





PostPosted: Windows Workflow Foundation, Custom activity: setting value of bound parameter fails Top

Have you tried this in future releases (i.e. RTM)

This should work just fine. Please make another post if you're still having this issue.

Thanks!
Angel