Try our conversational search powered by Generative AI!

Migrating to EPiServer 10 is causing Circular reference

Vote:
 

Hi

Migrating to EPiServer 10 is causing Circular reference in all JSON Serializations i use.

whether i use JavascriptSerializer, Newtonsoft, Jil.. i get a circular reference error while serializing a list of PageTypes.

I can loop through the objects and get the properties i only need and build a JSON. But this is a huge project that serializes objects lots of times. so rewriting the code seems almost impossible.

Any idea how to solve that?

#177916
Apr 24, 2017 11:35
Vote:
 

Ofcourse I don't know excactly what your list contains, but have you tried adding the following?

return JsonConvert.SerializeObject(results, Formatting.Indented, 
    new JsonSerializerSettings { 
        ReferenceLoopHandling = ReferenceLoopHandling.Ignore 
    });
#177922
Apr 24, 2017 15:00
Vote:
 

Hi  There,

When i add the ReferenceLoopHandling i receive this error:

[NullReferenceException: Object reference not set to an instance of an object.]
EPiServer.Core.PropertyContentReference.get_ID() +13
GetID(Object ) +44
Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target) +383

[JsonSerializationException: Error getting value from 'ID' on 'EPiServer.Core.PropertyPageReference'.]

#177936
Apr 24, 2017 17:54
Vote:
 

I would like to add also that the ID is not null. It has value. And that the same code is working in EpiServer 8.

#177950
Apr 25, 2017 9:00
Vote:
 

Have you tried adding

NullValueHandling = NullValueHandling.Ignore

to the settings as well?

#177959
Apr 25, 2017 10:26
Vote:
 

Jeroen, Thanks for the fast reply.

I still get the NullReferenceException even after having NullValueHandling ignored in the settings. This is really strange. 

#177961
Apr 25, 2017 11:26
Vote:
 

Sorry to rekindle an old thread but did you get this working?  I see that the GetID doesn't do a null check in their code.

#201951
Mar 08, 2019 9:29
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.