Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Member Hiding and XML Serialization

955 views
Skip to first unread message

Hugh Williams

unread,
Mar 25, 2003, 9:10:47 AM3/25/03
to
I have object A that declares a property:

public object foo {get, set}

and an object B that inherits from A and hides the property:

public new int foo {get, set}

When I try to serialize object B with XML serialization, I get this:

"Member B.foo of type System.Int32 hides base class member A.foo of type
System.Object. Use XmlElementAttribute or XmlAttributeAttribute to specify a
new name."

What should I do here? I've put an XMLElement attribute on B.foo so that
it's named something different but that doesn't help. Any ideas?


Karthik Ravindran[MSFT]

unread,
Mar 25, 2003, 6:37:58 PM3/25/03
to
Hello,

This behavior is by design currently: because you are changing the type on
the property we cannot express this in xsd (we do not support restriction
in this version). The error message is misleading as applying the proposed
change will not fix the problem.

To express this in an XSD schema without breaking the inheritance chain we
would have to first restrict the base type to forbid the use of the object
type, and then extend the resulting type with new int foo element.

Thanks
Karthik

This posting is provided "AS IS" with no warranties.


0 new messages