I am using the below code. While debugging I always get the error :
"Collection not initialised"
in line 3
private static void GenerateLeftNav(ClientContext cltContext, string webUrl)
{
cltContext.Load(cltContext.Web);
cltContext.ExecuteQuery();
NavigationNodeCollection qlNavNodeColl = cltContext.Web.Navigation.QuickLaunch;
cltContext.Load(qlNavNodeColl);
//Fetching node which needs to be updated
// IEnumerable<NavigationNode> projectsNode = cltContext.LoadQuery(qlNavNodeColl.Where(n => n.Title == "Projects"));
NavigationNode projectsNode = qlNavNodeColl.Where(n => n.Title == "Projects").FirstOrDefault();
if (projectsNode != null)
{
try
{
NavigationNode gNode = projectsNode;
gNode.Url = webUrl;
gNode.Update();
cltContext.ExecuteQuery();
}
catch (Exception)
{
throw;
}
}
}