.NET has surely made application development easier. Developers now can write attractive and very functional applications without a major challenge. However, application deployments seem to be getting less attention than any other step in the development cycle. This article will explain the steps for creating configuration files on the target machine during deployment using Custom Actions. During the deployment process, we will collect information from the user (installer), then using this information we will create the appropriate folder and XML file(s) where we store user specific information. When we run the application, we would like to see some of the features of our application disabled and/or enabled based on who the user is. I am sure most developers run into situations where they provide the same copy of software to two different types of vendors. But some features of the software may be disabled or enabled based on a vendor's requirements.
Objectives
To develop an application such that during the installation of the software, it would record installer specific information in an XML file. When the application is operated, it would read the recorded data and customize the interface based on the user.
Implementation
There may be times that developers will come across a situation where they have to downgrade or disable some features of their applications for a different group of users. If your software is written in .NET, the solution may be easy using VS .NET's custom deployment feature. The bulk of this article describes how to assemble files on the target machine during the deployment process using VS .NET's custom action feature. As an example, I have written a simple application to explain how custom deployment enables us to achieve our objective.
The following figures show the interfaces that have been built for demonstration. This application consists of a single form and a few controls. Note that, while this application may seem trivial, the concepts explained here hold true for any kind of application.
Most important, notice that when the application is operated by "Arslan Inc", it displays more features (button appears) than when it is operated by "ABC Financial Corp." as shown in Figure 1 and Figure 2 respectively.
Figure 1: Application operated by a user whose access to information is greater.
Figure 2: Application operated by a user whose access to information is more limited.
Clearly, this application behaves differently based on what company (end user) operates it. In this case, the company name is the only variable. For a large application you may maintain more than one variable or provide a license file.
Setup And Deployment
The software development life cycle is a process that includes all of the activities related to the software that take place up to completion and transition to an operational status. A typical life cycle would include several phases such as envisioning, planning, developing, stabilizing and deploying. At times, these phases may be combined. The envisioning phase is the process where the objective(s) of the solution gets expressed; the planning phase is where the objective(s) gets analyzed and designed; the development phase is where most of the development takes place (this is where you will see most of the code written); the stabilizing phase is where no additional features are introduced, but instead, a lot of testing takes place and bugs are fixed. This phase may also be known as the "Testing Phase", and finally the deployment phase is where the software is installed on the target machine.
It is imperative to think about deployment of projects early in the process cycle, as deployment strategies can influence the design of applications. During deployment most applications require either database setup on a server, virtual directory setup on the IIS or file manipulation on the target machine. Thanks to the .NET Framework, developers can develop applications and write programs for deployment without purchasing a deployment program, which would add to the cost of your project.
Using VS .NET, it is not a massive challenge to alter the target installation directory nor is it a challenge for a Web application to have the installation process create a virtual directory and copy the applications files into it. However, large scale Windows or Web applications require additional steps such as registering shared components in the Global Assembly Cache (GAC), installing databases, adding event logs, gathering information from the user performing the installation to customize configuration parameters or creating a configuration file such that when the program runs, it reads the configuration file and customizes the interface based on the data that is entered during the installation.
Re-examining the main objective: Produce an application that when it is operated, the interface will be customized based on the user. The user information shall be recorded during the installation process and read from an XML file when the application is operated. So without further ado, let's examine how we can utilize VS .NET to achieve our objectives.
In this article, Thiru Thangarathinam demonstrates the different classes and features available through the My namespace. By providing a speed-dial that allows you to more quickly and effectively utilize .NET framework functionalities in your application, the My feature provides huge productivity improvements for .NET developers. [Read This Article][Top]
Thiru Thangarathinam discusses taking advantage of the integation between
the .NET CLR and SQL Server 2005 in order to do things like create triggers
using managed code. [Read This Article][Top]
Developers often use brute force coding to marshal data between the GUI and application objects. In this article, Luther Stanton explains how to use .NET's out-of-the box data-binding functionality to make this job much easier. [Read This Article][Top]
Ambrose Little provides the complete source code for his 'Perfect Service'
and explains how the .NET Service Manager enables features such as drag-n-drop deployment. [Read This Article][Top]
There is broad-reaching debate about remoting, Web services, Enterprise Services, and DCOM. In short, it is a debate about the best technology to use when implementing client/server communication in .NET. Rocky Lhotka shares his thoughts on the issue while offering clear explanations of basic application architecture terminology. [Read This Article][Top]
This article provides and excellent foundation for COM Interop. It reviews COM's background, explains how VB6 interacts with COM, and then shows how to design .NET components to smoothly interact with COM. [Read This Article][Top]
The first article in this two-part series shows how to get Ambrose Little's .NET Service Manager running and then how to add plug-n-play services to it using drag-n-drop or XCOPY. [Read This Article][Top]
Although generics are extremely useful, they also seem to have a certain mystique that cannot be readily explained. This article hopes to remove that aura of mystery by showing just how easy it is to use generics and how useful they can be in many common situations. [Read This Article][Top]
When implementing custom components that require access to restricted resources, implicit impersonation must be used. Jay Nathan shows how to create a class that makes using .NET Impersonation a snap. [Read This Article][Top]
Adnan Masood just returned from DevDays 2004 in Los Angeles. Here he provides some thoughts and insights into the Web application security-focused conference. [Read This Article][Top]
Mailing List Want to receive email when the next article is published? Just Click Here to sign up.