views:

114

answers:

1

I am working on a drag and drop system for my WPF App.

The way it works is:

  1. I take the dragged Item
  2. Serialize it to xml
  3. When it gets dropped I deserialize it again.

This worked fine in my test app. However, now that I am trying to do it in my real app, I have hit a snag. The class I am trying to deserialize (Microsoft.TeamFoundation.WorkItemTracking.Client.FieldDefinition) does not have a public constructor.

When I try to deserialize it using this code:

XmlReader reader = XmlReader.Create(new StringReader(xamlString));
object elt = XamlReader.Load(reader);

I get this error:

Cannot create object of type 
'Microsoft.TeamFoundation.WorkItemTracking.Client.FieldDefinition'. 
CreateInstance failed, which can be caused by not having a public default 
constructor for 'Microsoft.TeamFoundation.WorkItemTracking.Client.FieldDefinition

Am I toast? Is there any way to deserialize this class? Any other ideas on how to transfer this class via drag and drop? (I am using the FluidKit Drag and Drop Advisers.)

+3  A: 

I've worked with the FieldDefinition class quite a bit and the least of the problems you'll have with XML serialization is the internal constructor. This is a very complex type that generally has references (indirectly) to COM values and several GC handles. It's simply not going to be easy to serialize instances of the type.

What you can do though is serialize the ReferenceName of the FieldDefinition. You can then use that to rebuild the FieldDefinition object at a later point.

JaredPar
Good Idea! I will go with that. Thanks for the tip.
Vaccano