question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fix-analyzers throwing error.

See original GitHub issue

When running the latest development build. --version 5.0.136601

It runs through until it hits, Running Formatters then throws an error. Fix-style is working fine.

Running formatters. Unhandled exception: System.IO.FileLoadException: Assembly with same name is already loaded at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly) at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath) at System.Reflection.Assembly.LoadFrom(String assemblyFile) at Microsoft.CodeAnalysis.Tools.Analyzers.AnalyzerReferenceInformationProvider.<>c.<GetAnalyzersAndFixers>b__0_1(String path) in /_/src/Analyzers/AnalyzerReferenceInformationProvider.cs:line 28

The full set of analyzers returned are:

[0]: ".nuget\\packages\\microsoft.entityframeworkcore.analyzers\\3.1.4\\analyzers\\dotnet\\cs\\Microsoft.EntityFrameworkCore.Analyzers.dll"
    [1]: "packages\\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.6\\analyzers\\dotnet\\cs\\Microsoft.CodeAnalysis.VersionCheckAnalyzer.resources.dll"
    [2]: "packages\\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.6\\analyzers\\dotnet\\Microsoft.CodeAnalysis.VersionCheckAnalyzer.dll"
    [3]: "packages\\Microsoft.CodeQuality.Analyzers.2.9.6\\analyzers\\dotnet\\cs\\Humanizer.dll"
    [4]: "packages\\Microsoft.CodeQuality.Analyzers.2.9.6\\analyzers\\dotnet\\cs\\Microsoft.CodeQuality.Analyzers.dll"
    [5]: "packages\\Microsoft.CodeQuality.Analyzers.2.9.6\\analyzers\\dotnet\\cs\\Microsoft.CodeQuality.CSharp.Analyzers.dll"
    [6]: "packages\\Microsoft.NetCore.Analyzers.2.9.6\\analyzers\\dotnet\\cs\\Microsoft.NetCore.Analyzers.dll"
    [7]: "packages\\Microsoft.NetCore.Analyzers.2.9.6\\analyzers\\dotnet\\cs\\Microsoft.NetCore.CSharp.Analyzers.dll"
    [8]: "packages\\Microsoft.NetFramework.Analyzers.2.9.6\\analyzers\\dotnet\\cs\\Microsoft.NetFramework.Analyzers.dll"
    [9]: "packages\\Microsoft.NetFramework.Analyzers.2.9.6\\analyzers\\dotnet\\cs\\Microsoft.NetFramework.CSharp.Analyzers.dll"
    [10]: "C:\\Program Files\\dotnet\\sdk\\3.1.301\\Sdks\\Microsoft.NET.Sdk.Web\\analyzers\\cs\\Microsoft.AspNetCore.Analyzers.dll"
    [11]: "C:\\Program Files\\dotnet\\sdk\\3.1.301\\Sdks\\Microsoft.NET.Sdk.Web\\analyzers\\cs\\Microsoft.AspNetCore.Mvc.Analyzers.dll"
    [12]: "C:\\Program Files\\dotnet\\sdk\\3.1.301\\Sdks\\Microsoft.NET.Sdk.Web\\analyzers\\cs\\Microsoft.AspNetCore.Components.Analyzers.dll"
    [13]: ".nuget\\packages\\microsoft.codeanalysis.analyzers\\2.9.4\\analyzers\\dotnet\\cs\\Microsoft.CodeAnalysis.Analyzers.dll"
    [14]: ".nuget\\packages\\microsoft.codeanalysis.analyzers\\2.9.4\\analyzers\\dotnet\\cs\\Microsoft.CodeAnalysis.CSharp.Analyzers.dll"
    [15]: ".nuget\\packages\\microsoft.entityframeworkcore.analyzers\\3.1.4\\analyzers\\dotnet\\cs\\Microsoft.EntityFrameworkCore.Analyzers.dll"
    [16]: ".nuget\\packages\\microsoft.codeanalysis.analyzers\\2.9.4\\analyzers\\dotnet\\cs\\Microsoft.CodeAnalysis.Analyzers.dll"
    [17]: ".nuget\\packages\\microsoft.codeanalysis.analyzers\\2.9.4\\analyzers\\dotnet\\cs\\Microsoft.CodeAnalysis.CSharp.Analyzers.dll"
    [18]: ".nuget\\packages\\microsoft.entityframeworkcore.analyzers\\3.1.4\\analyzers\\dotnet\\cs\\Microsoft.EntityFrameworkCore.Analyzers.dll"
    [19]: ".nuget\\packages\\xunit.analyzers\\0.10.0\\analyzers\\dotnet\\cs\\xunit.analyzers.dll"
    [20]: ".nuget\\packages\\microsoft.entityframeworkcore.analyzers\\3.1.4\\analyzers\\dotnet\\cs\\Microsoft.EntityFrameworkCore.Analyzers.dll"
    [21]: ".nuget\\packages\\microsoft.entityframeworkcore.analyzers\\3.1.4\\analyzers\\dotnet\\cs\\Microsoft.EntityFrameworkCore.Analyzers.dll"
    [22]: ".nuget\\packages\\xunit.analyzers\\0.10.0\\analyzers\\dotnet\\cs\\xunit.analyzers.dll"
    [23]: "C:\\Program Files\\dotnet\\sdk\\3.1.301\\Sdks\\Microsoft.NET.Sdk.Web\\analyzers\\cs\\Microsoft.AspNetCore.Analyzers.dll"
    [24]: "C:\\Program Files\\dotnet\\sdk\\3.1.301\\Sdks\\Microsoft.NET.Sdk.Web\\analyzers\\cs\\Microsoft.AspNetCore.Mvc.Analyzers.dll"
    [25]: "C:\\Program Files\\dotnet\\sdk\\3.1.301\\Sdks\\Microsoft.NET.Sdk.Web\\analyzers\\cs\\Microsoft.AspNetCore.Components.Analyzers.dll"
    [26]: ".nuget\\packages\\microsoft.aspnetcore.components.analyzers\\3.1.3\\analyzers\\dotnet\\cs\\Microsoft.AspNetCore.Components.Analyzers.dll"
    [27]: ".nuget\\packages\\microsoft.codeanalysis.analyzers\\2.9.4\\analyzers\\dotnet\\cs\\Microsoft.CodeAnalysis.Analyzers.dll"
    [28]: ".nuget\\packages\\microsoft.codeanalysis.analyzers\\2.9.4\\analyzers\\dotnet\\cs\\Microsoft.CodeAnalysis.CSharp.Analyzers.dll"
    [29]: ".nuget\\packages\\microsoft.entityframeworkcore.analyzers\\3.1.4\\analyzers\\dotnet\\cs\\Microsoft.EntityFrameworkCore.Analyzers.dll"
    [30]: ".nuget\\packages\\xunit.analyzers\\0.10.0\\analyzers\\dotnet\\cs\\xunit.analyzers.dll"
    [31]: ".nuget\\packages\\xunit.analyzers\\0.10.0\\analyzers\\dotnet\\cs\\xunit.analyzers.dll"
    [32]: ".nuget\\packages\\microsoft.aspnetcore.components.analyzers\\3.1.3\\analyzers\\dotnet\\cs\\Microsoft.AspNetCore.Components.Analyzers.dll"
    [33]: ".nuget\\packages\\microsoft.codeanalysis.analyzers\\2.9.4\\analyzers\\dotnet\\cs\\Microsoft.CodeAnalysis.Analyzers.dll"
    [34]: ".nuget\\packages\\microsoft.codeanalysis.analyzers\\2.9.4\\analyzers\\dotnet\\cs\\Microsoft.CodeAnalysis.CSharp.Analyzers.dll"
    [35]: ".nuget\\packages\\microsoft.entityframeworkcore.analyzers\\3.1.4\\analyzers\\dotnet\\cs\\Microsoft.EntityFrameworkCore.Analyzers.dll"
    [36]: ".nuget\\packages\\xunit.analyzers\\0.10.0\\analyzers\\dotnet\\cs\\xunit.analyzers.dll"
    [37]: ".nuget\\packages\\microsoft.entityframeworkcore.analyzers\\3.1.4\\analyzers\\dotnet\\cs\\Microsoft.EntityFrameworkCore.Analyzers.dll"
    [38]: ".nuget\\packages\\xunit.analyzers\\0.10.0\\analyzers\\dotnet\\cs\\xunit.analyzers.dll"
    [39]: ".nuget\\packages\\microsoft.entityframeworkcore.analyzers\\3.1.5\\analyzers\\dotnet\\cs\\Microsoft.EntityFrameworkCore.Analyzers.dll"
    [40]: ".nuget\\packages\\xunit.analyzers\\0.10.0\\analyzers\\dotnet\\cs\\xunit.analyzers.dll"
    [41]: ".nuget\\packages\\microsoft.aspnetcore.components.analyzers\\3.1.3\\analyzers\\dotnet\\cs\\Microsoft.AspNetCore.Components.Analyzers.dll"

And the distinct list:

    [0]: ".nuget\\packages\\microsoft.entityframeworkcore.analyzers\\3.1.4\\analyzers\\dotnet\\cs\\Microsoft.EntityFrameworkCore.Analyzers.dll"
    [1]: packages\\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.6\\analyzers\\dotnet\\cs\\Microsoft.CodeAnalysis.VersionCheckAnalyzer.resources.dll"
    [2]: packages\\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.6\\analyzers\\dotnet\\Microsoft.CodeAnalysis.VersionCheckAnalyzer.dll"
    [3]: packages\\Microsoft.CodeQuality.Analyzers.2.9.6\\analyzers\\dotnet\\cs\\Humanizer.dll"
    [4]: packages\\Microsoft.CodeQuality.Analyzers.2.9.6\\analyzers\\dotnet\\cs\\Microsoft.CodeQuality.Analyzers.dll"
    [5]: packages\\Microsoft.CodeQuality.Analyzers.2.9.6\\analyzers\\dotnet\\cs\\Microsoft.CodeQuality.CSharp.Analyzers.dll"
    [6]: packages\\Microsoft.NetCore.Analyzers.2.9.6\\analyzers\\dotnet\\cs\\Microsoft.NetCore.Analyzers.dll"
    [7]: packages\\Microsoft.NetCore.Analyzers.2.9.6\\analyzers\\dotnet\\cs\\Microsoft.NetCore.CSharp.Analyzers.dll"
    [8]: packages\\Microsoft.NetFramework.Analyzers.2.9.6\\analyzers\\dotnet\\cs\\Microsoft.NetFramework.Analyzers.dll"
    [9]: packages\\Microsoft.NetFramework.Analyzers.2.9.6\\analyzers\\dotnet\\cs\\Microsoft.NetFramework.CSharp.Analyzers.dll"
    [10]: "C:\\Program Files\\dotnet\\sdk\\3.1.301\\Sdks\\Microsoft.NET.Sdk.Web\\analyzers\\cs\\Microsoft.AspNetCore.Analyzers.dll"
    [11]: "C:\\Program Files\\dotnet\\sdk\\3.1.301\\Sdks\\Microsoft.NET.Sdk.Web\\analyzers\\cs\\Microsoft.AspNetCore.Mvc.Analyzers.dll"
    [12]: "C:\\Program Files\\dotnet\\sdk\\3.1.301\\Sdks\\Microsoft.NET.Sdk.Web\\analyzers\\cs\\Microsoft.AspNetCore.Components.Analyzers.dll"
    [13]: ".nuget\\packages\\microsoft.codeanalysis.analyzers\\2.9.4\\analyzers\\dotnet\\cs\\Microsoft.CodeAnalysis.Analyzers.dll"
    [14]: ".nuget\\packages\\microsoft.codeanalysis.analyzers\\2.9.4\\analyzers\\dotnet\\cs\\Microsoft.CodeAnalysis.CSharp.Analyzers.dll"
    [15]: ".nuget\\packages\\xunit.analyzers\\0.10.0\\analyzers\\dotnet\\cs\\xunit.analyzers.dll"
    [16]: ".nuget\\packages\\microsoft.aspnetcore.components.analyzers\\3.1.3\\analyzers\\dotnet\\cs\\Microsoft.AspNetCore.Components.Analyzers.dll"
    [17]: ".nuget\\packages\\microsoft.entityframeworkcore.analyzers\\3.1.5\\analyzers\\dotnet\\cs\\Microsoft.EntityFrameworkCore.Analyzers.dll"

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
jmarolfcommented, Jul 24, 2020

One per project is likely the correct design moving forward

1reaction
sharwellcommented, Jul 24, 2020

Since we can’t load analyzers side-by-side on .NET Core (and we know dotnet-format is running on .NET Core, we should be using an assembly load context for the analyzers which allows them to be loaded even when there is more than one analyzer with the same name in the solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AD0001 Analyzer 'Microsoft.CodeAnalysis.CSharp. ...
CSharp.Analyzers.FixAnalyzers.CSharpFixerWithFixAllAnalyzer' threw an exception of type 'System.TypeInitializationException #3198.
Read more >
VS 2019 - seeing many warnings AD0001 from Microsoft. ...
AD0001 Analyzer 'Microsoft.CodeAnalysis.CSharp.Analyzers.FixAnalyzers.CSharpFixerWithFixAllAnalyzer' threw an exception of type 'System.
Read more >
unable to install via nuget - Using Umbraco And Getting ...
FixAnalyzers.FixerWithFixAllAnalyzer`1' threw an exception.'. ... Parser Error Message: Could not load type 'Umbraco.Web.
Read more >
https://chat.stackexchange.com/messages/14929/44834141
Failed with 428 errors. Interesting a warning message says Severity Code ... FixAnalyzers.CSharpFixerWithFixAllAnalyzer' threw an exception of type 'System.
Read more >
Umbraco 7 Build Error - New Installation From NuGet
CSharpFixerWithFixAllAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'Microsoft ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found