Getting Lists causes 'Instance Was deleted Error'
See original GitHub issueIn my solution I’m trying to read all SharePoint Online data of a tenant, and in order to improve performance and reduce the amount of objects in memory, I use separate threads for each SharePoint object. The PnPContext is created only once per URL, stored in a Map and re-used as needed.
When I try to read Lists from Web I sometimes get the following exception:
This model instance was deleted, you can't use it anymore
at PnP.Core.Model.TransientObject.CheckDeleted()
at PnP.Core.Model.TransientObject.GetValue[T](String propertyName)
at PnP.Core.Model.BaseDataModel`1.GetModelCollectionValue[T](String propertyName)
at PnP.Core.Model.SharePoint.Web.get_Lists()
Code I use for loading Lists:
var list = context.Web.Lists.GetById(new Guid("xxxxx")
Important: I have multiple threads running parallel that are probably using the same Context to load different Lists of the current Web.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
List instance deleted on retraction
The problem is that when I retract the solution or redeploy then the list instance is removed. This is going to cause an...
Read more >List default view deleted in production
When a list view is deleted in any instance, it will generate a customer update XML record in the current update set.
Read more >Why am I getting deleted instance passed to merge, when ...
This happens because you first delete the object (without committing) and then try to update it. ... To avoid the error you should...
Read more >Error codes for the Amazon EC2 API - AWS Documentation
These errors are usually caused by an AWS server-side issue. ... This section lists the client error codes that all Amazon EC2 API...
Read more >FIX: BizTalk Operators issue when you terminate service ...
When selecting multiple service instances in the Admin Console and then deleting them, you notice that not all of them get deleted and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ran into the same here with only two concurrent threads. Cloning the PnPContext for every call as Bert mentions above fixed it for me.
@bajce : if you want to run work for the same IWeb in parallel via threads then cloning a context should fix things for you. https://pnp.github.io/pnpcore/using-the-sdk/basics-context.html#cloning-a-pnpcontext-for-the-same-web describes the details, but a default clone operation will not result in a server roundtrip. If you however optimized the initial load as described in my previous reply, then not all properties are copied over to the cloned context.
If this answers your questions, then please close the issue.