Dynamic Properties sample cannot work with XOML workflow  
Author Message
Ethan Hunt





PostPosted: Windows Workflow Foundation, Dynamic Properties sample cannot work with XOML workflow Top

Anyone got this activity sample and tried

If I put the dynamic in code based workflow, it works fine. however, when i put on xoml based workflow, i got the following error at compile time.

Error loading workflow

An error occured while loading the workflow. Pls correct the following error and try reloading the document to view the workflow.
CreateInstance failed for type 'System.Workflow.ComponentModel.WorkflowParameterBindingCollection'. No parameterless constructor defined for this object..

Can any help me pls





Software Development for Windows Vista6  
 
 
Tom Lake - MSFT





PostPosted: Windows Workflow Foundation, Dynamic Properties sample cannot work with XOML workflow Top

Remove the setter from the Parameters property so that it looks like the following:

[Description("Parameters Collection")]

[Category("Dynamic")]

[Browsable(false)]

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]

public WorkflowParameterBindingCollection Parameters

{

get

{

return ((WorkflowParameterBindingCollection)(base.GetValue(DynamicActivity.ParametersProperty)));

}

}



 
 
Christof





PostPosted: Windows Workflow Foundation, Dynamic Properties sample cannot work with XOML workflow Top

I have build a similar sample, based upon same sample code for dynamic properties; if I follow your advice, the error indeed dissapears but another one pops up. (Not sure is that's the case in the original sample though.)

The error I get is: Error 2 Could not deserialize object. Serializer for type 'Samples.myActivity' threw an exception during deserialization. Exception was thrown with error message 'Type 'System.Workflow.ComponentModel.WorkflowParameterBindingCollection' for dependency property 'ParameterBindings' does not match with value type 'System.Workflow.ComponentModel.WorkflowParameterBinding'.
Parameter name: value'.

My serialized xoml looks like:

<ns0:myActivity x:Name="WriteTextAndInteger" MyBooleanProperty="False">

<ns0:myActivity .ParameterBindings>

<WorkflowParameterBinding ParameterName="MySampleTextData">

<WorkflowParameterBinding.Value>

<ns1:String xmlns:ns1="clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">test</ns1:String>

</WorkflowParameterBinding.Value>

</WorkflowParameterBinding>

</ns0:myActivity.ParameterBindings>

</ns0:myActivity >

My parameterbindings property is coded like this:

public static DependencyProperty ParameterBindingsProperty =

System.Workflow.ComponentModel.DependencyProperty.Register(

"ParameterBindings", typeof(WorkflowParameterBindingCollection), typeof(BamPointActivity),

new PropertyMetadata(DependencyPropertyOptions.Metadata,

new Attribute[]{new BrowsableAttribute(false),

new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)}));

[Browsable(false)]

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]

public WorkflowParameterBindingCollection ParameterBindings

{

//We only use this property to get the dynamic property values:

get

{

return ((WorkflowParameterBindingCollection)(base.GetValue(BamPointActivity.ParameterBindingsProperty)));

}

//TODO: Needed to remove the setter because of serialization bug : (callers now use setvalue directly)

//set

//{

// base.SetValue(BamPointActivity.ParameterBindingsProperty, value);

//}

}

Thanks for any assistance! Best regards! Christof


 
 
Roman Kiss





PostPosted: Windows Workflow Foundation, Dynamic Properties sample cannot work with XOML workflow Top

Christof,

have a look at the following links:

 - http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1009208&SiteID=1 

 - the sample WorkflowProbe, where the WorkflowParameterBindingCollection class is used in the xoml and code.

 

Thanks

 

Roman