# Sonar cloud scanner error: System.NullReferenceException

**URL:** <https://community.sonarsource.com/t/sonar-cloud-scanner-error-system-nullreferenceexception/114000>\
**Category:** SonarQube Cloud\
**Tags:** dotnet\
**Created:** [April 22, 2024, 1:47pm UTC](https://community.sonarsource.com/t/sonar-cloud-scanner-error-system-nullreferenceexception/114000 "2024-04-22T13:47:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom\_Wilson](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tom_wilson/32/14134_2.png) [@Tom\_Wilson](https://community.sonarsource.com/u/Tom_Wilson)\
**Post date:** [April 22, 2024, 1:47pm UTC](https://community.sonarsource.com/t/sonar-cloud-scanner-error-system-nullreferenceexception/114000/1 "2024-04-22T13:47:56Z")

</div>

Azure DevOps

- Scanner command used when applicable (private details masked)  
Sonar Cloud Analyzer Azure Devops Step
- Languages of the repository  
dotnet framework
- Only if the SonarCloud project is public, the URL
  - And if you need help with pull request decoration, then the URL to the PR too

- Error observed (wrap logs/code around with triple quotes ``` for proper formatting)

```auto
13:37:05.566 Processing plugin: csharp version 9.23.2.88755
##[debug]Processed: ##vso[task.logissue type=error;]

##[error]Unhandled Exception:
##[debug]Processed: ##vso[task.logissue type=error;]Unhandled Exception:
##[error]System.NullReferenceException: Object reference not set to an instance of an object.
   at SonarScanner.MSBuild.PreProcessor.Roslyn.SubdirIndex.GetOrCreatePath(String key)
   at SonarScanner.MSBuild.PreProcessor.Roslyn.EmbeddedAnalyzerInstaller.GetPluginResourceFiles(Plugin plugin)
   at SonarScanner.MSBuild.PreProcessor.Roslyn.EmbeddedAnalyzerInstaller.InstallAssemblies(IEnumerable`1 plugins)
   at SonarScanner.MSBuild.PreProcessor.Roslyn.RoslynAnalyzerProvider.FetchAnalyzerPlugins(String language, IEnumerable`1 activeRules)
   at SonarScanner.MSBuild.PreProcessor.Roslyn.RoslynAnalyzerProvider.SetupAnalyzer(BuildSettings teamBuildSettings, IAnalysisPropertyProvider sonarProperties, IEnumerable`1 rules, String language)
   at SonarScanner.MSBuild.PreProcessor.PreProcessor.<FetchArgumentsAndRuleSets>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 SonarScanner.MSBuild.PreProcessor.PreProcessor.<DoExecute>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 SonarScanner.MSBuild.PreProcessor.PreProcessor.<Execute>d__6.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 SonarScanner.MSBuild.BootstrapperClass.<PreProcess>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 SonarScanner.MSBuild.BootstrapperClass.<Execute>d__8.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 SonarScanner.MSBuild.Program.<Execute>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 SonarScanner.MSBuild.Program.<Execute>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 SonarScanner.MSBuild.Program.<Main>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---

   at SonarScanner.MSBuild.PreProcessor.Roslyn.EmbeddedAnalyzerInstaller.GetPluginResourceFiles(Plugin plugin)
   at SonarScanner.MSBuild.PreProcessor.Roslyn.EmbeddedAnalyzerInstaller.InstallAssemblies(IEnumerable`1 plugins)
   at SonarScanner.MSBuild.PreProcessor.Roslyn.RoslynAnalyzerProvider.FetchAnalyzerPlugins(String language, IEnumerable`1 activeRules)
   at SonarScanner.MSBuild.PreProcessor.Roslyn.RoslynAnalyzerProvider.SetupAnalyzer(BuildSettings teamBuildSettings, IAnalysisPropertyProvider sonarProperties, IEnumerable`1 rules, String language)
   at SonarScanner.MSBuild.PreProcessor.PreProcessor.<FetchArgumentsAndRuleSets>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 SonarScanner.MSBuild.PreProcessor.PreProcessor.<DoExecute>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 SonarScanner.MSBuild.PreProcessor.PreProcessor.<Execute>d__6.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 SonarScanner.MSBuild.BootstrapperClass.<PreProcess>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 SonarScanner.MSBuild.BootstrapperClass.<Execute>d__8.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 SonarScanner.MSBuild.Program.<Execute>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 SonarScanner.MSBuild.Program.<Execute>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 SonarScanner.MSBuild.Program.<Main>d__2.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 SonarScanner.MSBuild.Program.<Main>(String[] args)
##[debug]Exit code 3762504530 received from tool 'D:\agents\***-dev-develop-pr\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.41.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
##[debug]STDIO streams have closed for tool 'D:\agents\***-dev-develop-pr\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.41.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'

```

- Steps to reproduce  
Error in Prepare analysis on SonarCloud steps of zure devops pipeline
- Potential workaround  
None found, sometimes restarting helps randomly  
**Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!**

---

<div class="post-metadata">

**Author:** ![Mary](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mary/32/59106_2.png) [@Mary](https://community.sonarsource.com/u/Mary)\
**Post date:** [April 29, 2024, 3:03pm UTC](https://community.sonarsource.com/t/sonar-cloud-scanner-error-system-nullreferenceexception/114000/4 "2024-04-29T15:03:03Z")

</div>

Hello @Tom_Wilson,

Apologies for the late reply.

- what are the commands you are running to do the analysis? Can you share the YAML file or relevant steps that is orchestrating the DevOps CI?
- are you using VMs provided by Microsoft or your own images?

Could you please share the verbose logs with us?

Here’s how to enable the verbose logs:

#### Share the Scanner for .NET verbose logs

- Add `/d:"sonar.verbose=true"` to the “SonarQubePrepare” or “SonarCloudPrepare” task’s `extraProperties` argument when using Azure DevOps
  - For example:

```yml
- task: SonarCloudPrepare@1
    inputs:
      SonarCloud: 'sonarcloud'
      organization: 'foo'
      scannerMode: 'MSBuild'
      projectKey: 'foo_sonar-scanning-someconsoleapp'
      projectName: 'sonar-scanning-someconsoleapp'
      extraProperties: |
        sonar.verbose=true

```

Thanks a lot!  
Best Regards  
Mary
