Home > Microsoft .Net Development Tips > Visual Basic and Visual Basic .NET > Visual Basic 2005 and My.Settings
Win Development Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

VISUAL BASIC AND VISUAL BASIC .NET

Visual Basic 2005 and My.Settings


Ed Tittel, Contributor
10.18.2005
Rating: -3.50- (out of 5)


.NET Essentials Channel
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


A new class in the Visual Basic 2005 environment improves the important task of configuring settings.

WinForms applications need data to establish the right runtime settings when they execute. It's smart to keep this data separate from code so that changes in application settings don't force recompilation. Previous incarnations of Visual Basic stored data in various historically popular locations, such as INI files, the Windows Registry, or in config files. And the .NET Framework 1.0 added app.config files to this mix (XML files used to store application settings).

Problems with these methods include one or more of the following:

  • Settings may not be type-safe (or strongly typed at all);
  • Considerable coding effort is required to read or write to such files;
  • Using registry entries means applications must have permissions to read and/or write to the registry, or;
  • User-scope settings are hard to maintain.

This new architecture addresses these problems. It makes it easy to store application- and user-scoped settings on the client machine. Using Visual Studio or some other code editor, you can define a setting for any particular property simply by specifying the name, data type, and default value and by indicating if its scope covers the application or user. Under the hood this data is represented using XML in .config files. Application-scoped settings are read-only because they typically don't need to be rewritten; user-scoped settings may be read or written securely at run-time, even for applications that run under partial trust.

The task of adding a new setting in Visual Basic 2005 is eased significantly. There's no need to open a config file to enter that information. The Settings designer in the project properties form lets you add new settings, and select the associated name, type, and scope information for each one. The app.config file resides in the bin folder, named to match your application name. User scope settings are specific to individual users and are stored in a user.config file in that user's folder hierarchy under the Documents and Settings root-level folder on %SystemDrive% (usually C:\).

Microsoft has more details plus well-illustrated sample code and path examples on their Web site in the Visual Basic Developer Center. It appears under the heading Using My.Settings in Visual Basic 2005. For Visual Basic 2005 developers (or those looking for good reasons to upgrade to that version), this is a must-see item.

Ed Tittel is a full-time writer and trainer whose interests include XML and development topics, along with IT Certification and information security topics. E-mail Ed at etittel@techtarget.com with comments, questions, or suggested topics or tools to review.


Rate this Tip
To rate tips, you must be a member of SearchWinDevelopment.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
Visual Basic and Visual Basic .NET
Compose XML more quickly using Visual Basic 9
Virtualization keeps Legacy Apps alive
VB 9 Anonymous Types help create flexible objects
Visual Studio Team System Add-ins: Conchango Scrum for Team System and Scrum Dashboard
Book Excerpt: Sams Teach Yourself Visual Basic 2008 in 24 Hours -- Complete Starter Kit
Check out CodePlex for a ton of interesting .NET projects
Book excerpt: Murach's VB 2008
Book excerpt: Printing in Visual Basic 2005
Visual Basic 2008 and closures
WinForms development using SQL Server 2005 and Visual Basic 2005

.NET Framework 2.0 and Visual Studio 2005 development
Mono 2.0 moves .NET apps to Linux - includes migration analyzer
Using the Visual Studio 2005 DataSet Designer to build a data access layer
SCM Visual Studio plug-in offers updated interface
Assembly versioning in the .NET Framework 2.0
SearchVB.com's Podcast Page
Visual Studio 2008 Learning Guide: Multi-targeting
On managing a .NET Framework 1.x migration
Case Study: IdeaBlade DevForce object mapping
Book excerpt: Printing in Visual Basic 2005
CodeGear RAD Studio now supports .NET 2.0

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
IronRuby  (SearchWinDevelopment.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Database Programming Solutions - .NET XML, Visual Studio LINQ, ORM .NET
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts