OneDriveVersionCleaner icon indicating copy to clipboard operation
OneDriveVersionCleaner copied to clipboard

Microsoft.SharePoint.Client.ServerException: Operation is not valid

Open Presjar opened this issue 4 years ago • 3 comments

Hi,

I used the original and webbexpert branch with the same result. Some files seem to trigger this output during processing, I don't know which file is causing the problem as it is not shown in the output. Results in a crash at the same point every time.

Original Balassy Code Error; Unhandled Exception: Microsoft.SharePoint.Client.ServerException: Operation is not valid due to the current state of the object. at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream) at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse() at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb) at Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery() at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery() at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery() at OneDriveVersionCleaner.Program.ProcessFile(ClientContext context, ListItem item) in C:\Users\Me\Desktop\OneDriveVersionCleaner-master\OneDriveVersionCleaner\Program.cs:line 405 at OneDriveVersionCleaner.Program.ProcessItems(ClientContext context, ListItemCollection items) in C:\Users\Me\Desktop\OneDriveVersionCleaner-master\OneDriveVersionCleaner\Program.cs:line 393 at OneDriveVersionCleaner.Program.ProcessFolder(ClientContext context, List list, String rootRelativeUrl) in C:\Users\Me\Desktop\OneDriveVersionCleaner-master\OneDriveVersionCleaner\Program.cs:line 378 at OneDriveVersionCleaner.Program.Main(String[] args) in C:\Users\Me\Desktop\OneDriveVersionCleaner-master\OneDriveVersionCleaner\Program.cs:line 338

Webbexpert Code Error; Unhandled Exception: Microsoft.SharePoint.Client.ServerException: Operation is not valid due to the current state of the object. at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream) at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse() at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb) at Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery() at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery() at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery() at OneDriveVersionCleaner.Program.ProcessFile(ClientContext context, ListItem item) in C:\Users\Me\Desktop\OneDriveVersionCleaner-master [webexpert]\OneDriveVersionCleaner\Program.cs:line 153 at OneDriveVersionCleaner.Program.ProcessItems(ClientContext context, ListItemCollection items) in C:\Users\Me\Desktop\OneDriveVersionCleaner-master [webexpert]\OneDriveVersionCleaner\Program.cs:line 141 at OneDriveVersionCleaner.Program.ProcessFolder(ClientContext context, List list, String rootRelativeUrl) in C:\Users\Me\Desktop\OneDriveVersionCleaner-master [webexpert]\OneDriveVersionCleaner\Program.cs:line 126 at OneDriveVersionCleaner.Program.Main(String[] args) in C:\Users\Me\Desktop\OneDriveVersionCleaner-master [webexpert]\OneDriveVersionCleaner\Program.cs:line 55

Presjar avatar Sep 09 '21 10:09 Presjar

I have now noticed that webbexpert has posted a Pull request for the recursive. Although their version still results in Operation is not valid in some situations. Edit original comment and title to be specific to the crash.

Presjar avatar Sep 09 '21 11:09 Presjar

Hello @Presjar, I wrote this code as an experiment, and at the moment I don't have time to fully investigate this issue. Thanks for reporting it though, I let it here for others to see and comment.

I'm not sure, but my gut feeling is that this issue happens when multiple processes access the file at the same time. Maybe a template operation is not finished or a workflow is updating the properties of the file or a client is current viewing or synchronizing it.

balassy avatar Sep 09 '21 15:09 balassy

Thanks for the reply. Understand you already have other things to be doing.

365 is so painful to use. Why there isn't an option in my personal drive to clear all old versions is beyond me. I'm not even able to turn off the Function.

Presjar avatar Sep 09 '21 23:09 Presjar