Force XMLSerializer to use class namespaces

Is there anyway to force the XMLSerializer to use fully qualified
namespaces for when serializing? I was in the midsts of implementing
EnterpriseServices configurations using a file store and
XMLSerialization when I got clubbed over the head by the serializer
because I have two different classes:
CompanyA.Risk.Server.Settings
and
CompanyA.Risk.Client.Settings

CompanyA.Risk.Server.Settings contains an array of
Gargoyle.Risk.Client.Settings and the serializer craps out because I
have two classes with the name "Settings". Is there anyway to force the
serializer to use class names with their namespaces when serializing?
i.e.
<CompanyA.Risk.Server.Settings>
   <ClientSettings>
      <CompanyA.Risk.Client.Settings />
      <CompanyA.Risk.Client.Settings />
      <CompanyA.Risk.Client.Settings />
   </CompanyA>
</CompanyA.Risk.Server.Settings>

etc.

I'd rather not go through every class I want to serialize and add an
[XmlType(TypeName="CompanyA.Risk.Server.Settings")]
and
[XmlType(TypeName="CompanyA.Risk.Client.Settings")]

for all of my classes.

0
ben4402 (2)
5/18/2006 1:40:42 AM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
423 Views

Similar Articles

[PageSpeed] 51

As an addition to the comment before. Lets say I have two assemblies.
One called CompanyA.Risk.Server and another called
CompanyA.Risk.Client. I try to run xsd.exe on CompanyA.Risk.Server to
produce a schema for the CompanyA.Risk.Server.Settings class which
contains an array of CompanyA.Risk.Client.Settings objects.
I get an error which states ...Settings both use the XML type name,
Settings, from namespace . Use XML attributes to specify a unique XML
name and/or namespace for the type.

Is there anyway for the tool to use the full class namespace to set the
XML namespaces?

0
ben4402 (2)
5/18/2006 3:15:51 AM
Reply:

Similar Artilces: