Questions tagged [app-config]

.NET application configuration files contain settings specific to an application.

Application configuration files contain settings specific to an application. This file contains configuration settings that the common language runtime reads (such as assembly binding policy, remoting objects, and so on), and settings that the application can read.

The name and location of the application configuration file depend on the application's host, which can be one of the following:

Executable–hosted application.

The configuration file for an application hosted by the executable host is in the same directory as the application. The name of the configuration file is the name of the application with a .config extension. For example, an application called myApp.exe can be associated with a configuration file called myApp.exe.config.

While developing with Visual Studio the file app.config in a project will be copied to the correctly named configuration file when the project is built.

The file can contain both framework defined and user defined elements (possibly using .NET types to read and write the content).

ASP.NET-hosted application.

ASP.NET configuration files are called web.config. Configuration files in ASP.NET applications inherit the settings of configuration files in the URL path. For example, given the URL http://www.example.com/aaa/bbb, where http://www.example.com/aaa is the Web application, the configuration file associated with the application is located at www.example.com/aaa. ASP.NET pages that are in the subdirectory bbb use both the settings that are in the configuration file at the application level and the settings in the configuration file that is in bbb.

For more information about ASP.NET configuration files, see ASP.NET Configuration

Internet Explorer-hosted application. If an application hosted in Internet Explorer has a configuration file, the location of this file is specified in a tag with the following syntax:

<link rel="ConfigurationFileName" href="location">

In this tag, location is a URL to the configuration file. This sets the application base. The configuration file must be located on the same Web site as the application.

3121 questions
56
votes
2 answers

Escape & in App.config

I have the following piece of config in my App.config file: The above connection string is rejected by Visual Studio…
developer747
  • 15,419
  • 26
  • 93
  • 147
54
votes
7 answers

Can a class library have an App.config file?

Here is what my solution is looking like at the moment: In the Tutomentor.Branding project, I'd like to save branding information in the App.config file, like names, colors, etc. In the Tutomentor.Data project, the App.config was created when I…
delete
54
votes
6 answers

Actually read AppSettings in ConfigureServices phase in ASP.NET Core

I need to setup a few dependencies (services) in the ConfigureServices method in an ASP.NET Core 1.0 web application. The issue is that based on the new JSON configuration I need to setup a service or another. I can't seem to actually read the…
Andrei Rînea
  • 20,288
  • 17
  • 117
  • 166
54
votes
2 answers

Why is a "bindingRedirect" added to the app.config file after adding the Microsoft.Bcl.Async package?

I was wondering why nuget added the following code to my applications app.config file, after installing the Microsoft.Bcl.Async:
GameScripting
  • 16,092
  • 13
  • 59
  • 98
53
votes
3 answers

Typesafe config: Load additional config from path external to packaged scala application

My scala application will be packaged into a jar. When I run my app, it needs to read an additional config file stored externally to my app jar. I am looking for functionality similar to the Typesafe Config library but other solutions are welcome…
RAbraham
  • 5,956
  • 8
  • 45
  • 80
52
votes
7 answers

Encrypt connection string in app.config

I am having trouble encrypting a connection string in app.config. I have code that will protect the connectionStrings section of app.config, but the password is still displayed in plain text. I need to encrypt the connection string in so it is not…
Blade3
  • 4,140
  • 13
  • 41
  • 57
50
votes
11 answers

How to programmatically modify WCF app.config endpoint address setting?

I'd like to programmatically modify my app.config file to set which service file endpoint should be used. What is the best way to do this at runtime? For reference:
alchemical
  • 13,559
  • 23
  • 83
  • 110
49
votes
2 answers

Differences between App.Config and Web.Config?

when building a desktop app in wpf can you read documentation of problems and safely subsititute 'app.config' when people's answer's refer to 'web.config'? if so are there any glaring GOTCHAS you have to look out for? tnx
Jack McG
  • 595
  • 2
  • 6
  • 5
47
votes
3 answers

Reading keyvalue pairs into dictionary from app.config configSection

I currently have an app.config in an application of mine set up like so:
DanteTheEgregore
  • 1,530
  • 5
  • 23
  • 44
47
votes
9 answers

App.Config change value

This is my App.Config With this code I make the change lang = "Russian"; private void…
a1204773
  • 6,923
  • 20
  • 64
  • 94
42
votes
2 answers

sub appsettings in the appsetting node c#

I am using the app.config file that is created with a console application and I can read the val1 of the key1 using the ConfigurationSettings.AppSettings["key1"].ToString()
Tony Germanos
  • 477
  • 1
  • 5
  • 11
41
votes
1 answer

Use XML includes or config references in app.config to include other config files' settings

I have standard logging, NHibernate, etc. configuration blocks in my app.config and I'd like to extract them into a common XML file that can be included as a reference by all of my applications' app.config files. Is this possible?
TheSoftwareJedi
  • 34,421
  • 21
  • 109
  • 151
39
votes
3 answers

How do I set CultureInfo.CurrentCulture from an App.Config file?

I need to set my application's culture through an App.Config file, so that "pt-BR" is used automatically for parsing dates without the need to manually inform the culture for each operation. As far as I know, there's a globalization section that can…
Andre Pena
  • 56,650
  • 48
  • 196
  • 243
39
votes
3 answers

Enabling Intellisense for Custom Sections in .config Files

When editing .NET config files (app.config, web.config, etc) in Visual Studio, I get Visual Studio's intellisense to guide me when choosing my application's settings. If I add a custom configuration section, how can I enable intellisense for my…
Kevin Babcock
  • 10,187
  • 19
  • 69
  • 89
39
votes
3 answers

How to write an URI string in App.Config

I am making a Windows Service. The Service has to donwload something every night, and therefor I want to place the URI in the App.Config in case I later need to change it. I want to write an URI in my App.Config. What makes it invalid and how…
radbyx
  • 9,352
  • 21
  • 84
  • 127