Skip to content

Commit d3666d9

Browse files
authored
Merge pull request #9620 from drewnoakes/fix-collection-modified-exception
Fix "collection modified" exception
2 parents 24eabd0 + 2876142 commit d3666d9

File tree

1 file changed

+4
-1
lines changed
  • src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/UI/InfoBars

1 file changed

+4
-1
lines changed

src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/UI/InfoBars/VsInfoBarService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ public VsInfoBarService(
4747
{
4848
lock (s_entries)
4949
{
50-
foreach (InfoBar entry in s_entries)
50+
// Copy the list to avoid "collection modified during enumeration" exceptions,
51+
// as when the last project associated with an info bar is closed, we will
52+
// remove that entry from the list.
53+
foreach (InfoBar entry in s_entries.ToList())
5154
{
5255
entry.OnProjectClosed(_project);
5356
}

0 commit comments

Comments
 (0)