We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Json serializer error

Thread ID:

Created:

Updated:

Platform:

Replies:

147890 Sep 26,2019 09:39 PM UTC Sep 30,2019 04:15 AM UTC Blazor 3
loading
Tags: Grid
Michael Lambert
Asked On September 26, 2019 09:39 PM UTC

When I try to update the DataSource binding on the Grid I get the following error in the browser:

<EjsGrid DataSource="@ts" Toolbar="@gridToolbar">
    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>
    <GridEvents OnActionComplete="OnComplete" TValue="TimeSheets" />
    <GridColumns>
…..



    public void GetTimesheet()
{
        ts = db.TimeSheets.Where(a => a.CustId == CustomerID).ToList();

    }


[2019-09-26T21:21:15.251Z] Error: System.AggregateException: One or more errors occurred. (Self referencing loop detected with type 'ReserevesTest.Data.db.TimeSheets'. Path 'dataSource[0].Officer.TimeSheets'.)
 ---> Newtonsoft.Json.JsonSerializationException: Self referencing loop detected with type 'ReserevesTest.Data.db.TimeSheets'. Path 'dataSource[0].Officer.TimeSheets'.
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CheckForCircularReference(JsonWriter writer, Object value, JsonProperty property, JsonContract contract, JsonContainerContract containerContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, Type type, Formatting formatting, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, Formatting formatting, JsonSerializerSettings settings)
   at Syncfusion.EJ2.Blazor.BaseComponent.GetSerializedModel()
   at Syncfusion.EJ2.Blazor.BaseComponent.GetUpdateModel(Boolean isInit)
   at Syncfusion.EJ2.Blazor.BaseComponent.OnAfterRender(Boolean firstRender)
   at Syncfusion.EJ2.Blazor.Grids.EjsGrid`1.OnAfterRender(Boolean firstRender)
   at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleAfterRender.OnAfterRenderAsync()
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.NotifyRenderCompletedAsync()
   --- End of inner exception stack trace ---

Vignesh Natarajan [Syncfusion]
Replied On September 27, 2019 09:08 AM UTC

Hi Michael,  

Greetings from Syncfusion support.  

Query: “When I try to update the DataSource binding on the Grid I get the following error in the browser 
 
We have prepared a sample as per your suggestion and code example, but we are unable to reproduce the reported at our end. We have tried to update the data on Button click and we are able to update successfully. Kindly download the sample from below.  


The reported issue may occur when model class properties are complex properties of its own parent class. Please find some general links for self-reference loop error from below  



After referring the sample and solution, if you are still facing the issue kindly get back to us with following details.  

  1. Share the full grid rendering code example.
  2. Share the details about GetTimeSheets() method along with the model class.
  3. Are you facing the reported issue during the initial rendering or while updating the dataSource property?.
  4. If possible try to reproduce the reported issue in provided sample.

Requested details will be helpful for us to validate the reported issue at our end and provide solution as soon as possible. 

Regards,
Vignesh Natarajan. 


Michael Lambert
Replied On September 27, 2019 08:51 PM UTC

Thanks,
this worked:
[JsonIgnore] 
[IgnoreDataMember] 
public virtual ICollection<Product> Products { get; set; } 

Here is a link with really good info: https://code.msdn.microsoft.com/Loop-Reference-handling-in-caaffaf7



Vignesh Natarajan [Syncfusion]
Replied On September 30, 2019 04:15 AM UTC

Hi Michael,  

Thanks for the update.  

We are glad to hear that your query has been resolved by our solution. And also thanks for your suggestion.  

Please get back to us if you have further queries.  

Regards, 
Vignesh Natarajan. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon