deserialization of a List<string> does not work

I have the property shown below in one of my custom activites.

When serializing a workflow into an XML file, then I see the List<string> as a comma separated list of strings in the XML file.

However, when I deserialize the workflow, the List<string> is not restored. Can anyone please explain, how custom properties can be restored on deserialization?

For example, do I need a special constructor pattern in my activity class to support deserialization of my custom properties?

--

publicstaticDependencyProperty PredicatesProperty =

System.Workflow.ComponentModel.DependencyProperty.Register(

"Predicates",typeof(List<string>),typeof(PanedActivity));

publicList<string> Predicates

{

get

{

return ((List<string>)(base.GetValue(PanedActivity.PredicatesProperty)));

}

set

{

base.SetValue(PanedActivity.PredicatesProperty,value);

}

}

[3734 byte] By [mario.muja] at [2007-12-24]
# 1

If you have a collection you want serialized property you need to do three things:

1) Make the DependencyProperty a MetaData and readonly property (add

new PropertyMetadata(DependencyPropertyOptions.Metadata|DependencyPropertyOptions.ReadOnly)) at the end of your dependencyproperty declaration).

and remove the setting part of your property.

2) Add a call to this.SetReadOnlyPropertyValue in your constructor and add a new instance of your collection

3) Add the

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]

to your property.

I have a sample in the download from this post : http://www.masteringbiztalk.com/blogs/jon/PermaLink,guid,7be9fb53-0ddf-4633-b358-01c3e9999088.aspx

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

Thanks. This worked.

Regards, Mario

mario.muja at 2007-8-31 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified