'CS8032 warning with Microsoft.CodeAnalysis out of no where

I've had a solution with a large number of projects in that has built fine since we switched to .NET6 then suddenly I am getting for every project this warning in Visual studio, however it does not appear on the MSBuild output and analyzers are set to run on build. Any idea of how to track down why this is happening? The analyzers are included automatically as part of the fact I am using NET SDK projects with .NET6 so there isn't Nuget package references in he way that I know of?

Warning CS8032 An instance of analyzer Microsoft.CodeAnalysis.CSharp.Analyzers.MetaAnalyzers.CSharpReportDiagnosticAnalyzer cannot be created from C:\Users\defaultuser\.nuget\packages\microsoft.codeanalysis.analyzers\3.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll: Could not load type 'Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers.ReportDiagnosticAnalyzer4' from assembly 'Microsoft.CodeAnalysis.Analyzers, Version=3.3.5.2003, Culture=neutral, PublicKeyToken=31bf3856ad364e35'..
System.TypeLoadException: Could not load type Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers.ReportDiagnosticAnalyzer4 from assembly Microsoft.CodeAnalysis.Analyzers, Version=3.3.5.2003, Culture=neutral, PublicKeyToken=31bf3856ad364e35. at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type) at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.Extensions`1.GetAnalyzersForTypeNames(Assembly analyzerAssembly, IEnumerable1 analyzerTypeNames, Boolean& reportedError)



Solution 1:[1]

Upgrading .net 5-6 on latest VS2022 - solution has been evolving for almost 10 years:

One project that is a dependency for many others was still referencing this nuget package: Microsoft.AspNetCore.Mvc v 2.2.0.

Since it's the most recent version, it didn't stand out as needing to be updated, however was no longer being used anywhere. So, it has flown under the radar, until now.

Removing this nuget package from that project eliminated all my CS8032 warnings.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 John