unable to reflect type
-
I've got a problem with the XmlSerializer - i can't seem to serialiaze custom types. The XmlSerializer works fine with any BCL type, but my custom types throw this error:
An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll Additional information: There was an error reflecting 'ComponentTestConsole.CustomType'.
I wonder if it's a security thing (even though it's not a security exception), since this is the first project i've created on a network drive and it did warn me when i started the project yesterday. So as a second question, what do i need to do to let .NET know that my network shares are safe as houses? :confused: Thanks in advance, Paul -
I've got a problem with the XmlSerializer - i can't seem to serialiaze custom types. The XmlSerializer works fine with any BCL type, but my custom types throw this error:
An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll Additional information: There was an error reflecting 'ComponentTestConsole.CustomType'.
I wonder if it's a security thing (even though it's not a security exception), since this is the first project i've created on a network drive and it did warn me when i started the project yesterday. So as a second question, what do i need to do to let .NET know that my network shares are safe as houses? :confused: Thanks in advance, PaulHave you implemented the serializable interface in your classes?
-
Have you implemented the serializable interface in your classes?
Hi Lee, I was just about to post to say i've fixed it. I hadn't looked in the InnerException member of the thrown exception - i'd stupidly not made my custom type public (doh!). You don't need to implement the serializable interface to use the XmlSerializer - it uses reflection to inspect the type and serialize any publicly accessible members. Cheers, Paul
-
I've got a problem with the XmlSerializer - i can't seem to serialiaze custom types. The XmlSerializer works fine with any BCL type, but my custom types throw this error:
An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll Additional information: There was an error reflecting 'ComponentTestConsole.CustomType'.
I wonder if it's a security thing (even though it's not a security exception), since this is the first project i've created on a network drive and it did warn me when i started the project yesterday. So as a second question, what do i need to do to let .NET know that my network shares are safe as houses? :confused: Thanks in advance, Paul -
I beleive that the xml serializer requires the class to have a public parameter-less constructor. Does yours have one?