I'm building a Web Service with the CLR 2.0 that returns a DataTable but I
get the followng error:
System.InvalidOperationException: There was an error generating the XML
document. ---> System.InvalidOperationException: Cannot serialize the
DataTable. DataTable name is not set.
at System.Data.DataTable.WriteXmlSchema(XmlWriter writer, Boolean
writeHierarchy)
at
System.Data.DataTable.System.Xml.Serialization.IXmlSerializable.WriteXml(XmlWriter writer)
at
System.Xml.Serialization.XmlSerializationWriter.WriteSerializable(IXmlSerializable
serializable, String name, String ns, Boolean isNullable, Boolean wrapped)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write2_DataTable(Object o)
at
Microsoft.Xml.Serialization.GeneratedAssembly.DataTableSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String encodingStyle)
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces)
at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter
textWriter, Object o, XmlSerializerNamespaces namespaces)
at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter
textWriter, Object o)
at System.Web.Services.Protocols.XmlReturnWriter.Write(HttpResponse
response, Stream outputStream, Object returnValue)
at System.Web.Services.Protocols.HttpServerProtocol.WriteReturns(Object[]
returnValues, Stream outputStream)
at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[]
returnValues)
at System.Web.Services.Protocols.WebServiceHandler.Invoke()
Does anybody know what the problem is? I thought DataTables were
serializable in .NET 2.0.
Peter Kelcey - 24 Nov 2005 18:34 GMT
Jayne
Trying using the tablename property to assign your datatable a name
before serializing it.
Peter Kelcey
Jayne - 24 Nov 2005 20:59 GMT
Thanks Peter. That worked a treat.
Jayne
> Jayne
>
> Trying using the tablename property to assign your datatable a name
> before serializing it.
>
> Peter Kelcey