XMLSerializer Error with Hashtable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to serialize and deserialize a Class which has a Hashtable in it and I'm getting the error:

"An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll - Additional information: There was an error reflecting type 'HashSerializeTest.INIData'."

at runtime when I try to instantiate the XMLSerializer object with a constructor to which I pass the Class Type.

I tried it with the class just having Public string members and it worked fine. Then I added a Public Hashtable member and I started to get this error.

Help?
 
Hi,

The XML serializer explicitly ignores serializing objects derived from
IDictionary. To work around this problem, one would need to wrap IDictionary
instances in a class that implements IXmlSerializable. For more info on
this, refer to this excellent
(http://msdn.microsoft.com/msdnmag/issues/03/06/XMLFiles/) column by Aaron
Skonnard

--
HTH,
Manoj G
[MVP , Visual Developer - Visual Basic ]
http://msmvps.com/manoj/

Alex Maghen said:
I am trying to serialize and deserialize a Class which has a Hashtable in it and I'm getting the error:

"An unhandled exception of type 'System.InvalidOperationException'
occurred in system.xml.dll - Additional information: There was an error
reflecting type 'HashSerializeTest.INIData'."
at runtime when I try to instantiate the XMLSerializer object with a
constructor to which I pass the Class Type.
I tried it with the class just having Public string members and it worked
fine. Then I added a Public Hashtable member and I started to get this
error.
 
Back
Top