qr code generator c# mvc Lesson 2: Creating an Installer in Visual C#

Generating QR Code in Visual C# Lesson 2: Creating an Installer

Lesson 2: Creating an Installer
Denso QR Bar Code Encoder In Visual C#.NET
Using Barcode generation for .NET Control to generate, create QR Code image in Visual Studio .NET applications.
www.OnBarcode.com
Decoding QR In Visual C#.NET
Using Barcode scanner for .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
// Commit the 'MyAssembly' assembly. CustomAssemblyInstaller.Commit(Actions); } catch (ApplicationException e) { Console.WriteLine(e.ToString()); }
Barcode Generation In C#.NET
Using Barcode printer for Visual Studio .NET Control to generate, create bar code image in .NET framework applications.
www.OnBarcode.com
Reading Barcode In C#.NET
Using Barcode decoder for .NET framework Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Rolling Back an Installation
QR Creation In VS .NET
Using Barcode generator for ASP.NET Control to generate, create QR Code 2d barcode image in ASP.NET applications.
www.OnBarcode.com
Paint Denso QR Bar Code In .NET
Using Barcode drawer for Visual Studio .NET Control to generate, create QR Code image in .NET applications.
www.OnBarcode.com
In this example we re installing an application, but we could just as easily uninstall an application by changing the code to call the Uninstall method.
QR Code 2d Barcode Creation In VB.NET
Using Barcode encoder for .NET Control to generate, create QR Code ISO/IEC18004 image in Visual Studio .NET applications.
www.OnBarcode.com
Code 128 Code Set A Generator In Visual C#.NET
Using Barcode drawer for .NET framework Control to generate, create Code 128A image in .NET applications.
www.OnBarcode.com
' VB Sub Main(ByVal args As String()) Dim Actions = New Hashtable() Try Dim CustomAssemblyInstaller As New _ Configuration.Install.AssemblyInstaller("ExampleAssembly.exe", args) CustomAssemblyInstaller.UseNewContext = True CustomAssemblyInstaller.Uninstall(Actions) Catch e As ApplicationException Console.WriteLine(e.ToString) End Try End Sub // C# IDictionary Actions = new Hashtable(); try { AssemblyInstaller CustomAssemblyInstaller = new AssemblyInstaller("CustomAssembly.exe", args); CustomssemblyInstaller.UseNewContext = true; CustomAssemblyInstaller.Uninstall(Actions); } catch (ApplicationException e) { Console.WriteLine(e.ToString()); }
Matrix Barcode Creator In Visual C#.NET
Using Barcode creator for Visual Studio .NET Control to generate, create Matrix 2D Barcode image in .NET applications.
www.OnBarcode.com
Creating Quick Response Code In C#.NET
Using Barcode drawer for VS .NET Control to generate, create Denso QR Bar Code image in .NET framework applications.
www.OnBarcode.com
To uninstall the application, follow these steps: 1. Create a new AssemblyInstaller or ComponentInstaller object. 2. Specify the name of the assembly or application. 3. Call the Uninstall method.
Encode UPC-A In Visual C#
Using Barcode printer for .NET Control to generate, create UPC Symbol image in .NET applications.
www.OnBarcode.com
ANSI/AIM I-2/5 Creation In Visual C#
Using Barcode creator for VS .NET Control to generate, create I-2/5 image in VS .NET applications.
www.OnBarcode.com
9
Painting 2D Barcode In VB.NET
Using Barcode creator for .NET framework Control to generate, create Matrix 2D Barcode image in .NET applications.
www.OnBarcode.com
EAN-13 Supplement 5 Maker In .NET
Using Barcode creation for Reporting Service Control to generate, create EAN13 image in Reporting Service applications.
www.OnBarcode.com
Installing and Configuring Applications
Recognize PDF 417 In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Code 128 Code Set B Scanner In VS .NET
Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
To roll back an installation instead of uninstalling it, a similar methodology is used. Assuming the same facts as in the preceding example, all that is needed is a call to the Rollback method:
Drawing Bar Code In VS .NET
Using Barcode generation for Reporting Service Control to generate, create bar code image in Reporting Service applications.
www.OnBarcode.com
Code 39 Extended Decoder In None
Using Barcode recognizer for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
' VB CustomAssemblyInstaller.Rollback(Actions) // C# CustomAssemblyInstaller.Rollback(Actions);
Code 39 Encoder In Java
Using Barcode generator for Android Control to generate, create Code 3 of 9 image in Android applications.
www.OnBarcode.com
EAN13 Creator In None
Using Barcode generation for Font Control to generate, create UPC - 13 image in Font applications.
www.OnBarcode.com
Lab: Set and Roll Back a Registry Key
In this lab, you create an installation package that creates a Windows registry key and then rolls it back if the program is uninstalled. If you encounter a problem completing an exercise, the completed projects are available on the companion CD in the Code folder.
Exercise: Set and Roll Back a Registry Key
In this exercise, you create an entry in a configuration file to store a connection string to a SQL Server database and then write client code to retrieve it. 1. Open Visual Studio 2005. Select File, New Project, Other Project Types, Setup And Deployment. Select the Setup Project template. You will see the dialog box shown in Figure 9-8:
Figure 9-8
Visual Studio 2005 Setup Project Template
2. Name the application CustomInstallerDemo.
Lesson 2: Creating an Installer
3. In the Solution Explorer, right-click at the top of the tree on CustomInstallerDemo and choose View and then Registry. You are now in the registry editor. 4. Select the User/Machine Hive option, right-click, and select the New Key option. 5. Name the new key CustomKey. 6. Right-click the CustomKey setting that was just created, and select New and then String Value. There are other types of values that you can set, but for this lab, just use a simple string value. Assign it the value DemoValue . 7. Select the CustomKey registry key again, right-click, and select Properties Window. The Properties Window should now be visible. 8. Set the AlwaysCreate property to True. This will ensure that the value is created with every installation. 9. Select the DeleteAtUninstall property, and set it to True. Now, if the program is uninstalled, the registry value will automatically be removed and, in every installation, the value will be automatically set.
Lesson Summary
The Installer class provides a framework for creating custom installation packages for .NET applications. If an installation fails, the Installer will automatically undo any changes it has made. This includes changes to the file system, Start menu, Windows registry, and Desktop. The Commit method of the Installer class signals that the installation was successful and that changes can be persisted. The Rollback method of the Installer class signals that there was an error and that all modifications should be undone. The Uninstall method of the Installer class provides the primary mechanism for completely undoing an application installation after it has been successfully committed. The Registry view of an Installer s designer provides an interface to get, set, and manage Registry settings. Launch conditions can be used to specify preconditions for an application s installation.
9
Installing and Configuring Applications
Lesson Review
You can use the following questions to test your knowledge of the information in Leson 2, Creating an Installer. The questions are also available on the companion CD if you prefer to review them in electronic form.
Copyright © OnBarcode.com . All rights reserved.