Deploying with Windows Installer

Team Fly 

Page 259

The following code segment shows how to download the NoTouchDeployment project's EXE file to the client, then extract the application's main form and display it:

 Dim appURL As String = ''http://localhost/NWEmployees/NoTouchDeployment.exe" Dim asm As [Assembly] = [Assembly].LoadFrom(appURL) Dim formType As Type = asm.GetType("NoTouchDeployment.Form1") Dim objForm As Object = Activator.CreateInstance(formType) Dim Form1 As Form = CType(objForm, Form) Form1.Show() 

Notice that the name of the Assembly class is embedded in a pair of brackets, because "assembly" is a reserved word in VB. Strangely, it's not used, but it's a reserved word. The assembly could be an EXE or a DLL. What this short code segment demonstrates is how to start an application from within another application, even though none of the applications lives at the client.

Deploying with Windows Installer

The last option for deploying .NET applications is the most advanced one and involves the generation of a setup project, which users must run on the client machines to install the application. This is also the most professional method of deploying an application, and it's the only option for distributing an application to the general public. Using the Windows Installer we can create shortcuts on the user's desktop, add items to the user's Programs menu, provide custom dialog boxes to customize the installation process, and do a lot more. The setup program is a bootstrap application that opens an MSI package and installs the application and its components on the client computer, according to instructions embedded into the package at design-time.

Creating a simple Windows installer package with Visual Studio .NET is a straightforward process, because the setup project can be part of the same solution as the application for which the package is created. In earlier versions of Visual Studio, setup projects were created with a tool outside Visual Studio. Creating a flexible installation program for a large application may become quite a task, but at the very least you can design and test the setup project in the IDE of Visual Studio.

A Windows installer package is a database with all the data needed to install the application. The information stored in the database remains at the client, and you can run the setup program again to either repair or uninstall the application. Every application installed at the client computer with the Windows installer package is assigned an item in the Add Or Remove Programs snap-in; and this is how users repair or remove applications from their machines. Figure 10.10 shows the Add Or Remove Programs snap-in window after the installation of the NWOrder application. If you click the Support information hyperlink, you will see the SupportInfo window, which is also shown on the same figure. This is the application for which we'll create a Windows installer package to demonstrate the process of deploying a Windows application with a setup project.

To demonstrate the process of deploying an application through a Windows installer package, we'll build a setup project for the NWOrders application. This is one of the sample applications we'll explore in detail later in this book. The NWOrders application lets you create orders for the North wind database. Users can specify the products to be added to the order either by their ID, or by their name. The selected products are added to a ListView control along with their prices, quantities, and discounts, and the order is committed to the database when the Save button is clicked. Figure 10.11 shows the main form of the NWOrders application.

Team Fly 


Visual Basic  .NET Power Tools
Visual Basic .NET Power Tools
ISBN: 0782142427
EAN: 2147483647
Year: 2003
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net