# AD0001 when switching from Debug to Release

**URL:** <https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915>\
**Category:** Visual Studio\
**Tags:** csharp\
**Created:** [June 29, 2023, 3:27pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915 "2023-06-29T15:27:36Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Hitchner](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/david_hitchner/32/23372_2.png) [@David\_Hitchner](https://community.sonarsource.com/u/David_Hitchner)\
**Post date:** [June 29, 2023, 3:27pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/1 "2023-06-29T15:27:36Z")

</div>

Window 10 22H2  
Visual Studio 2019 V16.11.27  
sonarlint 6.16.0.69538  
[VB.net](http://VB.net)

When switching from Debug to Release mode I get 915 “AD0001” warnings. Restarting Visual Studio resolves the issue.

All warnings are similar to this:

```auto
Severity	Code	Description	Project	File	Line	Source
Warning	AD0001	Analyzer 'SonarAnalyzer.Rules.VisualBasic.SymbolicExecutionRunner' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
Exception occurred with following context:
Compilation: PropixFL
SyntaxTree: C:\Development\IPDS and Propix\PropixFL\PropixFL\clsEHs.vb
SyntaxNode: Public Function Count() As Integer ... [MethodBlockSyntax]@[1853..1938) (70,4)-(74,16)

System.NullReferenceException: Object reference not set to an instance of an object.
   at lambda_method(Closure , Object , SyntaxTree , String , CancellationToken , ReportDiagnostic& )
   at StyleCop.Analyzers.Lightup.SyntaxTreeOptionsProviderWrapper.TryGetDiagnosticValue(SyntaxTree tree, String diagnosticId, CancellationToken cancellationToken, ReportDiagnostic& severity)
   at SonarAnalyzer.Rules.SymbolicExecutionRunnerBase.IsEnabled(SonarSyntaxNodeReportingContext context, DiagnosticDescriptor descriptor)
   at SonarAnalyzer.Rules.SymbolicExecutionRunnerBase.<>c __DisplayClass17_0.<AnalyzeRoslyn>b__ 0(KeyValuePair`2 x)
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Linq.Lookup`2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at System.Linq.GroupedEnumerable`3.GetEnumerator()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at SonarAnalyzer.Rules.SymbolicExecutionRunnerBase.AnalyzeRoslyn(SonarAnalysisContext analysisContext, SonarSyntaxNodeReportingContext nodeContext, SyntaxNode body, ISymbol symbol)
   at SonarAnalyzer.Rules.SymbolicExecutionRunnerBase.Analyze(SonarAnalysisContext analysisContext, SonarSyntaxNodeReportingContext nodeContext, SyntaxNode body, ISymbol symbol)
   at SonarAnalyzer.Rules.SymbolicExecutionRunnerBase.Analyze[TNode](SonarAnalysisContext analysisContext, SonarSyntaxNodeReportingContext context, Func`2 getBody)
   at SonarAnalyzer.Rules.VisualBasic.SymbolicExecutionRunner.<>c __DisplayClass4_0.<Initialize>b__ 0(SonarSyntaxNodeReportingContext c)
   at SonarAnalyzer.AnalysisContext.SonarAnalysisContext.Execute[TSonarContext,TRoslynContext](TSonarContext context, Action`1 action, SyntaxTree sourceTree, GeneratedCodeRecognizer generatedCodeRecognizer)
   at SonarAnalyzer.AnalysisContext.SonarAnalysisContext.<>c __DisplayClass23_0`1.<RegisterNodeAction>b__ 0(SyntaxNodeAnalysisContext c)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c __62`1.<ExecuteSyntaxNodeAction>b__ 62_0(ValueTuple`2 data)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info)
-----

Suppress the following diagnostics to disable this analyzer: S2222, S2259, S3655, S3900	PropixFL 1	IntelliSense

```

---

<div class="post-metadata">

**Author:** ![David\_Hitchner](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/david_hitchner/32/23372_2.png) [@David\_Hitchner](https://community.sonarsource.com/u/David_Hitchner)\
**Post date:** [July 18, 2023, 8:26pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/4 "2023-07-18T20:26:02Z")

</div>

This is constant issue with several different applications. Tried removing and re-installing SonarLink but issue still exist. The issue also occurs when switching from Debug to Release. Any thoughts on how to fix this?

---

<div class="post-metadata">

**Author:** ![duncanp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/duncanp/32/293_2.png) [@duncanp](https://community.sonarsource.com/u/duncanp)\
**Post date:** [August 2, 2023, 12:30pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/5 "2023-08-02T12:30:55Z")

</div>

Hi @David_Hitchner does the problem still occur if you reference the Sonar [VB.NET](http://VB.NET) analyzers as a NuGet package? i.e.

1. uninstall SonarLint
2. add a NuGet package reference to [SonarAnalyzer.VisualBasic](https://www.nuget.org/packages/SonarAnalyzer.VisualBasic)?

Thanks.

---

<div class="post-metadata">

**Author:** ![David\_Hitchner](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/david_hitchner/32/23372_2.png) [@David\_Hitchner](https://community.sonarsource.com/u/David_Hitchner)\
**Post date:** [August 3, 2023, 11:54am UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/6 "2023-08-03T11:54:01Z")

</div>

Duncan,  
Yes. The problem still occurs when installed as a NuGet package. In one project it added 403 “AD0001” warnings.

Regards,  
David Hitchner

---

<div class="post-metadata">

**Author:** ![duncanp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/duncanp/32/293_2.png) [@duncanp](https://community.sonarsource.com/u/duncanp)\
**Post date:** [August 3, 2023, 2:34pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/10 "2023-08-03T14:34:45Z")

</div>

Thanks for checking @David_Hitchner. I’ve asked the Languages team who wrote the analysis rule to take a look as the issue doesn’t seem to be related to SonarLint _per se_.

---

<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:** [August 3, 2023, 2:44pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/11 "2023-08-03T14:44:46Z")

</div>

Hello @David_Hitchner,  
Some questions:

- Do you see AD0001s only when turning from Debug to Release mode? Otherwise, there’s no AD0001 in the logs?
- Would it be possible to share this file  
`SyntaxTree: C:\Development\IPDS and Propix\PropixFL\PropixFL\clsEHs.vb`?

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![David\_Hitchner](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/david_hitchner/32/23372_2.png) [@David\_Hitchner](https://community.sonarsource.com/u/David_Hitchner)\
**Post date:** [August 3, 2023, 4:20pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/13 "2023-08-03T16:20:05Z")

</div>

Mary, Sorry, I cannot share the file but I can tell you that “AD0001” errors show for all files in the project as well as in other projects. So far I have not been able to tie it down to any specific file or cause. I can also say that the problem does not appear in Visual Studio 2022 on the same system. I could resolve the issue by using 2022 but because it is 64-bit I need to replace some of the controls in some of the projects before that can happen.

---

<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:** [August 4, 2023, 12:23pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/15 "2023-08-04T12:23:19Z")

</div>

Hello @David_Hitchner.

Do you have maybe different [configuration files for analysis](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files) between debug and release modes (such files are `editorconfig`, global configuration files, or ruleset files)?

---

<div class="post-metadata">

**Author:** ![David\_Hitchner](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/david_hitchner/32/23372_2.png) [@David\_Hitchner](https://community.sonarsource.com/u/David_Hitchner)\
**Post date:** [August 4, 2023, 2:04pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/16 "2023-08-04T14:04:38Z")

</div>

Mary,  
Thanks for your suggestions. I had hoped that this provided a solution because I did have different rulesets for debug and release. Changing the ruleset does trigger the issue. I changed debug and release to use the same ruleset “Microsoft Managed Recommended Rules”. I then exited Visual Studio and re-opened the application. Going from debug to release or release to debug still causes the AD0001 warnings.

---

<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:** [August 7, 2023, 1:57pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/17 "2023-08-07T13:57:32Z")

</div>

Hi @David_Hitchner,  
Is it possible to share with me the ruleset files, so I can try to reproduce the issue?  
Thanks!

---

<div class="post-metadata">

**Author:** ![David\_Hitchner](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/david_hitchner/32/23372_2.png) [@David\_Hitchner](https://community.sonarsource.com/u/David_Hitchner)\
**Post date:** [August 7, 2023, 2:26pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/18 "2023-08-07T14:26:48Z")

</div>

[Ruleset.zip](https://community.sonarsource.com/uploads/short-url/cjdPIqdI6LXoUl0UEwCRh6u4Wqn.zip) (810 Bytes)  
Here is the ruleset. It’s just the standard one supplied with Visual Studio

---

<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:** [August 7, 2023, 2:40pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/19 "2023-08-07T14:40:56Z")

</div>

Just to make sure I understood properly, from your side this is the only extra ruleset that you provide?  
From what I understood from a previous post you mentioned that you use different rulesets for debug and release modes.  
Would it be possible to provide me with these (unless I understood wrong)?

Could you also tell me how you pass the rulesets to your projects?

thanks!

---

<div class="post-metadata">

**Author:** ![David\_Hitchner](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/david_hitchner/32/23372_2.png) [@David\_Hitchner](https://community.sonarsource.com/u/David_Hitchner)\
**Post date:** [August 7, 2023, 3:06pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/20 "2023-08-07T15:06:15Z")

</div>

The ruleset is set in the project properties. I have included an image along with  
my custom ruleset.  
[CustomRuleset.zip](https://community.sonarsource.com/uploads/short-url/sh25gKW24atbbrbF7P731NtaVso.zip) (77.7 KB)

---

<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:** [September 22, 2023, 1:06pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/24 "2023-09-22T13:06:03Z")

</div>

Hello @David_Hitchner ,

I apologize for the late reply.  
Unfortunately, I still cannot reproduce the issue.

I’m working with VS 2019 16.11, a [VB.NET](http://VB.NET) project targeting NET5, providing at project level the rulesets (the ones you provided) and changing them between Release and Debug. Behavior is so far as expected.

Could you please tell me which framework you are targeting in your project?  
Is it possible that you have customized the project build somehow?

Would you be willing to build your project with a more recent MSBuild/VS version (VS22, for example) to see if you have the same issue?

Thank you.

---

<div class="post-metadata">

**Author:** ![David\_Hitchner](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/david_hitchner/32/23372_2.png) [@David\_Hitchner](https://community.sonarsource.com/u/David_Hitchner)\
**Post date:** [September 26, 2023, 12:36pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/25 "2023-09-26T12:36:01Z")

</div>

Mary, The issue does not occur in VS 2022. I am still using VS 2019 for some projects because of 32-bit controls.

---

<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:** [September 26, 2023, 12:44pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/26 "2023-09-26T12:44:25Z")

</div>

Thank you for testing this and for your patience.

Could you please tell me if there’s something different in your project from the setup I described in my previous message?

- which framework do you target?
- do you maybe have altered the build somehow? With targets for example?

One more note: I noticed that you mentioned Visual Studio 2019 V16.11.27.  
Could you try updating to the latest patch [16.11.30](https://learn.microsoft.com/en-us/visualstudio/releases/2019/release-notes#release-notes-icon-visual-studio-2019-version-161130)?

I noticed that I tested with 16.11.29 - so this might do the trick.  
It has happened in the past that there was a bug for a certain MSBuild version and it got resolved in a patch later.

Thank you very much!

---

<div class="post-metadata">

**Author:** ![David\_Hitchner](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/david_hitchner/32/23372_2.png) [@David\_Hitchner](https://community.sonarsource.com/u/David_Hitchner)\
**Post date:** [September 26, 2023, 1:32pm UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/27 "2023-09-26T13:32:23Z")

</div>

Mary, I am running Visual Studio 2019 Version 16.11.30 and targeting .NET Framework 4.6.2. I have another solution that has the same issue and it targets .NET Framework 4.5.2.  
The first solution targeting 4.6.2 does not experience the issue in Visual Studio 2022. I am unable to try the second solution due to the use of 32-bit controls.

---

<div class="post-metadata">

**Author:** ![duncanp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/duncanp/32/293_2.png) [@duncanp](https://community.sonarsource.com/u/duncanp)\
**Post date:** [September 27, 2023, 9:52am UTC](https://community.sonarsource.com/t/ad0001-when-switching-from-debug-to-release/94915/31 "2023-09-27T09:52:42Z")

</div>

@David_Hitchner a couple more questions:

1. are your MSBuild projects SDK-style or in the legacy format (or both)?

2. how is background analysis configured in your IDE? i.e.

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/f/0/f08e78618e638343951ba4cf86e05a91d8193ad9.png)

It might be worth checking the _“Enable file logging for file diagnostics”_ option to see if the log gives any hints about what is happening.

Thanks.
