views:

664

answers:

1

I'v been able to return a HashTable from a Web Service that I setup for a .Net 2.0, but the service fails to retun a DataTable in JSON. I keep getting the following error: 'A circular reference was detected while serializing an object'. Any tips?

 [WebMethod(EnableSession = true) ]
public DataTable getSavedAddresses()
{
    DataTable dt = new DataTable();
    if (Session["ClientID"] != null)
    {
        int clientId = Convert.ToInt32(Session["ClientID"]);
        dt = Address.GetClientShippingAddresses(clientId);
    }
    return dt;

}

A: 

The circular reference is likely due to DataTable having a Columns property, and each DataColumn object has a Table property.

The information in this blog post by Rick Strahl may be of help to you, perhaps.

chyne
Interesting. Yeah, I read it, but I couldn't figure it out.
GreenEggs
I think I'll just try using XML instead.
GreenEggs