SGEN: The top XML element from namespace references distinct types

I have the following classes (all defined in the same namespace, Test.NamespaceTest):

[XmlRootAttribute("rootTag")]
public class BaseClass
{
}


[XmlRootAttribute("rootTag")]
public class MyClass : BaseClass
{
}

and similarly

[XmlRootAttribute("rootTag")]
public class Class1
{
}


[XmlRootAttribute("rootTag")]
public class Class2
{
}

When sgen tries to create the serialization assemblies for these classes, I get the following error (same thing for BaseClass and MyClass):

The top XML element 'rootTag' from namespace " references distinct types Test.NamespaceTest.Class1 and Test.NamespaceTest.Class2. Use XML attributes to specify another XML name or namespace for the element or types.

Now, these classes should use the same root name so I defined the XmlRootAttribute. What do I need to do in order to get sgen to work? These classes are serialized and sent to existing services as SOAP requests so if I add namespace values, couldn't that mess up the service when it tries to deserialize the request, since no namespaces are originally defined?

Answers


This was resolved after adding some namespace attributes.


Need Your Help

Thanking users who answered my question

discussion faq comments etiquette thanks

Quite often a number of users will give similar answers to one of my questions. Sometimes someone will give an answer that is interesting, but does not really help with my question.