问题描述
核心代码:ctx.Credentials=newNetworkCredential(userName,passwordStr,domainStr);Webweb=ctx.Web;ListannouncementsList=web.Lists.GetByTitle(list_name);CamlQueryquery=newCamlQuery();query.ViewXml="<Where>"+"<And><And>"+"<Eq><FieldRefName="Filed_1"/><ValueType="Text">0delltest</Value></Eq>"+"</And>"+"</Where>";ListItemCollectioncollListItem=announcementsList.GetItems(query);ctx.Load(collListItem);Console.WriteLine(collListItem.Count);//////这里出现异常怎么办。if(collListItem.Count==0){Console.WriteLine("Noitemscontaining'announce'found.");}else{Console.WriteLine("Itemscontaining'announce'found:n");foreach(ListItemtargetListItemincollListItem){targetListItem[text]="Thisismynewvalue!!";targetListItem.Update();}出现CollectionNotInitializedException异常,请问怎么解决Thecollectionhasnotbeeninitialized.Ithasnotbeenrequestedortherequesthasnotbeenexecuted.Itmayneedtobeexplicitlyrequested.
解决方案
解决方案二:
为什么没人回我。
解决方案三:
ctx.ExecuteQuery();