Custom activity: setting value of bound parameter fails

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:ParameterDeclarationName="DomeinObject"Type="Verzekeraar.Producten.AutoOfferte"Direction="Ref"xmlns:wcm="ComponentModel" />
</
StateMachineWorkflow.Parameters>
...
<
StateID="Varianten_Overzicht">
<
EventDrivenID="OfferteAanmakenEventDriven">
...
<?
MappingXmlNamespace="Certigo_Activities" ClrNamespace="Certigo.Activities" Assembly="Certigo.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null"?>
<
ns0:ParamPropertySyncActivityParamToProperty="False"ID="OfferteAanmaken_ParamPropertySyncActivity"xmlns:ns0="Certigo_Activities">
<
ns0:ParamPropertySyncActivity.DomeinObjectParameter>
<
wcm:ActivityBindPath="Parameters[&quot;DomeinObject&quot;].Value"ID="{/Workflow}"xmlns:wcm="ComponentModel" />
</
ns0:ParamPropertySyncActivity.DomeinObjectParameter>
<
ns0:ParamPropertySyncActivity.DomeinObjectProperty>
<
wcm:ActivityBindPath="_domeinObject"ID="{/Workflow}"xmlns:wcm="ComponentModel" />
</
ns0:ParamPropertySyncActivity.DomeinObjectProperty>
</
ns0:ParamPropertySyncActivity>
<
SetStateTargetState="Eind_1"ID="OfferteAanmakenSetState" />
</
EventDriven>
...
</
State>
</
StateMachineWorkflow>

Implementation of the activity:

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

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

[12892 byte] By [RonaldK] at [2007-12-18]
# 1

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

AngelAzcarraga-MSFT at 2007-9-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified