diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/UI/InfoBars/VsInfoBarService.cs b/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/UI/InfoBars/VsInfoBarService.cs index 076103eebd..80548f0c89 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/UI/InfoBars/VsInfoBarService.cs +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/UI/InfoBars/VsInfoBarService.cs @@ -47,7 +47,10 @@ public VsInfoBarService( { lock (s_entries) { - foreach (InfoBar entry in s_entries) + // Copy the list to avoid "collection modified during enumeration" exceptions, + // as when the last project associated with an info bar is closed, we will + // remove that entry from the list. + foreach (InfoBar entry in s_entries.ToList()) { entry.OnProjectClosed(_project); }