I have the following CSOM code inside my asp.net core console application:-
TaxonomySession txSession = TaxonomySession.GetTaxonomySession(context);
TermStore tc = txSession.TermStores.GetByName(termstorename);
TermGroup g = tc.Groups.GetByName(groupname);
try
{
var technician = context.Site.RootWeb.EnsureUser(SQLitem.Technician);
context.ExecuteQuery();
NewUFSlistItem("UserFeedbackEngineer") = technician;
}
catch (Exception e)
{
}
TermSet ts = g.TermSets.GetByName(termsetname);
var customername = ts.Terms.GetByName(SQLitem.Account);
context.Load(customername);
context.ExecuteQuery();
now if the first context.ExecuteQuery();
raise an exception (mainly when the context.Site.RootWeb.EnsureUser(SQLitem.Technician)
raise an error when the user can not be found), the second context.ExecuteQuery();
will raise this error:-
System.NullReferenceException: 'Object reference not set to an instance of an object.'
so i am not sure why this is happening? any advice?
Thanks