C
C#2y ago
Jawad

❔ System.NullReferenceException: 'Object reference not set to an instance of an object.'

Need some help please with this exception try { EntityCollection collection = service.RetrieveMultiple(new FetchExpression(query)); foreach (Entity contact in collection.Entities) { Console.WriteLine(contact.Attributes["fullname"].ToString()); } } catch (NullReferenceException e) { //eventListener.HandleEvent(Severity.Informational, line.GetType().Name, String.Format("Could not find the customer corresponding to the taxId '{0}' Applicant address will not be imported.", new TaxId(line.TaxId).Masked)); //eventListener.HandleEvent(Severity.Informational, line.GetType().Name, e.Message); Console.WriteLine(e.Message); }
7 Replies
Jawad
JawadOP2y ago
Can someone pelase help with this?
jcotton42
jcotton422y ago
what line is throwing the exception? also, you should pretty much never catch NRE it's always an indication of a bug
Jawad
JawadOP2y ago
EntityCollection collection = service.RetrieveMultiple(new FetchExpression(query));
jcotton42
jcotton422y ago
put a breakpoint on that line see what's null in the debugger
Tvde1
Tvde12y ago
likely service
Jawad
JawadOP2y ago
Thanks collection is null service is also null ok guys thank you for your input. I was not doing anything wrong in code but I had to allow the connection from AAD.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server