dotnet / project-system

The .NET Project System for Visual Studio
MIT License
969 stars 387 forks source link

After upgraded to VS2022 17.6, error when loading project: Project system data flow 'Workspace update handler ActionBlockSlimAsync`1' closed because of an exception: This program location is thought to be unreachable. #9035

Closed nickkfwong closed 1 year ago

nickkfwong commented 1 year ago

Visual Studio Version

VS2022 Professional 17.6 (I don't remember the previous version, but it should be 17.5 if my memory is correct)

Summary

Seeing below error on one of the project from a big solution. That project cannot be built.

This issue appears after i upgraded my VS2022 just now.

LimitedFunctionality
System.AggregateException: Project system data flow 'Workspace update handler ActionBlockSlimAsync`1' closed because of an exception: This program location is thought to be unreachable. File='/_/src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentStates.cs' Line=76.
---> (Inner Exception #0) System.InvalidOperationException: This program location is thought to be unreachable. File='/_/src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentStates.cs' Line=76
   at Microsoft.CodeAnalysis.SolutionState.WithDocumentContentsFrom(DocumentId documentId, DocumentState documentState)
   at Microsoft.CodeAnalysis.Solution.WithDocumentContentsFrom(DocumentId documentId, DocumentState documentState)
   at Microsoft.CodeAnalysis.Workspace.<SetCurrentSolution>g__UpdateExistingDocumentsToChangedDocumentContents|26_2(Solution solution, DocumentId changedDocumentId, HashSet`1 processedDocuments)
   at Microsoft.CodeAnalysis.Workspace.<SetCurrentSolution>g__UnifyLinkedDocumentContents|26_0(Solution oldSolution, Solution newSolution)
   at Microsoft.CodeAnalysis.Workspace.<>c.<SetCurrentSolution>b__26_3(Solution oldSolution, ValueTuple`7 data)
   at Microsoft.CodeAnalysis.Workspace.SetCurrentSolution[TData](TData data, Func`3 transformation, Action`3 onBeforeUpdate, Action`3 onAfterUpdate)
   at Microsoft.CodeAnalysis.Workspace.SetCurrentSolution(Func`2 transformation, Func`3 changeKind, ProjectId projectId, DocumentId documentId, Action`2 onBeforeUpdate, Action`2 onAfterUpdate)
   at Microsoft.CodeAnalysis.Workspace.SetCurrentSolution(Func`2 transformation, WorkspaceChangeKind changeKind, ProjectId projectId, DocumentId documentId, Action`2 onBeforeUpdate, Action`2 onAfterUpdate)
   at Microsoft.CodeAnalysis.Workspaces.ProjectSystem.ProjectSystemProjectFactory.ApplyBatchChangeToWorkspace_NoLock(SolutionChangeAccumulator solutionChanges)
   at Microsoft.CodeAnalysis.Workspaces.ProjectSystem.ProjectSystemProjectFactory.<ApplyBatchChangeToWorkspaceMaybeAsync>d__45.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Workspaces.ProjectSystem.ProjectSystemProject.<OnBatchScopeDisposedMaybeAsync>d__102.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Workspaces.ProjectSystem.ProjectSystemProject.BatchScope.<DisposeAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.LanguageServices.Workspace.<>c__DisplayClass42_1`1.<<OnProjectChangedAsync>g__ApplyInBatchAsync|1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.<>c__DisplayClass3_0.<<ExecuteAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.<ExecuteAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.OnceInitializedOnceDisposedUnderLockAsync.<ExecuteUnderLockCoreAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.LanguageServices.Workspace.<OnBuildUpdateAsync>d__40.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.LanguageServices.Workspace.<>c__DisplayClass38_0.<<OnWorkspaceUpdateAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.LanguageServices.Workspace.<>c__DisplayClass38_0.<<OnWorkspaceUpdateAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.LanguageServices.Workspace.<OnWorkspaceUpdateAsync>d__38.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.<ProcessInputQueueAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex)
   at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.<Guard>g__Action|0()
   at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )
<--- (Inner Exception #0) 
===================
drewnoakes commented 1 year ago

@nickkfwong this error likely belongs to the Roslyn IDE team, who are not in this repo.

Are you able to reproduce this? Could you use Help | Send Feedback | Report a problem within VS to create a ticket about this, and please include a recording during which you cause this error to happen. That'll attach diagnostic information which will greatly help in diagnosing the issue here.

If you link the ticket here, I'll make sure it gets to routed to the right team.

Thanks.

drewnoakes commented 1 year ago

FYI @jasonmalinowski

jasonmalinowski commented 1 year ago

This internally is tracked in https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1801256. @drewnoakes do you want to just close this in favor of that one, or leave this open too? We can move and assign to me too.

drewnoakes commented 1 year ago

I'm happy to close this @jasonmalinowski. Do you have all the information you need to fix this? Please let @nickkfwong know whether it'd be helpful for them to submit a ticket recording the error happening or not.

jasonmalinowski commented 1 year ago

I've been heads down on other things so haven't looked yet, but from the stack I'd hope this should be easy enough to sort out without further info.

nickkfwong commented 1 year ago

I've been heads down on other things so haven't looked yet, but from the stack I'd hope this should be easy enough to sort out without further info.

Thank you all.

Initially, I was suspecting this is due to some sections in my csproj, so I tried removed some of the suspicious project settings, but no luck. Our solution also has some solution level linked items that have been moved. I removed those broken links but also no luck.

The problematic project is a WPF project (entry proj for our app) which used Sdk="MSBuild.Sdk.Extras/1.6.68".

If you need any further info for troubleshoot, please let me know, I will try to provide as much as possible without the company info.

Note - I have rolled back to 17.5.1 and project can be built as usual.

ChairmanMawh commented 1 year ago

Hi All

I also just started getting this my v17.6 VS. I didn't get it after an upgrade and have been using 17.6 for months

As for how to repro, I'm not sure; I use an extenson called EF Core Power Tools that saves its config at a project level. This causes me some nuisance when I want to reverse engineer more than one DB in a project; formerly I would do a reverse for DB 1, then a reverse for DB 2, and if I ever wanted to reverse DB 1 again I'd just re-do it (EFCPT would populate the UI with the settings for DB 2).

I then had the bright idea of adding a DLL per DB, so EFCPT could store its config at project level and I have a project for each DB. While stripping out the combined DBs folder hierarchies to new projects and re-reversing them all, this error started occurring, and I haven't been able to make it go away yet.

Stack trace it byte identical to the posted stack above. Unlike that complaint though, I don't seem to have any problem building at the moment, but some syntax highlighting and intellisense related features appear to be deactivated

I'm repairing VS now, and maybe I'll try the 17.7 preview if repair doesn't work..

ADefWebserver commented 1 year ago

(using Version 17.6.5) I installed EF Core Power Tools into a Blazor MAUI project and now if I create a new Blazor MAU project I get (even on a new project that does not have EF Core Power Tools):

8/5/2023 6:26:11 PM Recoverable System.AggregateException: Project system data flow 'DataflowBlockSlim (ActionBlockSlimAsync1 : 21706361)' closed because of an exception: Unable to find method: Microsoft.Windows.Msix.VisualStudio.ProjectExtensions.Debug.AppContainerDebugLaunchTargetsProvider..ctor(Microsoft.VisualStudio.ProjectSystem.UnconfiguredProject, Microsoft.Windows.Msix.VisualStudio.ProjectExtensions.Project.IProjectCfg, Microsoft.VisualStudio.ProjectSystem.IProjectThreadingService). ---> (Inner Exception #0) System.InvalidOperationException: Unable to find method: Microsoft.Windows.Msix.VisualStudio.ProjectExtensions.Debug.AppContainerDebugLaunchTargetsProvider..ctor(Microsoft.VisualStudio.ProjectSystem.UnconfiguredProject, Microsoft.Windows.Msix.VisualStudio.ProjectExtensions.Project.IProjectCfg, Microsoft.VisualStudio.ProjectSystem.IProjectThreadingService) at Microsoft.VisualStudio.Composition.Reflection.ResolverExtensions.Resolve(MethodRef methodRef) at Microsoft.VisualStudio.Composition.Reflection.MemberRef.get_MemberInfo() at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue() at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create() at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState) at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveToState(PartLifecycleState requiredState) at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose() at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.ConstructExportedValue(RuntimeImport import, RuntimeExport export, RuntimePartLifecycleTracker importingPartTracker, PartLifecycleTracker partLifecycle, ReportFaultCallback faultCallback) at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.<>c__DisplayClass16_0.<GetExportedValue>b__1() at Microsoft.VisualStudio.Composition.DelegateServices.<>c__DisplayClass2_01.b0() at System.Lazy1.CreateValue() at System.Lazy1.LazyInitValue() at Microsoft.VisualStudio.ProjectSystem.VS.Debug.LaunchProfilesDebugLaunchProvider.GetLaunchTargetsProvider(ILaunchProfile profile) at Microsoft.VisualStudio.ProjectSystem.VS.Debug.LaunchProfilesDebugLaunchProvider.d8.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.VisualStudio.ProjectSystem.VS.Debug.StartupProjectRegistrar.d14.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.ProjectSystem.VS.Debug.StartupProjectRegistrar.<b13_0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.<>cDisplayClass15_0.<b0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.d5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex) at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.gAction|0() at GuardMethodClass.GuardMethod(Func1 , Func2 , Func`2 ) <--- (Inner Exception #0)

ADefWebserver commented 1 year ago

See this link for the cause and a possible solution: https://github.com/microsoft/microsoft-ui-xaml/issues/8419

ADefWebserver commented 1 year ago

For now I can get past this error by opening the project using the latest Visual Studio 2022 preview