为什么Visual Studio告诉我未定义AddJsonFile()方法? [英] Why does Visual Studio tell me that the AddJsonFile() method is not defined?
本文介绍了为什么Visual Studio告诉我未定义AddJsonFile()方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用VS Ultimate 2015 Preview开发ASP.NET 5 WebAPI项目.我正在尝试以这种方式配置应用程序(行号只是指南):
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;
2
3 public IConfiguration Configuration { get; private set; }
4
5 public Startup()
6 {
7 Configuration = new Configuration()
8 .AddJsonFile("config.json")
9 .AddEnvironmentVariables();
10 }
第8行给我一个错误:配置"不包含"AddJsonFile"的定义...
Line 8 gives me an error: 'Configuration' does not contain a definition for 'AddJsonFile'...
怎么了?
推荐答案
您需要包含 Microsoft.Extensions.Configuration.Json
NuGet包,如果您想调用.AddJsonFile()
方法.
请参阅: https://github.com/aspnet/Configuration/tree/dev/src/Microsoft.Framework.ConfigurationModel.Json
For further reading, here's a nice tutorial: ASP.NET vNext Moving Parts: IConfiguration.
这篇关于为什么Visual Studio告诉我未定义AddJsonFile()方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文