I have a list with records uniquely identified by project numbers. This is column 5 - Col05 in my list. It works fine when I run the code, and I am getting the expected record. I can also read the values I need.
But this doesn't work on anybody else's computer. Error received is:
System.NullReferenceException: Object reference not set to an instance of an object.
I'm working with C# (.net) and Sharepoint Client COM, and using VS 2010. The above error had come earlier once, when trying to convert a SP List Item which is null to string, but there are no such columns for that record - I've checked and every column has some value.
The code I have used for this is below:
SP.ClientContext _clientcontext = new SP.ClientContext("https://mysite/");
NetworkCredential myCred = new NetworkCredential();
CredentialCache myCache = new CredentialCache();
SP.Web _site = _clientcontext.Web;
SP.List _list = _site.Lists.GetByTitle("myList");
string id = "9999";
string _viewXML = "" +
"<View>" +
"<Query>" +
"<Where>" +
"<Eq>" +
"<FieldRef Name = '_x0043_ol05'/>" +
"<Value Type = 'Text'>" + id + "</Value>" +
"</FieldRef>" +
"</Eq>" +
"</Where>" +
"</Query>" +
"</View>";
SP.CamlQuery _query = new SP.CamlQuery { ViewXml = _viewXML };
SP.ListItemCollection _listitems = _list.GetItems(_query);
_clientcontext.Load(_listitems);
_clientcontext.ExecuteQuery();
I can't figure out how it is working fine when I run it in debug mode/run with debug, but not on anybody elses. Remaining code runs fine, so its not an issue about nothing working at all, but its only this bit that is stuck
Would appreciate any help on this. Thanks in advance!