Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi

 

Im trying to serialize an object to XML (c#) using the System.XMLSerializer but Im getting exceptions due to the class being an interface (see code snippet below).

 

string filename = @"C:\Mark\CODAAccount_" + myElement.Code + ".xml";

TextWriter tw = new StreamWriter(filename);

XmlSerializer serializer = new XmlSerializer(typeof(codaElementClass));

serializer.Serialize(tw,myElement);

 

I have read that there are ways I can implement the ISerializable interface which will allow me to serialize my object, but can anyone help me with this and provide some example syntax??

 

Thanks

Mark

  • Administrators
Posted

The XmlSerializer class needs to know about the class' data structures to be able to serialze it - interfaces do not have any data fields and therefore it cannot use them to determine storage requirements.

 

If you are looking at implementing ISerializable yourself then this MSDN article is a good starting point.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...