.NET core 2.1 - System.TypeInitializationException
.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.
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.
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.