I am encountering the same error as is described above.
I understand that there will be issues when the object graph has a circular reference in it, however I am encountering this issue when I simply attempt to return a System.Data.DataTable comprised of columns with simple data types.
What I'm currently attempting to do is call the 'getTableFromService' JavaScript function and get a DataTable back from the Web Service. I've included both the Service and the JavaScript.
My error handling function output is also included at the bottom.
Any help you can provide would be greatly appreciated.
Thanks,
neil
Imports System
Imports System.Data
Imports System.Web.Services
Namespace Services
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
Public Class SampleDataTable
Inherits System.Web.Services.WebService
<WebMethod()> Public Function GetTable() As System.Data.DataTable
Dim dtResults As New System.Data.DataTable
Dim drRow As System.Data.DataRow = Nothing
dtResults.Columns.Add(New System.Data.DataColumn("ID", GetType(Integer)))
dtResults.Columns.Add(New System.Data.DataColumn("Digit", GetType(Integer)))
drRow = dtResults.NewRow()
drRow.Item("ID") = 1
drRow.Item("Digit") = 1
dtResults.Rows.Add(drRow)
Return dtResults
End Function
End Class
End Namespace
function
getTableFromService(){
Services.SampleDataTable.GetTable(onSuccess, onTimeout, onError);
}
function
onSuccess( Results ){
//success}
function
onTimeout( Results ){
//timeout}
function
onError( Results ){
alert(
'Error Type:\n' + Results.get_exceptionType() + '\n\nError:\n' + Results.get_message() + '\n\nStack Trace:\n' + Results.get_stackTrace());}
---------------------------
Microsoft Internet Explorer
---------------------------
Error Type:
System.InvalidOperationException
Error:
A circular reference was detected while serializing an object of type 'System.Reflection.Module'.
Stack Trace:
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeCustomObject(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeCustomObject(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeCustomObject(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeCustomObject(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeEnumerable(IEnumerable enumerable)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeCustomObject(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.Serialize(Object o, IJavaScriptSerializationContext context)
at Microsoft.Web.Services.RestHandler.ProcessRequest(HttpContext context)
---------------------------
OK
---------------------------