System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: Cannot serialize the DataTable. DataTable name is not set.
This is the error occur when you create method in webservice with data type "DataTable". For Example like this :
[WebMethod] public DataTable test1() { DataTable testTable = new DataTable(); return testTable; }
The Example above will lead to the Error "Cannot Serialize The Data Table"
This error because of method in WebService try to return result of DataTable to whoever request it, but unfortunately the DataTable do not have their own name. So the quick solution for this error is put the name for DataTable like this :
The Solutions
[WebMethod] public DataTable test1() { DataTable testTable = new DataTable("Table1"); return testTable; }
By Mohd Zulkamal
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)
0 comments:
Post a Comment