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.IXm lSerializable.WriteXml(XmlWriter writer)
at
System.Xml.Serialization.XmlSerializationWriter.Wr iteSerializable(IXmlSerializable
serializable, String name, String ns, Boolean isNullable, Boolean wrapped)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriter1.Write2_DataTable(Object o)
at
Microsoft.Xml.Serialization.GeneratedAssembly.Data TableSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
at System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
at System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String encodingStyle)
at System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces)
at System.Xml.Serialization.XmlSerializer.Serialize(T extWriter
textWriter, Object o, XmlSerializerNamespaces namespaces)
at System.Xml.Serialization.XmlSerializer.Serialize(T extWriter
textWriter, Object o)
at System.Web.Services.Protocols.XmlReturnWriter.Writ e(HttpResponse
response, Stream outputStream, Object returnValue)
at System.Web.Services.Protocols.HttpServerProtocol.W riteReturns(Object[]
returnValues, Stream outputStream)
at System.Web.Services.Protocols.WebServiceHandler.Wr iteReturns(Object[]
returnValues)
at System.Web.Services.Protocols.WebServiceHandler.In voke()
Does anybody know what the problem is? I thought DataTables were
serializable in .NET 2.0.