Bug #20034 Can not get a DataSet from .NET Web Services use MySQL Connector/NET
Submitted: 24 May 2006 5:55 Modified: 25 Oct 2007 15:58
Reporter: Hoang Manh Do Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:1.0.7 OS:Windows (Windows Server 2003)
Assigned to: CPU Architecture:Any

[24 May 2006 5:55] Hoang Manh Do
Description:
Dear Sir,

I write a small application that use Web Services to get a dataset from the web site. It run perfectly with Windows Server 2003 + .NET Framework 1.1 + MySQL Connector/NET 1.0.7. But I got the error below with Windows Server 2003 + .NET Framework 2.0 + MySQL Connector/NET 1.0.7.

Server was unable to process request. ---> There was an error generating the XML document. ---> MySql.Data.Types.MySqlDateTime cannot be serialized because it does not have a parameterless constructor.

Regards,

Do Manh Hoang

How to repeat:
Create a small Web Services that return a dataset and then create a small application get that dataset.

Suggested fix:
   Create a defaul constructor in MySqlDateTime variant. I think you will have some more problem with the other MySql Type. 
   Make sure that MySql Type can be serialize perfectly by using XmlSerializer class because .NET Framework 2.0 serialize its dataset to XML and then send back to client through http
[24 May 2006 17:27] Tonci Grgin
Hi and thanks for your problem report.
Can you please try to re-build your webservices since sometimes this happens when WebService is not updated accordingly to the application.
[25 May 2006 3:08] Hoang Manh Do
Dear Sir,

I re-written all of my code in Visual Studio 2005 and upload to IIS again, but I still got that error. And then, I try to create a parametterless constructor in MySqlDateTime class and I got a new error.

System.InvalidOperationException: There is an error in XML document (1, 3066). ---> System.ArgumentException: Column requires a valid DataType.
   at System.Data.DataColumn.set_DataType(Type value)
   at System.Data.XSDSchema.SetProperties(Object instance, XmlAttribute[] attrs)
   at System.Data.XSDSchema.HandleElementColumn(XmlSchemaElement elem, DataTable table, Boolean isBase)
   at System.Data.XSDSchema.HandleParticle(XmlSchemaParticle pt, DataTable table, ArrayList tableChildren, Boolean isBase)
   at System.Data.XSDSchema.HandleComplexType(XmlSchemaComplexType ct, DataTable table, ArrayList tableChildren, Boolean isNillable)
   at System.Data.XSDSchema.InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType typeNode, Boolean isRef)
   at System.Data.XSDSchema.HandleTable(XmlSchemaElement node)
   at System.Data.XSDSchema.HandleDataSet(XmlSchemaElement node, Boolean isNewDataSet)
   at System.Data.XSDSchema.LoadSchema(XmlSchemaSet schemaSet, DataSet ds)
   at System.Data.DataSet.ReadXSDSchema(XmlReader reader, Boolean denyResolving)
   at System.Data.DataSet.ReadXml(XmlReader reader, XmlReadMode mode, Boolean denyResolving)
   at System.Data.DataSet.ReadXmlSerializable(XmlReader reader)
   at System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.ReadXml(XmlReader reader)
   at System.Xml.Serialization.XmlSerializationReader.ReadSerializable(IXmlSerializable serializable)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderGetDataSetFromWebSite.Read47_GetTable01Response()
   at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer77.Deserialize(XmlSerializationReader reader)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at WSManualCall.GetDataSetFromWebSite.GetTable01(String Id) in D:\Temp\WSManualCall\WSManualCall\wscall.vb:line 913
   at WSManualCall.Form1.Button1_Click(Object sender, EventArgs e) in D:\Temp\WSManualCall\WSManualCall\Form1.vb:line 8"	String

Personally, I think XmlSerializer class didn't serialize MySqlDateTime to XML correctly.

Regards,

Do Manh Hoang
[25 May 2006 10:27] Tonci Grgin
Hi.
The reason you're getting this error is in that there is no default constructor for MySqlDateTime type...
Verified as described by reporter.
[6 Jul 2006 2:03] Emery Fabrice NZEYIMANA
This is probably caused by a zero Date or DateTime value. Try to return non-zero date values to see if the problem re-occurs
[17 Oct 2006 12:55] Sergey Morozov
This problem can be fixed by using "convert zero datetime=yes" in the ConnectionString.
[25 Oct 2007 15:58] Reggie Burnett
this is a very old bug report that appears to have a "fix" given in the last comment.  Closing.