During winform development, some configuration information is inevitably written to the app. in the config file, after the program is generated, the app. config is changed to a file with the program name + config. For example, if
The application configuration file is a standard XML file, and XML tags and attributes are case-sensitive. It can be changed as needed, and developers can use the configuration file to change the settings without having to recompile the application. In the app. config file, the root node is the
1. Problem
2. HowTo
3. Advance
1. ProblemThe problem is simple and clear, that is, how to protect your data in Config, such as database connection strings and other data hidden to users.
2. HowToStep1. create a machine-level RSA Key Container.Aspnet_regiis-pc "XKeys"-expStep2. Add the following Node to your Config File (before the information to be encrypted ):Type = "System.
Today I wrote a Windows exampleProgram, I am depressed enough. I haven't been in touch for too long. Write down a little gadgets for future reference.I will not go into details when reading app. config.It is said that Microsoft does not recommend that we write app. config dynamically, but it is inevitable that some people write
. NET, configurationmanager default reads Web. config or app. config However, everything in these two files, feeling too much, also not good management configuration. So refer to the other people's information, wrote an example of their own, examples of the implementation of the E:\App.config file, the file format is a
Read/write app. config on the InternetCodeWhen writing, you cannot directly use system. configuration. configurationsettings. deleetmetadata. Set (appkey, appvalue), but use app. config as an XML file. I tried this. Why is the Set () method provided?Source codeIf there is a
For more information about app. config operations, seeHttp://developer.51cto.com/art/200908/146303.htm. However, I don't know if you have any questions.
E.g.
After the project is compiled, two configuration files (this project is used as an example), named "ABC. DLL. config, And the other name is "ABC. DLL. vshost ".
Create a new C # project, add the appsettings key in App. Config, and run with the error "configuration system failed to initialize", MSDN writes that if the configuration file contains configsections elements, the configsections element must be The first child element of a configu
After entering the company for more than a year, I have added many parameters to the configuration file, but I never thought about how these parameters are read. Today I have read the parameters and gained a lot. Suppose there is app. config as follows:
Birth = "1954"Name = "AA"Holobby = "reading books">Birth = "1958"Name = "BB"Holobby = "chatting">Birth = "1982"
In winform, you can add a configuration file (such as app. config) to set some parameters for the program, but to specify the location of the configuration file, you do not need to add vs, write two methods to read and modify the specified file.Public class appsettings{Public static string appconfig (){Return System. I
We put the data connection string in the configuration file, but how to read it was previously used in vs2003
Configurationsettings. deleettings ["connectionstring"]. tostring ();
To read the configured connection, but the compiler prompts in vs2005:
Warning "system. configuration. configurationsettings. deleettings" is out of date:
"This method is obsolete, it has been replaced by system.
Today, I added a reference to the database connection string for the app. config file in my own class library, but the return was null, wondering. And then found the answer on the internet originally my app. config file was added to the wrong place, should be added to the startup project, rather than add in the referen
After adding the appsettings node in App. Config, run the following error to the Conn.Open times:The type initializer for "System.Transactions.Diagnostics.DiagnosticTrace" throws an exception. "The problem is resolved after placing the configsections node in the first element under the configuration, for unknown reasons.Before you change your
How to read and write app. config Using System; Using System. Collections. Generic; Using System. text; Using System. configuration; Using System. collections; Namespace Servicesconfiguration { Public Class Configurationdispose { Public Configurationdispose () {} # Region Getconfiguration /// /// Obtain the value in the deletem
small and medium-sized teams who are not so large. So instead of a lightweight configuration center like Spring Cloud Config Server, it's a good fit to run in minutes, and it's rich enough to be relevant to the configuration itself.
So our architecture is like this:
Git: Store specific configuration files and be
Database Connection is often used in programs, and database connection statements are indispensable. This is often the case in the past:
This method is to write the database connection to the program, which will cause trouble for future maintenance. Once you modify the database, you have to re-modify the code, package, and re-deploy the database, which requires a lot of work. now I have learned the object-oriented idea and have access to the configuration
What do we need to do now if we need to define a node in app. Config as follows?So what does each field of this node mean? Section name refers to the name of your custom section, type refers to the class used to receive the corresponding field in this section, and when the program runs, the CLR assigns individual fields to the corresponding properties of the class by reflection. Here, listeners is a collect
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.