System.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()...
Steps to reproduce the behavior:
No Exception and Configuration File Loaded and Ready
Please share the list of all of your dependency versions. With previews it's very important not to mix versions.
Share the runtime version too. It's probably not the correct version.
I upgraded everything to Preview 7.
Class Library
Microsoft.Extensions.Configuration.EnvironmentVariables Version="3.0.0-preview7.19362.4"
Microsoft.Extensions.Configuration.FileExtensions Version="3.0.0-preview7.19362.4"
Microsoft.Extensions.Configuration.Json Version="3.0.0-preview7.19362.4"
Microsoft.Extensions.DependencyInjection Version="3.0.0-preview7.19362.4"
MSTest.TestFramework Version="2.0.0-beta4"
System.Text.Json Version="4.6.0-preview7.19362.9"
Host MS Test Project (Microsoft.NETCore.App Version="v.3.0.0-preview7-27912-14")
MediatR.Extensions.Microsoft.DependencyInjection Version="7.0.0"
Microsoft.EntityFrameworkCore.InMemory Version="3.0.0-preview7.19362.6"
Microsoft.Extensions.Configuration.EnvironmentVariables Version="3.0.0-preview7.19362.4"
Microsoft.Extensions.Configuration.FileExtensions Version="3.0.0-preview7.19362.4"
Microsoft.Extensions.Logging.Debug Version="3.0.0-preview7.19362.4"
Microsoft.NET.Test.Sdk Version="16.2.0"
MSTest.TestAdapter Version="2.0.0-beta4"
MSTest.TestFramework Version="2.0.0-beta4"
System.Text.Json Version="4.6.0-preview7.19362.9"
And it's still throwing the same exception? If so please share your csproj.
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
The same issue in asp.net core worker project when trying to inject Microsoft.Extensions.Logging.ILogger
You're using preview5 of Hosting, try updating it to preview8
You're using preview5 of Hosting, try updating it to preview8
That's the problem, I used preview5 and all works fine for me, and after I have updated global sdk to preview8, this exception occured
Mixing preview versions is not a supported scenario and in the case of preview 7 and below there were a bunch of breaking changes related to the sdk and JSON.
Most helpful comment
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!