System.IO.FileNotFoundException In ConfigurationBuilder Constructor

-1

I'm trying add the ConfigurationBuilder in an .net core console application I'm getting this exception when running the code below. I checked and in the Directory.GetCurrentDirectory() the file appsettings.json is present.

System.IO.FileNotFoundException
  HResult=0x80070002
  Message=Could not load file or assembly 'Microsoft.Extensions.FileProviders.Physical, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
  Source=Microsoft.Extensions.Configuration.FileExtensions
  StackTrace:
   at Microsoft.Extensions.Configuration.FileConfigurationExtensions.SetBasePath(IConfigurationBuilder builder, String basePath)
   at DashboardService.Program.Main(String[] args)
var builder = new ConfigurationBuilder()
    .SetBasePath(Directory.GetCurrentDirectory())
    .AddJsonFile("appsettings.json");
c#
.net-core
asked on Stack Overflow Jul 9, 2019 by Claudio Ferraro • edited Jul 9, 2019 by gunr2171

1 Answer

1

You will have to add Microsoft.Extensions.FileProviders.Physical to your project. https://www.nuget.org/packages/microsoft.extensions.fileproviders.physical/ Here you can take it. Hope it helps

answered on Stack Overflow Jul 9, 2019 by Yuanyo

User contributions licensed under CC BY-SA 3.0