Visual Studio 2005 Form configuration file

Source: Internet
Author: User
Tags range

Visual Studio 2005 extends a strong data type into a configuration file, adding a set scope, a GUI-based property editor, and a read-only constraint on a drag-and-drop configuration class.

In some of the new features of. NET 2.0, the patch for the System.Configuration namespace and the visual Studio 2005 configuration Editor are included. Compared to the previous implementations, the new class has elevated the configuration of the desktop and Web applications to a new level of refinement. This article focuses on a simple desktop application that is designed to display and modify the contents of its own configuration file. If you want to run this application, you must download the visual Studio 2005 public beta version.

Some new features

The most important two profile attributes are the separation and editing of strong data entry for type security and the range of user settings information.

Type security (Types Safety)

The old. NET Framework component allows only strings to set information. When we read the setup information directly into the non string variable, we encounter some problems, as follows:

int maxconnections =

applicationsettings.appsettings.key["MaxConnections"];

If the content of the configuration information is not a string and behaves as another data type, such as a Boolean, Integer, or more complex data type, you must write custom code, convert the string value, or create and populate the appropriate object. In contrast, the new API handles all the basic data types and interfaces for implementing a custom serialization program. In addition, the framework component provides built-in handlers for a number of frequently used programming structures, such as data source connections and URLs.

Range (scopes)

The new API uses a concept called scope (scopes) to differentiate between application and user settings. You need to use the application (application) scope to set some of the application's details (such as the connection string) and some of the other driver application values, which generally do not (do not tend to) change. The user scope is the value of the application that can be configured to store users (such as the last window position and the most frequently used document). More importantly, the user scope stores default values for each setting. When users change these defaults using the application, the configuration file stores the updated values in a separate location. This is important because it guarantees the integrity of the application configuration file and saves user-specific data in the user's system configuration. Without any additional development, the configuration framework component can automatically read user-specific settings information in the background.

Thisconfigeditor applications

The sample application Thisconfigeditor (shown in Figure 1) provided in this article is a simple tool for displaying settings information in your own configuration file. Although very simple, it can be a good springboard to meet the needs of most applications.

Figure 1: Sample Configuration Editor: Display setup information for the sample project configuration file

In this project, Visual Studio automatically generates most of the files (shown in Figure 2).

Figure 2:visual Studio generated files for the project, adding ThisConfigEditor.cs files

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.