Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Cannot access recreated list when using client-side object model in c#

$
0
0

Hi,

I am currently building an application in C# that uses CSOM to create and modify lists within SharePoint. So far this is going very well. I have added a function to create the list from scratch and if the list already exists it will delete it and create it. This is where i have an issue.

The object is dropped and recreated without issue. However when i run the following command to retrieve the new list it fails with a 'List cannot be found'.

List list = clientContext.Web.Lists.GetByTitle(listName);
clientContext.Load(list);
clientContext.ExecuteQuery();

The list definitely exists. After experimenting i found if i disposed of the current client context and created a new one the above code would run.

I'm guessing the context is still remembering the old lists object id so thinks the list doesn't exist.

Is there a way to refresh the client context so it sees the new object or am i doing something incorrect in this process of deleting and recreating the list.

Regards.

Simon.


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>