I have an issue with CSOM and content type, I used CSOM to read some value in a sharepoint list, it works well until I try to used content type If I create a new content type with my fields, it's worked but if I add my field in an existing content type. It doesn't work and that's return me the following error:

Error: Object reference not set to an instance of an object 

the error it's comming from the first line which try to read my field so in my code here the line:

if (item[l_strUniqueKeyName].ToString() == l_strUniqueKeyValue) 

I've done a lot of researches but I found nothing related to this issue

Any idea of what I'm doing wrong?

Thank you for your help


Please check if the ContentType field value is null, if it is null, then call.ToString() method, it will throw "Object reference not set to an instance of object" exception.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.