Settings.settings
generates Settings.Designer.cs
which presumably generates app.config
which then is copied to output directory as Foo.exe.config
. When I distribute the application without the config file, nothing bad seems to happen. So, what is that file for?
相关问题
- Generic Generics in Managed C++
- How to know full paths to DLL's from .csproj f
- Importing NuGet references through a local project
- How to Debug/Register a Permanent WMI Event Which
- Visual Studio 2019 - error MSB8020: The build tool
You can store your configuration in that file.
The .Net framework will automatically load a config file with the exe-name.config.
If you dont use any configurations in your application, then nothing bad will happen...
If you don't have the config file, it uses the default values from the designer. However, the config file allows users/administrators to easily change settings - such as the server you talk to, themes, etc. If you don't have the file, where would you expect those settings to be stored?
You can have per-user settings as well as per-application settings, which are stored in different locations.
The config file is optional, if it does not exist environments such as ASP.NET will fall back to the machine.config file stored in the .NET system directories to get machine wide defaults.
If you actually add code to your app to retrieve settings from the config file (say using the ConfigurationManager class) and it does not exist, you will receive null values.
That is why it is important to check for this siutation and have your application make it's own decision on how/if to continue.
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.