To configure the C # foreground screen through a configuration file, Curiosity did the following: a new app. config and app1.config two profiles were created in the project,If you want to read the configuration information from App1.conf
The configuration file is the basis and basis for the program itself. It is essentially an xml file. The operations on the configuration file are as follows. NET 2.0 is very convenient, and provides the System [. web]. to use the NameSpace of the Configuration management function, you need to add. configuration. dll re
. NET: how to obtain the parameter values in the App. config configuration file,. netapp. config
First add System. Configuration reference
Class file must contain using System. Configuration;
Add
1: ///
2: // modify the value Attribute in Add in the appSettings configuration section of the web. config or app. config file.
3: ///
4: ///
5: // Note: after calling this function, the entire Web Application will be restarted, resulting in the loss of all sessions currently.
6: ///
7: //
8: //
9: /
The System. Configuration namespace in. Net provides perfect support for custom Configuration in web. config or app. config. Recently, some projects are still using custom xml files for program configuration, so you can't help wri
The first method: using MS existing ConfigurationManager to read and writeUsing System.configuration;namespace zwj.tems.common{Public abstract class ConfigHelper {private Confighelp ER () {}/// the second method: use native Xml+xpath to read and write (from the network) ==============================================//filename:configmanager//Description: Static method Business class for C #, ASP. NET WinForm WebForm Program profile//app.
C # program configuration file, the most used is appsettings under the Requirements: The program Super Administrator in this way, configured in App. config, you can configure multiple. After successful login, read config to see if I am super admin.(Of course, the demand is very lame, because I'm trying to give an examp
Again, use app. Config to configure multiple custom methods.Let's look at this example: American Family Simpson has a father and a mother and three children, while the Chinese old king has only one child. The structure is as follows: The implementation of each section and ConfigurationElementCollection is described in the previous article. Not posted here.Attention Lao Wang American Family difference is: L
Today, when doing the review, suddenly found that they could not read the configuration file in the database connection string, and checked for half a day did not find out why, and finally to the almighty degree Niang to solve--1. App.Config profile is added to the project do not modify the name , or the application can not find the file, see Clearly, do not change the name ~ ~2. Common uses:We are generally used to do database access, now there are t
system.configuration.configurationmanager.appsettings["User"];" configuration system failed to initialize" error occurredWorkaround:If the configuration file contains a configsections element, the configsections element must be the first child element of the configuration element. ", after placing the appsettings in configsections, it is normal.It's a question of
The application configuration file for ASP. NET is Web. config for the WinForm program is app. config (ExeName.exe.config).Configuration file, for the program itself, is the basis and basis, its essence is an XML file, for the operation of the
Post:
1.
Add to project
App. config
File:
Right-click the project name and select "add"> "Add new project". In the displayed "Add new project" dialog box, select "add application ".ProgramConfiguration file. If the project has no configuration file before, the default file name is"
App.
A DLL is used in the code. And you need to add the log4net configuration in App. Config, and then it goes wrong, prompting "configuration system failed to initialize" Add the following code to Configation Add code in the configation tag of the
Transfer from https://www.cnblogs.com/tonnie/archive/2010/12/17/appconfig.htmlIn general projects, in order to make your code more flexible, more convenient to adjust, reduce unnecessary hard code, we have to add a lot of configuration information in config, generally can choose. NET comes with a configuration file in the form of
Obtain the parameter values in the App. config configuration file.
The following code is used as an example. The specific content is as follows:
First add System. Configuration referenceAdd parameters to the App. config
We often want to write some configuration information in the program, such as the version number, the connection string for the database, and so on. You may know that you can use Properties.settings to do similar work in WinForm applications, but these actually take advantage of the app. config profile.This article explores how to access the
App. config configuration file
We all know.. NET application development can use configuration files to save frequently-used and possibly changed information, such as the log file storage path and database connection information, in this way, even if the parameter information in the production environment is inconsiste
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.