ASP 101 - Active Server Pages 101 - Web05
The Place ASP Developers Go!

Please visit our partners


Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash



 Top ASP 101 Stories Top ASP 101 Stories
An Overview of ASP.NET
Connections, Commands, And Procedures
What is ASP?

QUICK TIP:
Configure IIS to Perform Reverse DNS Lookups
Show All Tips >>
ASP 101 RSS Feed ASP 101 Updates


Building a .NET Application Configuration Editor

by Jayram Tallamraju & Sethu Bijumalla

Overview

With Microsoft .NET, configuration for any .NET application is stored in XML files, as compared to the Registry which is used for normal Windows applications. With the "Microsoft .NET Configuration" tool (Administrator Tools -> Microsoft .NET Configuration) that comes with the .NET Framework, it is possible to configure some application properties. But there is no tool available to manage application settings of a .NET application. Each time a .NET application is installed on a new machine, the system administrator has to edit the XML file in notepad or a similar editor and make the required changes. With many .NET applications installed on production machines, it is a real maintenance issue for the Operations team, to find these configuration files and edit them. Another point to remember is that the Operations team might not have the same skills as the developer, in terms of familiarity with XML files or determining the name and location of the appropriate configuration file for a specific application.

Need for application configuration editor and automation

Most big/medium size organizations need a single tool to manage application settings of .NET applications (Both Windows Forms and ASP.NET applications). Also all ASP.NET or Windows Forms based applications should support 'Windows Installer' kind of setup programs and should invoke configuration editor tool, so that person who is installing the application can enter correct configuration information while installing it.

In this article I will focus on the developing configuration editor tool and building windows installer package, to support .NET application maintenance. You can download the sample code and the tools used in this article, with complete source code, from download link. You are free to modify the source and use it as per your needs.

Focus of this article is on, installing and configuring a .NET application in production environment. We will look at ways, how to simplify Operation team's work in installing and maintaining the .NET application. We will look at an ASP.NET application (developed and tested) ready to be deployed to production environment. Solution described in this article is not limited to ASP.NET application and can be used for Windows Form based .NET Application or Web services application.

Case-study

Seth Financials, a big financial organization, has a lot of .NET development. Development includes ASP.NET applications, Web services and Windows Forms based applications.

One of these applications is: Prakash Book Store, an ASP.NET application that uses following application settings from configuration file to name few: Connection String, Log level, Log directory, Admin email ID

Problem

For obvious reasons Operations team does not like to give production configuration details, up-front to development team and they want to enter it, while installing the application. Operations team does not like to fiddle around with XML configuration files and they want simple user interface to change any configuration. Also Operations team is looking for configuration editor tool that can be used for changing configuration of .NET applications at later time also.

Goal/Requirement

Following are the requirements for installing and configuring .NET applications:

  • Requirement 1: Require Configuration Editor tool, to manage different .NET application settings. Installer programs that install any .NET application should invoke the tool. Tool can also be used to manage existing .NET application configuration.

  • Requirement 2: Provide Windows Installer packages for all applications. Invoke above tool after installation of any .NET application so that operations team can change configuration settings.

  • Requirement 3: Tools that are invoked during installation process should run under secure configuration. ASP.NET application installations should install the tool in /bin directory of the application virtual directory, so that it is not accessible to web users.

Approach

Requirement 1: (ConfigEditor)
     Since configuration for any .NET application is stored in XML configuration file it is very easy to build Windows Forms based application and use System.Xml namespace classes to manipulate configuration files. This will address Requirement 1. ConfigEditor should read command line arguments passed, to switch to safe operation mode when invoked from an installer.

Requirement 2:
     Setup project templates that come with Visual studio .NET are very easy to use, for creating windows installer setup packages. There is a lot of flexibility in the setup projects: to add new user input dialogs or change look and feel (bitmap/icon/text) of setup screens or add custom actions. To invoke configuration editor, after the installation is completed, we can use 'Custom Action' feature in the setup project.

Requirement 3: (Custom Actions in setup with arguments)
     In the setup project created, ConfigEditor tool should be added to bin directory. [TARGETDIR] property in the setup project can be used to figure out installation directory. This and additional properties should be passed to ConfigEditor tool, as arguments. This will allow ConfigEditor to recognize that it is invoked from installer and behave differently vs. normal invocation.

Development

Requirement 1: Following are high level details in creating ConfigEditor tool

  1. Select "Windows Forms Application" project in Visual Studio .NET

  2. For select any configuration file use "OpenFileDialog" control

  3. Use System.Xml.XmlDocument to read and write XML configuration files

  4. Use DataSet and DataGrid control for presenting configuration details

Fig. 1: Configuration Editor tool

Requirement 2: Following are high level details in creating Setup package

  1. For ASP.NET or web services applications use "Web Setup project" template and for "Windows Forms Applications" use "Setup project" template in Visual studio .NET

  2. Use View->Editor menu to add the file to file system that are required on target machine (You can simply select Project Output and Select "Content files" or "Primary Output" ).

  3. Use View->Custom actions to invoke any tool that needs to be invoked after running and installing setup. (Make sure to change "InstallerClass = False" for tool in Custom Actions)

Requirement 3:

  1. In Custom Actions -> Install-> select the tool output added and check properties

  2. In properties add "[TARGETDIR] Installer" in the arguments. This will allow use to pass these arguments to the tool when it is invoked form Installer.

Fig. 2: Custom Action properties

Sample Code and source

Attached sample code has all the source code with the tools you need.

You can download a zip file (311 kb) containing the code from here.

About the authors

Jayram Tallamraju and Sethu Bijumalla work for Hemisphere Financials (a Bisys Group) in Boston, MA. You can reach them at tjayram@yahoo.com and mbijumalla@rocketmail.com.


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers