Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Working with Windows Forms Configuration Files in .NET 2.0 and Visual Studio 2005 : Page 4

The newest version of the .NET framework extends strong data typing to configuration files, adds scope for settings, a GUI-based property editor, and drops the read-only restriction for configuration classes.


advertisement
Where Does It All Go?
So, after skimming over the code and running the application you can see the various configuration settings in the ThisConfigEditor.exe.config file. To understand what the configuration framework does, it's worth exploring what happens when you change a User scoped setting (see Figure 6).
 
Figure 6. Changing the User Scoped Setting: The figure shows the process of changing a setting in the ThisConfigEditor sample application.
The changed setting isn't saved into the application's configuration file; instead, the API creates a new directory for the application (if it doesn't already exist) in the user's profile where it adds a file called user.config (see Figure 7).

Separating the data by scope in this manner protects the integrity of the applications configuration file by keeping user-specific data with the user. Again, the .NET framework automatically loads user-specific content without requiring any intervention from developers. Notice that the last subdirectory corresponds to the version number of the application. This ensures that successive versions of the application will maintain their individual integrity and not interfere with each other if a property's datatype changes.

Author's Note: Be mindful of your application's version stamp because any changes (such as auto-incrementing build numbers) will cause the framework to create a new directory with new User-scoped settings—the values won't carry over from previous versions. This is undoubtedly behavior that testers as well as developers should be aware of.
 
Figure 7. The New User Configuration File: The figure shows where the .NET framework saves the user's configuration file for the sample application.

Compact Framework Gets Short Shrift—Again
The Compact Framework implementation on the Pocket PC sometimes seems to be the unwanted stepchild of the .NET world. Its 1.0 implementation made no provision for the System.Configuration namespace or the registry. The beta documentation for 2.0 flags the Compact Framework for each of the class entries in the System.Configuration namespace, as it does for numerous of the classes in all the namespaces in the beta documentation, but the currently available bits do not support this.

One can only hope that this is merely a passing condition during the development phase of the new .NET platform, and that the release version will support the same configuration capabilities as the desktop version.



Guy Rish is a ColdFusion and .NET developer at Vente as well as President at Gestaltech. He is an active developer and author using various languages and technologies. He has contributed work in books on ColdFusion MX, Flash MX, and Dreamweaver MX.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap