"Failed to analyze xxx StreamJsonRpc.RemoteInvocationException" when opening C# file

  • Operating system: Windows 10 Pro, 22H2, 19045.5011
  • Visual Studio version: Community 2022, 17.11.5
  • SonarLint plugin version: 8.6.0.10679
  • Programming language you’re coding in: C#
  • Is connected mode used: No

When opening a C# file, Visual Studio’s status bar shows the message “SonarLint: Failed to analyze file.cs. See the Output Window for more information”. The “SonarLint” output in the output window shows these messages:

[SLCoreAnalyzer] Analyzing xxx\file.cs with id 
[SLCoreAnalyzer] Failed to analyze xxx\file.cs with id : StreamJsonRpc.RemoteInvocationException: Value cannot be null.
Parameter name: path1
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__154`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 SonarLint.VisualStudio.SLCore.Analysis.SLCoreAnalyzer.<ExecuteAnalysisInternalAsync>d__7.MoveNext()
RPC server exception:
System.ArgumentNullException: Value cannot be null.
Parameter name: path1
      at System.IO.Path.Combine(String path1, String path2)
      at SonarLint.VisualStudio.Integration.SolutionWorkspaceService.<>c__DisplayClass9_0.<AllItemsInProject>b__0(VSITEMID id)
      at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
      at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
      at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
      at System.Collections.Generic.HashSet`1.UnionWith(IEnumerable`1 other)
      at System.Collections.Generic.HashSet`1..ctor(IEnumerable`1 collection, IEqualityComparer`1 comparer)
      at System.Linq.Enumerable.ToHashSet[TSource](IEnumerable`1 source, IEqualityComparer`1 comparer)
      at SonarLint.VisualStudio.Integration.SolutionWorkspaceService.<>c__DisplayClass7_0.<GetAllFilesInSolution>b__0()
      at SonarLint.VisualStudio.Infrastructure.VS.ThreadHandling.<>c__DisplayClass5_0.<<RunOnUIThread>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.JoinableTask.CompleteOnCurrentThread()
      at SonarLint.VisualStudio.Infrastructure.VS.ThreadHandling.RunOnUIThread(Action op)
      at SonarLint.VisualStudio.Integration.SolutionWorkspaceService.GetAllFilesInSolution(IVsSolution solution)
      at SonarLint.VisualStudio.SLCore.Listeners.Implementation.ListFilesListener.ListFilesAsync(ListFilesParams parameters)

It seems to happen with any file, with or without errors. The SonarLint analysis warnings/suggestions/etc for the file still appear, though. I’m not 100% sure of this, but it seems to only happen on projects for the Unity game engine, as I haven’t been able to reproduce it on other types of projects.

2 Likes

Hello Trisibo,

Thank you for bringing this to our attention.

The errors you’re encountering are related to the SonarLint out-of-process service, which handles the analysis for all languages except C#, VB, C, and C++. This is why you are still able to see SonarLint issues for C#, as its analysis remains unaffected. However, these errors are unexpected, and we’d appreciate your assistance in diagnosing the cause so we can work on a resolution.

If possible, could you please share the full Verbose logs with us? You can find the instructions for obtaining these logs here: SonarLint Troubleshooting Guide.

Additionally, any further details about your project setup would be very helpful. For instance, have you opened the project as a solution, or is it set up as a folder/workspace?

Thank you again for your support.

Best regards,
Vasileios

1 Like

The project is opened as a solution. I’m not sure if it’s relevant, but it’s a Unity project, which means Unity creates and updates the solution and project files. At first I thought it could have something to do with it being a Unity project somehow, because it happened with a pair of them and not other types of projects, but I have just checked with another Unity project and it doesn’t happen on it.

This is the log, just after opening the project, with one file opened at the start:

[ThreadId 1] [DEBUG] [ConnectedMode/GitMonitor] Monitoring git repo. Root path: H:\PathPart1\PathPart2\Project Name
[ThreadId 22] [FileTracker] Service Provider is unavailable
[ThreadId 26] [DEBUG] [ExclusionSettingsStorage] Standalone mode, exclusions are not supported.
[ThreadId 26] [DEBUG] [AnalyzableFileIndicator] No server settings were found.
[ThreadId 26] [SLCoreAnalyzer] Analyzing H:\PathPart1\PathPart2\Project Name\Assets\Test.cs with id 
[ThreadId 26] [SLCoreAnalyzer] Analysis  not ready for file H:\PathPart1\PathPart2\Project Name\Assets\Test.cs: Configuration scope not initialized
[ThreadId 1] Initializing the telemetry package...
[ThreadId 1] Finished initializing the telemetry package...
[ThreadId 1] Initializing the SonarLint package...
[ThreadId 1] Finishing initializing the SonarLint package
[ThreadId 83] Initializing the notifications package...
[ThreadId 1] Not connected: not checking for notifications
[ThreadId 1] Finished initializing the notifications package
[ThreadId 1] [SharedBindingConfigProvider] SonarLint shared folder was not found
[ThreadId 92] Initializing the daemon package...
[ThreadId 92] [Connection Migration] Start migrating connections from existing bindings
[ThreadId 92] [Connection Migration] End migrating connections from existing bindings
[ThreadId 32] [SLCoreHandler] Creating SLCore instance
[ThreadId 32] [SLCoreHandler] Starting SLCore instance
[ThreadId 32] Loaded settings from "C:\Users\trisi\AppData\Roaming\SonarLint for Visual Studio\settings.json".
[ThreadId 1] Current VS version:
    Visual Studio Community 2022
    17.11.35327.3
    17.11.5
[ThreadId 32] [NodeJSLocator] Checking environment variable SONAR_NODEJS_PATH
[ThreadId 32] [NodeJsLocator] Environment variable is not set
[ThreadId 32] Finished initializing the daemon package.
[ThreadId 54] [DEBUG] [SLCORE] SonarLint backend started, instance=org.sonarsource.sonarlint.core.rpc.impl.SonarLintRpcServerImpl@cb0755b
[ThreadId 44] [DEBUG] [SLCORE] Started embedded server on port 64120
[ThreadId 13] [DEBUG] [SLCORE] Restoring previous local-only issue database from C:\Users\trisi\AppData\Local\SLVS_SLOOP\storageRoot\local_only_issue_backup.tar.gz
[ThreadId 51] [DEBUG] [SLCORE] Starting local-only issue database from C:\Users\trisi\.sonarlint\xodus-local-only-issue-store13328066781943776530
[ThreadId 23] [SLCORE] Can't open directory channel. Log directory fsync won't be performed.
[ThreadId 52] [SLCORE] Unexpected error occurred in scheduled task
[ThreadId 52] [DEBUG] [SLCORE] Synchronizing new configuration scopes: [Project Name]
[ThreadId 7] [DEBUG] [SLCORE] Looking for node in the PATH
[ThreadId 53] [DEBUG] [SLCORE] Execute command 'C:\Windows\System32\where.exe $PATH:node.exe'...
[ThreadId 7] [DEBUG] [SLCORE] Command 'C:\Windows\System32\where.exe $PATH:node.exe' exited with 1
stderr: INFO: Could not find files for the given pattern(s).
[ThreadId 7] [DEBUG] [SLCORE] Unable to locate node
[ThreadId 7] [SLCORE] Node.js could not be automatically detected, has to be configured manually in the SonarLint preferences!
[ThreadId 7] [DEBUG] [SLCORE] Plugin 'JavaScript/TypeScript/CSS Code Quality and Security' requires Node.js 18.17.0. Skip loading it.
[ThreadId 7] [DEBUG] [SLCORE] Loaded 4 plugins
[ThreadId 7] [DEBUG] [SLCORE]   * CFamily Code Quality and Security 6.59.0.75237 (cpp)
[ThreadId 7] [DEBUG] [SLCORE]   * C# Code Quality and Security 9.32.0.97167 (csharp)
[ThreadId 7] [DEBUG] [SLCORE]   * Text Code Quality and Security 2.16.0.4008 (text)
[ThreadId 7] [DEBUG] [SLCORE]   * VB.NET Code Quality and Security 9.32.0.97167 (vbnet)
[ThreadId 7] [DEBUG] [SLCORE] Creating container for module 'Project Name'
[ThreadId 7] Updated analysis readiness: True
[ThreadId 38] Starting job: "re-analyzing 1 document(s)...". Time: 16:57:12
[ThreadId 38] Finished job "re-analyzing 1 document(s)..." started at 16:57:12. Elapsed time: 6ms
[ThreadId 14] [DEBUG] [ExclusionSettingsStorage] Standalone mode, exclusions are not supported.
[ThreadId 14] [DEBUG] [AnalyzableFileIndicator] No server settings were found.
[ThreadId 14] [SLCoreAnalyzer] Analyzing H:\PathPart1\PathPart2\Project Name\Assets\Test.cs with id 
[ThreadId 10] [DEBUG] [SLCORE] Extracting standalone rules metadata
[ThreadId 14] [DEBUG] [SLCORE] Computing file exclusion for uri 'file:///H:/PathPart1/PathPart2/Project%20Name/Assets/Test.cs'
[ThreadId 14] [DEBUG] [SLCORE] Unable to find client file for uri file:///H:/PathPart1/PathPart2/Project%20Name/Assets/Test.cs
[ThreadId 14] [DEBUG] [SLCORE] Relativizing path: H:\PathPart1\PathPart2\Project Name\Assets\Test.cs for git repo Assets
[ThreadId 28] [SLCoreAnalyzer] Failed to analyze H:\PathPart1\PathPart2\Project Name\Assets\Test.cs with id : StreamJsonRpc.RemoteInvocationException: Value cannot be null.
Parameter name: path1
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__154`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 SonarLint.VisualStudio.SLCore.Analysis.SLCoreAnalyzer.<ExecuteAnalysisInternalAsync>d__7.MoveNext()
RPC server exception:
System.ArgumentNullException: Value cannot be null.
Parameter name: path1
      at System.IO.Path.Combine(String path1, String path2)
      at SonarLint.VisualStudio.Integration.SolutionWorkspaceService.<>c__DisplayClass9_0.<AllItemsInProject>b__0(VSITEMID id)
      at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
      at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
      at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
      at System.Collections.Generic.HashSet`1.UnionWith(IEnumerable`1 other)
      at System.Collections.Generic.HashSet`1..ctor(IEnumerable`1 collection, IEqualityComparer`1 comparer)
      at System.Linq.Enumerable.ToHashSet[TSource](IEnumerable`1 source, IEqualityComparer`1 comparer)
      at SonarLint.VisualStudio.Integration.SolutionWorkspaceService.<>c__DisplayClass7_0.<GetAllFilesInSolution>b__0()
      at SonarLint.VisualStudio.Infrastructure.VS.ThreadHandling.<>c__DisplayClass5_0.<<RunOnUIThread>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.JoinableTask.CompleteOnCurrentThread()
      at SonarLint.VisualStudio.Infrastructure.VS.ThreadHandling.RunOnUIThread(Action op)
      at SonarLint.VisualStudio.Integration.SolutionWorkspaceService.GetAllFilesInSolution(IVsSolution solution)
      at SonarLint.VisualStudio.SLCore.Listeners.Implementation.ListFilesListener.ListFilesAsync(ListFilesParams parameters)

I have checked with the Unity project in which the issue doesn’t happen, and the main difference apart from the errors seems to be the line [SLCORE] Unexpected error occurred in scheduled task, which in the project without the issue is [DEBUG] [SLCORE] No connections configured, skipping binding suggestions.. This is the full log:

[ThreadId 1] [DEBUG] [ConnectedMode/GitMonitor] Monitoring git repo. Root path: H:\PathPart1\PathPart2\Project Name
[ThreadId 55] [FileTracker] Service Provider is unavailable
[ThreadId 54] [DEBUG] [ExclusionSettingsStorage] Standalone mode, exclusions are not supported.
[ThreadId 54] [DEBUG] [AnalyzableFileIndicator] No server settings were found.
[ThreadId 54] [SLCoreAnalyzer] Analyzing H:\PathPart1\PathPart2\Project Name\Assets\Test.cs with id 
[ThreadId 54] [SLCoreAnalyzer] Analysis  not ready for file H:\PathPart1\PathPart2\Project Name\Assets\Test.cs: Configuration scope not initialized
[ThreadId 1] Initializing the telemetry package...
[ThreadId 1] Finished initializing the telemetry package...
[ThreadId 1] Initializing the SonarLint package...
[ThreadId 1] Finishing initializing the SonarLint package
[ThreadId 86] Initializing the notifications package...
[ThreadId 1] Not connected: not checking for notifications
[ThreadId 1] Finished initializing the notifications package
[ThreadId 1] [SharedBindingConfigProvider] SonarLint shared folder was not found
[ThreadId 102] Initializing the daemon package...
[ThreadId 102] [Connection Migration] Start migrating connections from existing bindings
[ThreadId 102] [Connection Migration] End migrating connections from existing bindings
[ThreadId 30] [SLCoreHandler] Creating SLCore instance
[ThreadId 30] [SLCoreHandler] Starting SLCore instance
[ThreadId 30] Loaded settings from "C:\Users\trisi\AppData\Roaming\SonarLint for Visual Studio\settings.json".
[ThreadId 1] Current VS version:
    Visual Studio Community 2022
    17.11.35327.3
    17.11.5
[ThreadId 30] [NodeJSLocator] Checking environment variable SONAR_NODEJS_PATH
[ThreadId 30] [NodeJsLocator] Environment variable is not set
[ThreadId 30] Finished initializing the daemon package.
[ThreadId 49] [DEBUG] [SLCORE] SonarLint backend started, instance=org.sonarsource.sonarlint.core.rpc.impl.SonarLintRpcServerImpl@cb0755b
[ThreadId 56] [DEBUG] [SLCORE] Started embedded server on port 64120
[ThreadId 37] [DEBUG] [SLCORE] Restoring previous local-only issue database from C:\Users\trisi\AppData\Local\SLVS_SLOOP\storageRoot\local_only_issue_backup.tar.gz
[ThreadId 45] [DEBUG] [SLCORE] Starting local-only issue database from C:\Users\trisi\.sonarlint\xodus-local-only-issue-store15866362078860775608
[ThreadId 10] [SLCORE] Can't open directory channel. Log directory fsync won't be performed.
[ThreadId 16] [DEBUG] [SLCORE] No connections configured, skipping binding suggestions.
[ThreadId 16] [DEBUG] [SLCORE] Synchronizing new configuration scopes: [Project Name]
[ThreadId 37] [DEBUG] [SLCORE] Looking for node in the PATH
[ThreadId 53] [DEBUG] [SLCORE] Execute command 'C:\Windows\System32\where.exe $PATH:node.exe'...
[ThreadId 37] [DEBUG] [SLCORE] Command 'C:\Windows\System32\where.exe $PATH:node.exe' exited with 1
stderr: INFO: Could not find files for the given pattern(s).
[ThreadId 37] [DEBUG] [SLCORE] Unable to locate node
[ThreadId 37] [SLCORE] Node.js could not be automatically detected, has to be configured manually in the SonarLint preferences!
[ThreadId 39] [DEBUG] [SLCORE] Plugin 'JavaScript/TypeScript/CSS Code Quality and Security' requires Node.js 18.17.0. Skip loading it.
[ThreadId 10] [DEBUG] [SLCORE] Loaded 4 plugins
[ThreadId 10] [DEBUG] [SLCORE]   * CFamily Code Quality and Security 6.59.0.75237 (cpp)
[ThreadId 10] [DEBUG] [SLCORE]   * C# Code Quality and Security 9.32.0.97167 (csharp)
[ThreadId 10] [DEBUG] [SLCORE]   * Text Code Quality and Security 2.16.0.4008 (text)
[ThreadId 10] [DEBUG] [SLCORE]   * VB.NET Code Quality and Security 9.32.0.97167 (vbnet)
[ThreadId 39] [DEBUG] [SLCORE] Creating container for module 'Project Name'
[ThreadId 53] Updated analysis readiness: True
[ThreadId 55] Starting job: "re-analyzing 1 document(s)...". Time: 17:20:49
[ThreadId 55] Finished job "re-analyzing 1 document(s)..." started at 17:20:49. Elapsed time: 7ms
[ThreadId 53] [DEBUG] [ExclusionSettingsStorage] Standalone mode, exclusions are not supported.
[ThreadId 53] [DEBUG] [AnalyzableFileIndicator] No server settings were found.
[ThreadId 53] [SLCoreAnalyzer] Analyzing H:\PathPart1\PathPart2\Project Name\Assets\Test.cs with id 
[ThreadId 18] [DEBUG] [SLCORE] Language of file "file:///H:/PathPart1/PathPart2/Project%20Name/Assets/Test.cs" is detected to be "CS"
[ThreadId 16] [DEBUG] [SLCORE] Computing file exclusion for uri 'file:///H:/PathPart1/PathPart2/Project%20Name/Assets/Test.cs'
[ThreadId 10] [DEBUG] [SLCORE] Extracting standalone rules metadata
[ThreadId 28] [DEBUG] [SLCORE] Relativizing path: H:\PathPart1\PathPart2\Project Name\Assets\Test.cs for git repo Assets
[ThreadId 28] [DEBUG] [SLCORE] Triggering analysis with configuration: [
  baseDir: H:\PathPart1\PathPart2\Project Name\Assets
  extraProperties: {}
  activeRules: [425 cpp, 189 c, 90 secrets]
  inputFiles: [
    file:///H:/PathPart1/PathPart2/Project%20Name/Assets/Test.cs (UTF-8)
  ]
]

[ThreadId 28] [DEBUG] [SLCORE] Restoring previous known findings database from C:\Users\trisi\AppData\Local\SLVS_SLOOP\storageRoot\known_findings_backup.tar.gz
[ThreadId 28] [DEBUG] [SLCORE] Starting known findings database from C:\Users\trisi\.sonarlint\known-findings-store958034014655703530
[ThreadId 31] [DEBUG] [SLCORE] Start analysis
[ThreadId 9] [DEBUG] [SLCORE] Index files
[ThreadId 9] [DEBUG] [SLCORE] Language of file "file:///H:/PathPart1/PathPart2/Project%20Name/Assets/Test.cs" is detected to be "CS"
[ThreadId 52] [DEBUG] [SLCORE] 1 file indexed
[ThreadId 13] [DEBUG] [SLCORE] Execute Sensor: TextAndSecretsSensor
[ThreadId 13] [DEBUG] [SLCORE] Available processors: 20
[ThreadId 13] [DEBUG] [SLCORE] Using 20 threads for analysis.
[ThreadId 52] [DEBUG] [SLCORE] The property "sonar.tests" is not set. To improve the analysis accuracy, we categorize a file as a test file if any of the following is true:
  * The filename starts with "test"
  * The filename contains "test." or "tests."
  * Any directory in the file path is named: "doc", "docs", "test" or "tests"
  * Any directory in the file path has a name ending in "test" or "tests"

[ThreadId 31] [DEBUG] [SLCORE] Analyzing all except non binary files
[ThreadId 9] [DEBUG] [SLCORE] 1 source file to be analyzed
[ThreadId 36] [DEBUG] [SLCORE] 1/1 source file has been analyzed
[ThreadId 15] [DEBUG] [SLCORE] Analysis detected 0 issues and 0 Security Hotspots in 1254ms
[ThreadId 13] [DEBUG] [SLCORE] Matching Sonar project branch
[ThreadId 13] [DEBUG] [SLCORE] No binding for configuration scope
[ThreadId 13] [DEBUG] [SLCORE] Computing paths translation for config scope 'Project Name'...
[ThreadId 13] [DEBUG] [SLCORE] Config scope 'Project Name' does not exist or is not bound
[ThreadId 52] [SLCoreAnalyzer] Finished analyzing H:\PathPart1\PathPart2\Project Name\Assets\Test.cs with id e8060965-ae65-4047-ac25-5b9c6bee1732, analysis time: 0s
[ThreadId 52] [SLCoreAnalyzer] Found 0 issue(s) for H:\PathPart1\PathPart2\Project Name\Assets\Test.cs

It seems to be an issue with Visual Studio, people using Roslynator also seem to have the issue: github.com/dotnet

1 Like

It doesn’t seem to be exactly the same issue, as the exception on that one is “Argument contains duplicate analyzer instances” and in my report it’s “Value cannot be null” (“Parameter name: path1”). Maybe they are related, but no idea.

Today I updated to newest version of SonareQube for IDE, and the issue is still there. Is there any progress on this?

Hey everyone,

Thanks for reporting that and sorry for the delay in getting back to you! I tried to replicate the problem on my end but haven’t been able to reproduce it so far. If any of you could share a sample project where the analysis isn’t working, that would be really helpful.

Additionally, if there’s anything unique about your setup (custom configurations, weird paths, files on different drives, symbolic links, etc.), please let me know, that might help pinpoint what’s going wrong. Appreciate your patience, and I’ll do my best to get this sorted out!

For me, it was not project dependent. If I have SonarQube IDE enabled in visual studio it crashes directly. I checked if it might be due to Visual Studio Spell Checker (by EWSoftware), the only other none MS extension I have running.

However, now I try to reproduce it, it does not longer crash on 3 solutions that are accessible via GitHub. I’ll will keep trying to reproduce it. Sharing company code might not be that straightforward as it also requires access to private package servers.

I was too quick with my response: opening the solution of GitHub - dotnet-project-file-analyzers/dotnet-project-file-analyzers: Contains roslyn static code analyzers to analyze .NET project files. crashes too.

Thanks for following up! It’s interesting that it initially stopped crashing but then did again with the dotnet-project-file-analyzers repo.

Since I haven’t been able to reproduce the issue, could you check a few things?

Just to clarify, when you say “crash,” do you mean that the Extension stops working and you get a gold bar notification, or is it that the SonarQube for IDE analysis isn’t running properly?

If it’s the latter, could you check the SonarQube for IDE logs to see if there are any errors? If you find anything, could you post the logs in Verbose mode here? That might give us more insight into what’s going wrong.

Also, is there anything unique about your setup that could affect the analysis? For example:

  • Are your project files on a network drive?
  • Do you have any additional analyzers, special configurations, symlinks, or custom MSBuild settings?

Any extra details would be really helpful in narrowing this down! Appreciate you taking the time to troubleshoot this with me.

If I have no files open, also when I build, nothing happens.

Once I open a file I get this message popping op:

Feature ‘Diagnostic analyzer runner’ is currently unavailable due to an internal error. Show Stack Trace

The StackTrace

StreamJsonRpc.RemoteInvocationException: Argument contains an analyzer instance that does not belong to the 'Analyzers' for this CompilationWithAnalyzers instance. (Parameter '_analyzers')
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__156`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: Argument contains an analyzer instance that does not belong to the 'Analyzers' for this CompilationWithAnalyzers instance. (Parameter '_analyzers')
      at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyExistingAnalyzersArgument(ImmutableArray`1 analyzers)
      at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.GetAnalysisResultAsync(SyntaxTree tree, Nullable`1 filterSpan, ImmutableArray`1 analyzers, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzersPair.GetAnalysisResultAsync(SyntaxTree tree, Nullable`1 filterSpan, ImmutableArray`1 projectAnalyzers, ImmutableArray`1 hostAnalyzers, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Diagnostics.Extensions.GetAnalysisResultAsync(CompilationWithAnalyzersPair compilationWithAnalyzers, DocumentAnalysisScope documentAnalysisScope, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Diagnostics.Extensions.GetAnalysisResultAsync(CompilationWithAnalyzersPair compilationWithAnalyzers, DocumentAnalysisScope documentAnalysisScope, Project project, DiagnosticAnalyzerInfoCache analyzerInfoCache, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.AnalyzeAsync(CompilationWithAnalyzersPair compilationWithAnalyzers, BidirectionalMap`2 analyzerToIdMap, ImmutableArray`1 projectAnalyzers, ImmutableArray`1 hostAnalyzers, SkippedHostAnalyzersInfo skippedAnalyzersInfo, Boolean reportSuppressedDiagnostics, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetDiagnosticsAsync(ImmutableArray`1 projectAnalyzerIds, ImmutableArray`1 hostAnalyzerIds, Boolean reportSuppressedDiagnostics, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetNormalPriorityDiagnosticsAsync(ImmutableArray`1 projectAnalyzerIds, ImmutableArray`1 hostAnalyzerIds, Boolean reportSuppressedDiagnostics, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteDiagnosticAnalyzerService.<>c__DisplayClass3_0.<<CalculateDiagnosticsAsync>b__0>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<>c__DisplayClass7_0`1.<<RunWithSolutionAsync>g__ProcessSolutionAsync|1>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.RunWithSolutionAsync[T](Checksum solutionChecksum, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteDiagnosticAnalyzerService.CalculateDiagnosticsAsync(Checksum solutionChecksum, DiagnosticArguments arguments, CancellationToken cancellationToken)

It does not state anything about SonarQube IDE being the cause. Once I disable it, this does not longer occur. There are not file on a network. I have no custom Java installation, nor configured anything about Java. I have (as mentioned) VS2022 spelling check. Disabling that one did not change a thing (I assume they also hook on to Roslyn)

With verbose logging enabled, I get this:

Initializing the telemetry package...
Finished initializing the telemetry package...
Initializing the daemon package...
[Connection Migration] Start migrating connections from existing bindings
[Connection Migration] End migrating connections from existing bindings
[SLCoreHandler] Creating SLCore instance
[SLCoreHandler] Starting SLCore instance
Settings file does not exist at "C:\Users\c.nobel\AppData\Roaming\SonarLint for Visual Studio\settings.json".
Default settings will be used
Current VS version:
    Visual Studio Enterprise 2022
    17.12.35707.178
    17.12.4
[NodeJSLocator] Checking environment variable SONAR_NODEJS_PATH
[NodeJsLocator] Environment variable is not set
Finished initializing the daemon package.
Initializing the SonarQube for Visual Studio package...
Finishing initializing the SonarQube for Visual Studio package
Initializing the notifications package...
Not connected: not checking for notifications
Finished initializing the notifications package
[SharedBindingConfigProvider] The .sonarlint shared folder was not found
[SLCore] Can't open directory channel. Log directory fsync won't be performed.
Updated analysis readiness: True
Starting job: "re-analyzing 0 document(s)...". Time: 10:37:26
Finished job "re-analyzing 0 document(s)..." started at 10:37:26. Elapsed time: 2ms
Saving notifications settings...
[SLCoreAnalyzer] Analyzing C:\code\dotnet-project-file-analyzers\src\DotNetProjectFile.Analyzers\Rule.cs with id f01a0d25-1356-4e82-ba6c-6767bf73446d
[SLCoreAnalyzer] Found 0 issue(s) in C:\code\dotnet-project-file-analyzers\src\DotNetProjectFile.Analyzers\Rule.cs [id: f01a0d25-1356-4e82-ba6c-6767bf73446d, final: True]
[SLCoreAnalyzer] Finished analyzing C:\code\dotnet-project-file-analyzers\src\DotNetProjectFile.Analyzers\Rule.cs with id f01a0d25-1356-4e82-ba6c-6767bf73446d, analysis time: 3,24s
Saving notifications settings...
Saving notifications settings...
[SLCoreAnalyzer] Analyzing C:\code\dotnet-project-file-analyzers\src\DotNetProjectFile.Analyzers\Rule.Ini.cs with id 6765d352-55d2-4646-aa80-e4c439949fc5
[SLCoreAnalyzer] Found 0 issue(s) in C:\code\dotnet-project-file-analyzers\src\DotNetProjectFile.Analyzers\Rule.Ini.cs [id: 6765d352-55d2-4646-aa80-e4c439949fc5, final: True]
[SLCoreAnalyzer] Finished analyzing C:\code\dotnet-project-file-analyzers\src\DotNetProjectFile.Analyzers\Rule.Ini.cs with id 6765d352-55d2-4646-aa80-e4c439949fc5, analysis time: 0,126s
[ThreadId 1] Saving notifications settings...
[ThreadId 15] [SLCoreAnalyzer] Analyzing C:\code\dotnet-project-file-analyzers\specs\Benchmarks\Program.cs with id 06aaff42-a782-4be2-ae4b-5d7f202547a3
[DEBUG] [ThreadId 303] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] Language of file "file:///C:/code/dotnet-project-file-analyzers/specs/Benchmarks/Program.cs" is detected to be "CS"
[DEBUG] [ThreadId 303] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] Processing file event C:/code/dotnet-project-file-analyzers/specs/Benchmarks/Program.cs with event MODIFIED
[DEBUG] [ThreadId 303] [SLCore] [sonarlint > sonarlint-file-exclusions] Computing file exclusion for uri 'file:///C:/code/dotnet-project-file-analyzers/specs/Benchmarks/Program.cs'
[DEBUG] [ThreadId 302] [SLCore] [sonarlint > dotnet-project-file-analyzers > SonarLint Server RPC request executor] Triggering analysis with configuration: [
  baseDir: C:\code\dotnet-project-file-analyzers\specs\Benchmarks
  extraProperties: {}
  activeRules: [429 cpp, 24 css, 189 c, 46 Web, 315 csharpsquid, 267 typescript, 143 vbnet, 29 secrets, 265 javascript]
  inputFiles: [
    file:///C:/code/dotnet-project-file-analyzers/specs/Benchmarks/Program.cs (UTF-8)
  ]
]

[DEBUG] [ThreadId 299] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] Start analysis
[DEBUG] [ThreadId 300] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] Index files
[DEBUG] [ThreadId 300] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] Language of file "file:///C:/code/dotnet-project-file-analyzers/specs/Benchmarks/Program.cs" is detected to be "CS"
[DEBUG] [ThreadId 300] [SLCore] [sonarlint > dotnet-project-file-analyzers > Report about progress of file indexation] 1 file indexed
[DEBUG] [ThreadId 253] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] Added 267 checks for language='ts', repository='typescript'
[DEBUG] [ThreadId 253] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] Added 265 checks for language='js', repository='javascript'
[DEBUG] [ThreadId 310] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] No registered JsAnalysisConsumer.
[DEBUG] [ThreadId 238] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] Execute Sensor: HTML
[DEBUG] [ThreadId 238] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] 'JavaScript/TypeScript analysis' skipped because there are no related files in the current project
[DEBUG] [ThreadId 238] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] 'JavaScript inside YAML analysis' skipped because there are no related files in the current project
[DEBUG] [ThreadId 238] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] 'JavaScript inside HTML analysis' skipped because there are no related files in the current project
[DEBUG] [ThreadId 238] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] Execute Sensor: CSS Rules
[DEBUG] [ThreadId 238] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
[DEBUG] [ThreadId 238] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] 'CFamily' skipped because there are no related files in the current project
[DEBUG] [ThreadId 238] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] Execute Sensor: TextAndSecretsSensor
[DEBUG] [ThreadId 238] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] Available processors: 20
[DEBUG] [ThreadId 238] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] Using 20 threads for analysis.
[DEBUG] [ThreadId 191] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] Analyzing all except non binary files
[DEBUG] [ThreadId 201] [SLCore] [sonarlint > dotnet-project-file-analyzers > Progress of the text and secrets analysis] 1 source file to be analyzed
[DEBUG] [ThreadId 298] [SLCore] [sonarlint > dotnet-project-file-analyzers > Progress of the text and secrets analysis] 1/1 source file has been analyzed
[DEBUG] [ThreadId 298] [SLCore] [sonarlint > dotnet-project-file-analyzers > sonarlint-analysis-engine] Analysis detected 0 issues and 0 Security Hotspots in 70ms
[ThreadId 298] [SLCoreAnalyzer] Found 0 issue(s) in C:\code\dotnet-project-file-analyzers\specs\Benchmarks\Program.cs [id: 06aaff42-a782-4be2-ae4b-5d7f202547a3, final: True]
[ThreadId 201] [SLCoreAnalyzer] Finished analyzing C:\code\dotnet-project-file-analyzers\specs\Benchmarks\Program.cs with id 06aaff42-a782-4be2-ae4b-5d7f202547a3, analysis time: 0,11s

The most tricky part that I can think of, is that this project contains analyzers on top of Roslyn that analyze additional files (like MS Build project files). But if you can not reproduce it building this project, something else might be at going in. If you need more info, just let me know.

I came across CodeRush 24.1.5 causes an error in the 'Diagnostic analyzer runner' when using Visual Studio 17.12.3 | DevExpress Support and disabled TextEditor->C#->Advanced->Run code analysis in separate process And this seems to solve the Diagnostic analyzer runner for me.

2 Likes

I appreciate your patience. I’ve created a ticket to investigate and resolve the root cause of this issue.

In the meantime, @Ard2025 suggestion seems as a reasonable temporary workaround. Disabling “Run code analysis in a separate process” by navigating to:
Tools > Options > Text Editor > C# > Advanced

Thanks again for your understanding!

Best,
Vasileios

1 Like