LTR
LTR

Reputation: 1362

'Diagnostic analyzer runner' is currently unavailable due to an internal error

I'm using the Visual Studio 2022 (17.4.4). This is a .NET 6 C# project.

When running code analysis on my project, I immediately get the message "Code analysis completed for 'projectname'". No code analysis warnings or errors are displayed.

When I then leave Visual Studio open for a couple of minutes (without doing anything), after 2-3 minutes an error bar appear:

"Feature 'Diagnostic analyzer runner' is currently unavailable due to an internal error. [Show Stack Trace]"

When I click on "Show Stack Trace", I get a stack trace (attached at the bottom of this post).

How can I fix this or investigate further?

StreamJsonRpc.RemoteInvocationException: An item with the same key has already been added.
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__143`1.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.Remote.BrokeredServiceConnection`1.<TryInvokeAsync>d__18`1.MoveNext()
RPC server exception:
System.ArgumentException: An item with the same key has already been added.
      at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
      at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
      at Microsoft.CodeAnalysis.RemoveUnnecessarySuppressions.AbstractRemoveUnnecessaryInlineSuppressionsDiagnosticAnalyzer.<ProcessSuppressMessageAttributesAsync>d__25.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.RemoveUnnecessarySuppressions.AbstractRemoveUnnecessaryInlineSuppressionsDiagnosticAnalyzer.<AnalyzeAsync>d__16.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.Diagnostics.Extensions.<>c__DisplayClass9_0.<<GetPragmaSuppressionAnalyzerDiagnosticsAsync>g__AnalyzeDocumentAsync|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.CodeAnalysis.Diagnostics.Extensions.<GetPragmaSuppressionAnalyzerDiagnosticsAsync>d__9.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.Diagnostics.Extensions.<GetAnalysisResultAsync>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.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<AnalyzeAsync>d__10.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.Remote.Diagnostics.DiagnosticComputer.<GetDiagnosticsAsync>d__9.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.Remote.RemoteDiagnosticAnalyzerService.<>c__DisplayClass4_0.<<CalculateDiagnosticsAsync>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.CodeAnalysis.Remote.RemoteWorkspace.<>c__DisplayClass7_0`1.<<RunWithSolutionAsync>g__ProcessSolutionAsync|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.CodeAnalysis.Remote.RemoteWorkspace.<RunWithSolutionAsync>d__7`1.MoveNext()
   --- End of stack trace from previous location where exception was thrown ---
      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<RunWithSolutionAsync>d__7`1.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.Remote.BrokeredServiceBase.<RunWithSolutionAsync>d__11`1.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.Remote.RemoteDiagnosticAnalyzerService.<CalculateDiagnosticsAsync>d__4.MoveNext()

Upvotes: 1

Views: 2017

Answers (3)

Kirsten
Kirsten

Reputation: 18130

For me, disabling my Dev Express CodeRush extension solved this.

Upvotes: 2

George Beier
George Beier

Reputation: 256

My experience was similar (VS 17.7.2). If I just opened a .cs file and did nothing, the errors would begin to appear. Once they started appearing, only closing Visual Studio would make them go away. They would reappear after waiting a few minutes after I restarted VS. I noticed it only happened when I had particular .cs files open.

I tracked down the error to a really long string concatenation. I had a long string that looked like:

string longString = var1 + "," + var2 + "," ... _ var685 etc.

I did this for 685 variables. I know, I know, I should use stringbuilder or concat or join, etc. But I thought that this would be the fastest way to do the concatenation and it's auto-generated.

If I break it into two strings (e.g. longString1 and longString2) and then add them together then the errors go away. So I just replaced it with:

 string longString1 = var1 + "," + var2 + "," ... _ var400;
 string longString2 = var401 + "," + var402 + "," ... _ var685
 string longString = longString1 + longString2;

And the errors went away. Hope this helps.

Upvotes: 0

Youssef13
Youssef13

Reputation: 4984

When you encounter such a message, it's a bug. So, there is likely no fix you can do on your end. Such bugs should be reported to Microsoft.

This bug was already reported https://github.com/dotnet/roslyn/issues/50496

You'll have to wait for a fix.

Upvotes: 3

Related Questions