core icon indicating copy to clipboard operation
core copied to clipboard

.NET core 2.1 - System.TypeInitializationException

Open ssashok10 opened this issue 5 years ago • 2 comments

.NET core 2.1 dependency injection fails

I am working on .NET Core 2.1 and .NET core 3.1 projects on my machine. All projects are working fine with .NET core 3.1. However, .NET Core 2.1 projects are failing with the below error

MissingMethodException: Method not found: '!!0 Microsoft.Extensions.Configuration.ConfigurationBinder.Get(Microsoft.Extensions.Configuration.IConfiguration)'.

The exact line I usually see this error is here, ServiceProvider.GetRequiredService<ILogger>();

I have tried to re-install the .NET Core 2.1 SDK and re-started my machine as well. However, none of the .NET core 2.1 projects are working. I am using the "Microsoft.Extensions.Configuration" version 2.1.1. Any help will be really appreciated.

ssashok10 avatar Dec 09 '20 15:12 ssashok10

It seems like your app is built for a different SDK than what it is running under. Can you verify if that is the case?

If not, a small repro would be helpful. Thanks.

scalablecory avatar Jan 13 '21 23:01 scalablecory

This issue has been automatically closed due to no response from the original author. Please feel free to reopen it if you have more information that can help us investigate the issue further.

no-response avatar Jan 21 '21 00:01 no-response