❔ 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
Can someone pelase help with this?
what line is throwing the exception?
also, you should pretty much never catch NRE
it's always an indication of a bug
EntityCollection collection = service.RetrieveMultiple(new FetchExpression(query));
put a breakpoint on that line
see what's null in the debugger
likely
service
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.
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.