C# – The project system has encountered an error When trying to load project

cvisual studiovisual-studio-2017

In Visual Studio 2017 v15.7.1 I am getting the following error window when trying to load one of my projects:

VS error window

And when I go to the path specified, inside the test file I find a very long stack-trace which I could not copy all of it because it exceeds allowed characters count.

===================== 5/31/2018 3:40:57 PM LimitedFunctionality System.AggregateException: Project system data flow
'ProjectBuildSnapshotService Outer 320459' closed because of an
exception: System.AggregateException: One or more errors occurred.
—> System.AggregateException: One or more errors occurred. —> System.AggregateException: One or more errors occurred. —>
System.AggregateException: One or more errors occurred. —>
System.NullReferenceException: Object reference not set to an instance
of an object. at
Microsoft.VisualStudio.ProjectServices.DesignTimeBuilder.d__17.MoveNext()
— End of stack trace from previous location where exception was thrown — at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.ProjectSystem.Build.DesignTimeBuilderService.BuilderLifetimeHelper.d__12.MoveNext()
— End of stack trace from previous location where exception was thrown — at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.ProjectSystem.Build.DesignTimeBuilderService.d__36.MoveNext()
— End of stack trace from previous location where exception was thrown — at
Microsoft.VisualStudio.ProjectSystem.Build.DesignTimeBuilderService.d__36.MoveNext()
— End of stack trace from previous location where exception was thrown — at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at
Microsoft.VisualStudio.ProjectSystem.Build.DesignTimeBuildManagerService.d__55.MoveNext()
— End of stack trace from previous location where exception was thrown — at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at
Microsoft.VisualStudio.ProjectSystem.Build.DesignTimeBuildManagerService.d__53.MoveNext()
— End of stack trace from previous location where exception was thrown — at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.ProjectSystem.Designers.ProjectBuildSnapshotService.d__74.MoveNext()
— End of stack trace from previous location where exception was thrown — at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at
Microsoft.VisualStudio.ProjectSystem.Designers.ProjectBuildSnapshotService.<>c__DisplayClass72_0.<b__0>d.MoveNext()
— End of stack trace from previous location where exception was thrown — at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.Threading.JoinableTask.d__78.MoveNext()
— End of stack trace from previous location where exception was thrown — at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.Threading.JoinableTask1.<JoinAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.ProjectSystem.Designers.ProjectBuildSnapshotService.<UpdateSnapshotCoreAsync>d__72.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at
Microsoft.VisualStudio.ProjectSystem.Designers.CustomizableBlockSubscriberBase
3.d__34.MoveNext()
— End of stack trace from previous location where exception was thrown — at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.ProjectSystem.Designers.CustomizableBlockSubscriberBase3.<>c__DisplayClass32_0.<<Initialize>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.Threading.JoinableTask.<JoinAsync>d__78.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.ProjectSystem.Designers.CustomizableBlockSubscriberBase
3.<b__32_0>d.MoveNext()
— End of stack trace from previous location where exception was thrown — at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.ProjectSystem.DataflowExtensions.<>c__DisplayClass24_0`2.<b__0>d.MoveNext()

Best Answer

I found that you need to do two steps to resolve this issue:

  1. Delete the .vs folder at the solution level.
  2. Delete the bin and obj folders in all projects within the solution.

I encountered the issue in Visual Studio 2017 v15.7.4 and the affected project/solution was created in v15.7.4, so it can occur without upgrading to a new version of Visual Studio.

Related Topic