Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.InvalidOperationException: Collection was modified; enumeration operation may not execute. #66

Closed
perlun opened this issue Mar 6, 2018 · 4 comments
Assignees
Labels
Milestone

Comments

@perlun
Copy link

perlun commented Mar 6, 2018

When the WPF application I was attached to reloaded its data (and the visual tree likely was refreshed as well), Snoop triggered an exception that crashed the whole WPF app. Here is the stack trace:

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at System.Collections.Generic.List`1.Enumerator.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Snoop.Shell.VisualTreeProviderExtensions.NodeName(VisualTreeItem item)
   at Snoop.Shell.VisualTreeProvider.GetTreeItem(String path)
   at Snoop.Shell.VisualTreeProvider.OnSyncSelectedItem(Object _)
   at System.Threading.TimerQueueTimer.CallCallbackInContext(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.TimerQueueTimer.CallCallback()
   at System.Threading.TimerQueueTimer.Fire()
   at System.Threading.TimerQueue.FireNextTimers()
   at System.Threading.TimerQueue.AppDomainTimerCallback()
@cplotts
Copy link
Contributor

cplotts commented Aug 2, 2018

@perlun this seems to be an issue in the application that you were Snooping (and not with Snoop itself).

Since Snoop actually injects itself into the Snooped process, exceptions that happen there might seem to come from Snoop ... when they do not.

Unless you can provide some sample code that illustrates otherwise ... I am going to close this issue.

@cplotts cplotts closed this as completed Aug 2, 2018
@perlun
Copy link
Author

perlun commented Aug 3, 2018

@cplotts Thanks. No longer working actively on that project, so we can safely close this for now unless we find a way to reproduce it.

Can application-generated exceptions be re-thrown from the Snoop.Shell.VisualTreeProvider.OnSyncSelectedItem method?

@batzen
Copy link
Collaborator

batzen commented Aug 3, 2018

To be honest, i think this is a bug in snoop itself.

We are using linq here which evaluates lazy and we are using a timer to refresh things.
If the evaluation/refresh take longer than the timer interval, which currently is 250ms, we modify the list we are currently working on.
The problem is that there is no guard against re-entrancy etc..

While debugging i noticed that the powershell integration adds quite some overhead, like this timer and everything it does on tick, even if you don't use the powershell tab at all.

@cplotts
Copy link
Contributor

cplotts commented Aug 7, 2018

I'll reopen this ... I honestly didn't look close enough. @batzen I think you are right.

I wonder if we could limit the impact of the PowerShell tab by only starting this timer when the tab is active.

@cplotts cplotts reopened this Aug 7, 2018
@batzen batzen added the bug label Dec 21, 2018
@batzen batzen self-assigned this Apr 16, 2019
@batzen batzen added this to the 2.12 milestone May 20, 2019
@batzen batzen modified the milestones: 2.12, 3.0 Oct 24, 2019
@batzen batzen closed this as completed in 3c71bda Dec 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants