NET Core 3 Preview 7 AddJsonFile Throws MissingMethodException
See original GitHub issueSystem.MissingMethodException HResult=0x80131513 Message=Method not found: ‘System.Text.Json.JsonDocument System.Text.Json.JsonDocument.Parse(System.String, System.Text.Json.JsonReaderOptions)’. Source=Microsoft.Extensions.Configuration.FileExtensions StackTrace: at Microsoft.Extensions.Configuration.FileConfigurationProvider.HandleException(Exception e) at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload) at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load() at Microsoft.Extensions.Configuration.ConfigurationRoot…ctor(IList`1 providers) at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()…
To Reproduce
Steps to reproduce the behavior:
- Using “Microsoft.Extensions.Configuration.Json” Version=“3.0.0-preview7.19362.4”
- Run this code return new ConfigurationBuilder() .SetBasePath(outputPath) .AddJsonFile(“appsettings.json”, true, true) .AddEnvironmentVariables() .Build();
- See exception.
Expected behavior
No Exception and Configuration File Loaded and Ready
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
ConfigureLogging MissingMethodException with 2.0.0 ...
I have 3 projects in my solution; my application and two class libraries. In my class libraries, I have references to a couple...
Read more >ASP.NET Core updates in .NET 8 Preview 7
NET 8 Preview 3 has been updated to use the new C# 12 interceptors compiler feature to support intercepting calls to minimal API's...
Read more >JsonConfigurationExtensions.AddJsonFile Method
Adds a JSON configuration source to builder.
Read more >Looking inside ConfigurationManager in .NET 6
In this post I take a look at the ConfigurationManager class new in .NET 6, explore why it was added, and look at...
Read more >The Future of ASP.NET Core: A Preview of .NET 8 Features
NET Core from .NET 8 Preview 1 and Preview 2. 00:00 Introduction 00:28 Blazor United 01:38 QuickGrid for Blazor 02:56 Performance ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Upon further investigation I realized that the problem was not affecting new projects, only those projects that I had upgraded to Preview 7 from Preview 6. So after beating my head against a wall for a couple of hours today trying to figure out what was going on, I ended up adding a NuGet reference to:
Microsoft.Extensions.Configuration.Json Version=“3.0.0-preview7.19362.4”
In my MS Test Project and it finally worked. It must have been linking against an old version of the assembly that was not showing up in Visual Studio.
Thanks and my sincere apologies for the rushed bug report!
I just ran into the exact same issue when I was trying to read appsettings.json on the recently updated project from older preview version .net core to preview 7 after updating Microsoft.Extensions.Configuration.Json to the latest preview everything worked fine