Reputation: 82351
I am working on a drag and drop system for my WPF App.
The way it works is:
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.)
Upvotes: 2
Views: 1169
Reputation: 754763
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.
Upvotes: 3