NetCito NetCito - 1 year ago 91
C# Question

Why visual studio tell me that AddJsonFile() method is not define in configuration class?

I'm developing an ASP.NET 5 WebAPI project using VS Ultimate 2015 Preview. I'm trying to configure the app in this way (line numbers are just guides):

1 using Microsoft.Framework.ConfigurationModel;
3 public IConfiguration Configuration { get; private set; }
5 public Startup()
6 {
7 Configuration = new Configuration()
8 .AddJsonFile("config.json")
9 .AddEnvironmentVariables();
10 }

Line 8 give me an error: 'Configuration' does not contain a definition for 'AddJsonFile'...

What is wrong?.

Answer Source

You need to include the Microsoft.Framework.ConfigurationModel.Json if you want to call the .AddJsonFile() method


For further reading, a nice tutorial is at:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download