|
Use Dynamic Properties to Control Resources
Learn how to map properties to a key in the configuration file using dynamic properties.
by Keyur Shah
Posted November 20, 2003
Microsoft has introduced a feature called dynamic properties in its Visual Studio .NET integrated and rapid application development environment. You can use this feature to control the location of resources (such as Web services and databases) that your application uses.
I will explain how to do that. I'll also show you how to configure properties dynamically in Windows applications using Microsoft Visual Studio .NET. I will also configure SQLConnection objects dynamically and store the connection string in the application's config file (app.config). This will also demonstrate how Visual Studio .NET provides inherent support for dynamic properties.
Remember the Old Way
Remember the non-Microsoft .NET days of programming and building Web and Windows applications for the Microsoft platform? There were times when developers hard coded the application configuration details within the application code. Then they compiled and deployed the application to individuals or over the network or the Web servers for end users.
If the configuration settings are not hard coded, it is possible that the better and more-painful approaches would be to store the configuration parameters in Windows system registry or initialization (INI) files.
And as organizations' needs evolve, you have to change configuration parameters of these applications, such as the database to which the application points, user-ID/password setups, and more. To achieve this, you would need to modify your source code containing the hard-coded configuration parameters, recompile and build the executable units, and then redeploy over the servers.
To accomplish all of that, you might need the users to get offline and quit their applications; then you could install the application on the servers or workstations. The bottom line is that you cannot make changes to the applications on the fly.
Enable Change
You can alter production Web applications that require critical changes by using the new dynamic properties feature, which lets developers update XML files without requiring a full recompilation of the application. This capability makes the new feature an indispensable tool. But you also can use dynamic properties to alter Windows applications that require critical changes, such as when your organization develops a new standard for minimum and maximum password length to authenticate users.
This is of great help when you need to customize an application for a particular user or environment. You don't need any code change or compilation; the only thing you have to do is modify the app.config file or use an XML file that contains all of the necessary settings.
In today's rapid-fire business environments, where you have dynamic needs and quick deployment requirements, administrators need a way to modify the value of the property controlling the environment or application while they are outside the project or the running application. This is useful to administrators in application deployment and maintenance phases.
Areas where you need the ability to configure easily and quickly include changes in environment settings, application performance tuning parameters, parameters that control behavior of applications, and the location of resources. A few other areas where you can make use of dynamic properties are configuring database connections, event logs, performance counters, and log files.
Back to top
|