This is a strange problem that I am having with WCF trying to send DataTable in the response. I have the following service contract:
[ServiceContract]
public
I know this is an old question, but maybe someone is still experiencing the same problem (like I did). I was faced with the same confusing error message and spent hours banging my head when it hit me....
public DataTable GetDataTable()
{
DataTable dt = new DataTable(**"MY_NAME"**);
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("Caption", typeof(string));
dt.Rows.Add(new object[] { 1, "hooray!" });
return dt;
}
you should give your DataTable a name, i used a overloaded constructor and no more errors!
EDIT: Of course, you really shouldn't use DataTable or DataSet as a return type from a WCF service. For me it was just for testing purposes, because I thought it's the quickest way to get something out of a database and over the wire....boy was i wrong :)