Howard: it's possible to serialize derived classes as long as you also declare the derived type to the XmlSerializer. What type are you passing in to the XmlSerializer constructor ?
Also, check the InnerMessage property of the exception you are catching. It provides more information about the nature of the exception. HTH, Christoph Schittko Software Architect Mshow - a division of InterCall P.S. I already posted this answer to your question in the newsgroup, but it seems like the group is having problems. ----- Original Message ----- From: "Howard Hoffman" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, June 13, 2002 2:06 PM Subject: [ADVANCED-DOTNET] Extending XSD generated classes ... > Is it possible to extend XSD generated classes with methods and properties? > > I have a schema with around 200 complexTypes. I'd like to provide methods > for many of them. My first approach was use XSD.exe to generate classes > for the complexTypes (in the 'commonNamespace' namespace), to derive a new > CS class from the XSD generated class, and to provide the methods there. > However, that doesn't serialize. Here's a copy of my subclass : > > namespace commonNamespace { > [System.Xml.Serialization.XmlTypeAttribute( Namespace="myURI", > TypeName="Type_t")] > public class myType : Type_t // Type_t is a class generated by XSD.exe in > the commonNamespace namespace > { > void doIt() > { > // execute my business logic > } > } > } > > I have a root element in my schema that has a Type_t element in it. If my > C# code constructs a myType, populates the relevant fields, and then > serializes it, I get > System.InvalidOperationException on my XmlSerializer.Serialize() call. If I > change my C# to populate a Type_t instead of a myType, then it works. > > Is there something I can do without hand-editing the generated C# code to > make this work? It doesn't appear that you can pass XmlIncludeAttributes > to the XmlAttributesOverrides.Add() method. > > Thanks in advance, > > Howard > > You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or > subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.