Problem with custom CallExternalMethodActivity

I have successfully implement a local service allowing me to pass parameers into the workflow. Now I want the workflow to return data. I have created a custom activity derived from CallExternalMethodActivity. I have followed the example as outlined athttp://windowssdk.msdn.microsoft.com/en-us/library/ms734768.aspx.

I then added the custom activity to my workflow. I attempted to then bind the data property under the Properties of the activity. It is here when I receive an error.

Could not bind property "ReturnData".

Object of type "System.Workflow.ComponentModel.ActivityBind" cannot be converted to type "System.Collections.Specialized.IOrderedDictionary".

NOTE: it still creates the property binding in the workflow code. It simply will not allow me to bind it to the activity.

What am I doing wrong? I also found this error in another example I located on the web. I have included the code for my custom activity.

Thanks

Bill

[ToolboxItemAttribute(typeof(System.Workflow.ComponentModel.Design.ActivityToolboxItem))]
public partial class SendDataActivity : CallExternalMethodActivity
{
#region Constructors

public SendDataActivity()
{
base.InterfaceType = typeof(IRequestService);
base.MethodName = "SendData";
}

#endregion Constructors

#region Properties

public static DependencyProperty returnDataProperty = DependencyProperty.Register("returnData", typeof(IOrderedDictionary), typeof(SendDataActivity));

[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public override System.Type InterfaceType
{
get
{
return base.InterfaceType;
}
set
{
throw new System.InvalidOperationException("Cannot set InterfaceType on a derived CallExternalMethodActivity.");
}
}

[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public override string MethodName
{
get
{
return base.MethodName;
}
set
{
throw new System.InvalidOperationException("Cannot set MethodName on a derived CallExternalMethodActivity.");
}
}

[Editor()]
[TypeConverter(typeof(ActivityBindTypeConverter))]

[System.Workflow.ComponentModel.Compiler.ValidationOptionAttribute(System.Workflow.ComponentModel.Compiler.ValidationOption.Required)]
public IOrderedDictionary ReturnData
{
get
{
return ((IOrderedDictionary)(this.GetValue(SendDataActivity.returnDataProperty)));
}
set
{
this.SetValue(SendDataActivity.returnDataProperty, value);
}
}

#endregion Properties

#region Overriden Methods

protected override void OnMethodInvoking(System.EventArgs e)
{
this.ParameterBindings["returnData"].Value = this.ReturnData;
base.OnMethodInvoking(e);
}

#endregion Overriden Methods

}

[3452 byte] By [Bill_W] at [2007-12-23]
# 1

not sure, but it seems that you probably need to define an activityBindTypeConverter for IOrderedDictionary

Serge

SergeLuca at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 2

Hmm I was thinking of that possibility, but I cannot believe I need to go that far. The example at http://windowssdk.msdn.microsoft.com/en-us/library/ms734768.aspx does not hint at this. In fact, I tried doing the example using string and got the same error except it could not convert the ActivityBind to a string. Other examples use the same technique.

I have recently upgraded to the July CTP.

Bill

Bill_W at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 3

Any example on how to use the ActivityBindTypeConverter?

Bill

Bill_W at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 4

FYI, I have added the ConverterType attribute to my property on my custom activity.

[TypeConverter(typeof(ActivityBindTypeConverter))]

I even attempted to add this to the property created on my workflow class. No luck. Any other ideas?

Thanks

Bill

Bill_W at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 5

Bill,

I've a suggestion:

to generate your activities from your interface, why don't you use wca.exe ? (just to see if that fixes your issue and compare the generated code...)

see: http://windowssdk.msdn.microsoft.com/en-us/library/ms734534.aspx

Serge

SergeLuca at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 6

Thanks Serge. I thought about it as well. I did generate my Invokes and Sinks for comparison and they were slightly differnent. Wca.exe is a nice tool and eases the pain of creating the communication activities.

Bill_W at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified