我收到以下警告'System.Configuration.ConfigurationSettings.AppSettings'isobsolete:'"Thismethodisobsolete,ithasbeenreplacedbySystem.Configuration!System.Configuration.ConfigurationManager.AppSettings"'如何解决? 最佳答案 添加对程序集System.Configuration的引用。然后在顶部(假设使用C#)使用System.Configuration(
这个问题听起来可能太琐碎了,我按照文章中的建议做了同样的事情,但它没有按预期工作。希望有人能指出我正确的方向。我想保存每个AppSettings的用户设置。一旦Winform关闭,我就会触发这个:conf.Configurationconfig=ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);if(ConfigurationManager.AppSettings["IntegrateWithPerforce"]!=null)ConfigurationManager.AppSettings["I
我的XML看起来像这样,文件名为web.config....在我读到的代码中是这样的Stringpath=ConfigurationSettings.AppSettings["configFile"];我得到一个空值。不会抛出异常。这是正确的做法吗? 最佳答案 因为你正在访问一个web.config你应该使用usingSystem.Web.Configuration;WebConfigurationManager.AppSettings["configFile"] 关于c#-如何读取we
我有一个方法可以像这样从我的配置文件中读取设置:varvalue=ConfigurationManager.AppSettings[key];仅针对.NETStandard2.0时编译良好。现在我需要多个目标,所以我更新了我的项目文件:netcoreapp2.0;net461;netstandard2.0但是现在,netcoreapp2.0的编译失败并出现以下错误消息:ErrorCS0103Thename'ConfigurationManager'doesnotexistinthecurrentcontext(netcoreapp2.0)另外,我创建了一个新的.NETCore2.0控制
我无法访问配置文件中的值。Configurationconfig=ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);varclientsFilePath=config.AppSettings.Settings["ClientsFilePath"].Value;//thesecondlinegetsaNullReferenceException.config文件:你有什么建议我该怎么办? 最佳答案 这对我有用:stringvalue=Syste
我已经在文件appsettings/Config.json中设置了我的AppSettings数据,如下所示:{"AppSettings":{"token":"1234"}}我在网上搜索了如何从.json文件中读取AppSettings值,但没有得到任何有用的信息。我试过:varconfiguration=newConfiguration();varappSettings=configuration.Get("AppSettings");//nullvartoken=configuration.Get("token");//null我知道使用ASP.NET4.0可以做到这一点:Syste