Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Self Referencing loop detected for property 'manifestmodule' | While adding certificate to GET request

I have below code for GET request -

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method="GET";
request.Timeout=300000;

X509Certificate2 certificate= new X509Certificate2(path,password);
request.ClientCertificates.Add(certificate);

While adding certificate I am getting Error -

Self Referencing loop detected for property 'manifestmodule' with type 'System.Reflection.RuntimeModule' Path 'Exception.Targetsite.Module.Assembly'

I searched on internet with respect to this error , but its general occurance is while using / parsing json which I am nowhere doing in my code.

I am using .NET core - 2.1.1

like image 310
C Sharper Avatar asked Dec 10 '25 07:12

C Sharper


1 Answers

As you already found out this is an error coming from the Newtonsoft JsonSerializer. I think what's happening is that inside your API an exception is occurring, which is then passed to Newtonsoft to serialize to JSON so it can be returned as a response. Your options are either to fix this exception or disable reference loop detection mechanism.

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc()
        .AddJsonOptions(
            options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
        );
}
like image 67
Martin Devillers Avatar answered Dec 11 '25 21:12

Martin Devillers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!