Quantcast
Channel: Reading settings from app.config or web.config in .NET - Stack Overflow
Browsing all 29 articles
Browse latest View live
↧

Answer by asmgx for Reading settings from app.config or web.config in .NET

I found the answer in this link https://stackoverflow.com/a/1836938/1492229It's not only necessary to use the namespaceSystem.Configuration. You have also to add the reference to the...

View Article


Image may be NSFW.
Clik here to view.

Answer by Dmitry Grinko for Reading settings from app.config or web.config in...

I'm using Visual Studio for Mac version 17.0.6.As you can see on this screenshot it is not possible to add a reference to System.Configuration.Solution:install NuGet Package -...

View Article

Answer by esamaldin elzain for Reading settings from app.config or web.config...

extra : if you are working on a Class Library project you have to embed the settings.json file.A class library shouldn't really be directly referencing anything inapp.config - the class doesn't have an...

View Article

Answer by Chris Catignani for Reading settings from app.config or web.config...

If your needing/wanting to use the ConfigurationManager class...You may need to load System.Configuration.ConfigurationManager by Microsoft via NuGet Package ManagerTools->NuGet Package...

View Article

Answer by user3534040 for Reading settings from app.config or web.config in .NET

I was able to get the below approach working for .NET Core projects:Steps:Create an appsettings.json (format given below) in your project.Next create a configuration class. The format is provided...

View Article


Answer by martin c for Reading settings from app.config or web.config in .NET

The ConfigurationManager is not what you need to access your own settings.To do this you should use{YourAppName}.Properties.Settings.{settingName}

View Article

Answer by Mohammad D for Reading settings from app.config or web.config in .NET

You can use the below line. In my case it was working: System.Configuration.ConfigurationSettings.AppSettings["yourKeyName"]You must take care that the above line of code is also the old version and...

View Article

Answer by Jitendra Kumar for Reading settings from app.config or web.config...

Step 1: Right-click on references tab to add reference.Step 2: Click on Assemblies tabStep 3: Search for 'System.Configuration'Step 4: Click OK.Then it will work. string value =...

View Article


Answer by Nayanajith for Reading settings from app.config or web.config in .NET

Please check the .NET version you are working on. It should be higher than 4. And you have to add the System.Configuration system library to your application.

View Article


Answer by JMat for Reading settings from app.config or web.config in .NET

Here's an example: App.config<applicationSettings><MyApp.My.MySettings><setting name="Printer" serializeAs="String"><value>1234...

View Article

Answer by Ashwini Jindal for Reading settings from app.config or web.config...

As I found the best approach to access application settings variables in a systematic way by making a wrapper class over System.Configuration as belowpublic class BaseConfiguration{ protected static...

View Article

Answer by Masoud Siahkali for Reading settings from app.config or web.config...

Read From Config:You'll need to add a reference to the configuration:Open "Properties" on your projectGo to "Settings" TabAdd "Name" and "Value"Get Value with using following code:string value =...

View Article

Answer by sherite for Reading settings from app.config or web.config in .NET

Another possible solution:var MyReader = new System.Configuration.AppSettingsReader();string keyvalue = MyReader.GetValue("keyalue",typeof(string)).ToString();

View Article


Answer by rdans for Reading settings from app.config or web.config in .NET

Just for completeness, there's another option available for web projects only: System.Web.Configuration.WebConfigurationManager.AppSettings["MySetting"]The benefit of this is that it doesn't require an...

View Article

Answer by Tony O'Hagan for Reading settings from app.config or web.config in...

I always create an IConfig interface with typesafe properties declared for all configuration values. A Config implementation class then wraps the calls to System.Configuration. All your...

View Article


Answer by bsivel for Reading settings from app.config or web.config in .NET

Update for .NET Framework 4.5 and 4.6; the following will no longer work:string keyvalue = System.Configuration.ConfigurationManager.AppSettings["keyname"];Now access the Setting class via...

View Article

Answer by pomber for Reading settings from app.config or web.config in .NET

Also, you can use Formo:Configuration:<appSettings><add key="RetryAttempts" value="5" /><add key="ApplicationBuildDate" value="11/4/1999 6:23 AM" /></appSettings>Code:dynamic...

View Article


Answer by Ruslan for Reading settings from app.config or web.config in .NET

Try this:string keyvalue = System.Configuration.ConfigurationManager.AppSettings["keyname"];In the web.config file this should be the next structure:<configuration><appSettings><add...

View Article

Answer by Tom for Reading settings from app.config or web.config in .NET

I had the same problem. Just read them this way: System.Configuration.ConfigurationSettings.AppSettings["MySetting"]

View Article

Answer by Victor Naranjo for Reading settings from app.config or web.config...

You might be adding the App.config file to a DLL file. App.Config works only for executable projects, since all the DLL files take the configuration from the configuration file for the EXE file being...

View Article
Browsing all 29 articles
Browse latest View live