I got the following error while running SharePoint ClientObject Model. I went through my code and checked if I missed any thing to load, but didn't see.
"Process is Terminated: The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested."
I am not sure what I am missing after searching about this for a couple of hour.
The following is my code. Hope any one can help.
public static void UpdatePackageStatus(string Teamsite, string Libname, string Packagename, string User, string Password, string Domain, string PackageStatus, string DeploymentSucceeded, string query)
{
using(clientOM.ClientContext Ctx = new clientOM.ClientContext(Teamsite))
{
Ctx.Credentials = new System.Net.NetworkCredential(User, Password, Domain);
clientOM.Web Web = Ctx.Web;
Ctx.Load(Web);
Ctx.ExecuteQuery();
clientOM.List list = Web.Lists.GetByTitle(Libname);
Ctx.Load(list);
Ctx.ExecuteQuery();
clientOM.CamlQuery CamlQuery = new clientOM.CamlQuery();
CamlQuery.ViewXml = query;
clientOM.ListItemCollection Items = list.GetItems(CamlQuery);
Ctx.Load(Items);
Ctx.ExecuteQuery();
if(Items.Count > 0)
{
clientOM.ListItem Item = Items.GetById(Items[0].Id);;
Ctx.Load(Item);
Ctx.ExecuteQuery();
if(Item.DisplayName == Packagename)
{
Item[PackageStatus] = DeploymentSucceeded;
Item.Update();
Ctx.ExecuteQuery();
}
}
}
}