Showing posts with label circular. Show all posts
Showing posts with label circular. Show all posts

Wednesday, March 21, 2012

A circular reference was detected while serializing an object of type "System.goblaization

Hi all,

I am trying to call a webservice through javascript to return a dataset to bind it to a datagrid on the client side.

I am using a scriptmanager and registered the service by setting the service path.

I am calling a method on a Textbox onKeydown event to call the webservice method. The web service is returning the a data set. But the problem is am geting an exception stating the following

The server method 'GetDataSet' failed with the following error: System.InvalidOperationException-- A Circular reference was detected while serializing an object of type "System.Globalization.CultureInfo"

Please help me out.

See the following code to get an idea about the problem i have

<WebMethod(EnableSession:=True)> _

PublicFunction GetDataSet(ByVal prefixTextAsString)As DataSet

Dim dtAs DataTable

dt =New DataTable

Dim drAs DataRow

dt =Me.GetSelectedTestSchema()

dr =Me.PopulateSelectedTestsRow("1020","dafda", dt)

Try

dt.Rows.Add(dr)

Catch exAs Exception

EndTry

Dim dsAs DataSet =New DataSet()

ds.Tables.Add(dt)

Return ds

EndFunction

Javascript code

function GenerateGrid()

{

var myGrid = igtbl_getGridById("grdSelectedTests");

TestListService.GetDataSet("x",OnWebRequestComplete);

// myGrid.Control.Set_DataDataSource(TestListService.GetDataSet("x").Table[0]);

//

}

function OnWebRequestComplete(results)

{

'I am using the Infragistics ultraWebgrid

var grdControl = igtbl_getGridById("grdSelectedTests");

grdControl.control.set_data(results);

}

Scriptmanager code

<asp:ScriptManagerID="ScriptManager1"runat="server">

<Services>

<asp:ServiceReferencePath="../AutoCompleteServices/TestListService.asmx"/>

</Services>

</asp:ScriptManager>

Hi,

According to my understanding to your problem, I don't think it's a AJAX specific issue. The exception is related to your server side code.

Can you debug your server side code to try to solve it?

Or you may post the code for methods:GetSelectedTestSchema() andPopulateSelectedTestsRow here.


We are marking this issue as "Answered". If you have any new findings or concerns, please feel free to unmark the issue.


I too am having the same problems.

I'm using C# to write my webservice, I have almost an identical setup for the client-side scripts.


I get this error even when returning an empty DataSet.


 [WebMethod]public DataSet GetData() {return new DataSet(); }

Does anyone know what this error message is telling me? I tried debugging it, and no exception is thrown from the webservice and it works fine when I send a soap request to it.

Thanks,

Lee


You may try to overcome it by setting response format to XML. For instance:

[System.Web.Script.Services.ScriptMethod(ResponseFormat=System.Web.Script.Services.ResponseFormat.Xml)]
public DataSet GetData()
{

A Circular Reference Was Detected error

Hi there,

This has been confusing me to no ends for the past weekend and I ask for your help. When I try to access an IList of Type <SampleRow> or any list structure for that matter, I get this:

A circular reference was detected while serializing an object of type ...<- Many types have popped up (System.Reflection.Module) for example.

I've been trying to run the samples in the documentation with no more success (same error). I'm thinking this has to do with some libraries loaded and not the code itself. I have looked in the GAC, uninstalled/reinstalled everything from VS2005 to the ATLAS Framework (even IIS) with no go. I need to get the list structure for the listview control of ATLAS. It this can help, I'm pasting the stacktrace. Also, I'm not sure this is a specific ATLAS error but I can't tell otherwise. Thanks for your help. If you need anything more, please ask.Smile

[InvalidOperationException: A circular reference was detected while serializing an object of type 'System.Reflection.Module'.]
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o) +766
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o) +90
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeCustomObject(Object o) +706
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o) +908
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o) +90
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeCustomObject(Object o) +706
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o) +908
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o) +90
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeCustomObject(Object o) +706
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o) +908
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o) +90
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeCustomObject(Object o) +706
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o) +908
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o) +90
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeEnumerable(IEnumerable enumerable) +159
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o) +874
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o) +90
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeCustomObject(Object o) +706
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o) +908
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o) +90
Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.Serialize(Object o, IJavaScriptSerializationContext context) +62
Microsoft.Web.UI.Controls.InitialData.GetDataServiceResult() +589
Microsoft.Web.UI.Controls.InitialData.RenderScript(ScriptTextWriter writer) +248
Microsoft.Web.UI.Controls.InitialData.Microsoft.Web.Script.IScriptObject.RenderScript(ScriptTextWriter writer) +31
Microsoft.Web.UI.ScriptManager.RenderXmlScript(TextWriter writer) +735
Microsoft.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e) +663
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +96
System.Web.UI.Page.PerformPreRenderComplete() +32
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +479

Lesson learned: commenting the web.config file temporarily and forgetting about it is a bad idea. I had the converters section commented out, re-enabling them solved the problem. If it can help anyone to learn from my mistake then I won't have posted in vain!

Thanks.