Вы находитесь на странице: 1из 21

Presented by:

Developing and Implementing WindowsBased Applications with Visual C# .NET and Visual Studio .NET
Kalani Kirk Hausman Amit Kalani Priti Kalani

Developing and Implementing Windows-Based Applications with Visual C# .NET and Visual Studio .NET Exam Cram 2 (Exam 70-316)
Copyright 2003 by Que Certification All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, *without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein. International Standard Book Number: 0-7897-2902-4 Library of Congress Catalog Card Number: 2003100978 Printed in the United States of America First Printing: May 2003 05 04 4 3 2

Publisher
Paul Boger

Executive Editor
Jeff Riley

Development Editor
Ginny Bess Munroe

Managing Editor
Charlotte Clapp

Project Editor
Tricia Liebig

Indexer
Mandie Frank

Trademarks
All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Que Certification cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Windows is a registered trademark of Microsoft Corporation. Visual C# and Visual Studio are registered trademarks of Microsoft Corporation

Proofreader
Juli Cook

Team Coordinator
Pamalee Nelson

Technical Editors
Steve Heckler Greg Guntle

Warning and Disclaimer


Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an as is basis. The authors and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book or from the use of the CD or programs accompanying it.

Multimedia Developer
Dan Scherf

Page Layout
Michelle Mitchell

Graphics
Tammy Graham

Reproduced from the book MCAD Developing and Implementing Windows-based Applications with Microsoft Visual C# .NET and Microsoft Visual Studio .NET Exam Cram 2 (Exam Cram 70-316). Copyright 2003, Que. Reproduced by permission of Pearson Education, Inc., 800 East 96th Street, Indianapolis, IN 46240. Written permission from Pearson Education, Inc. is required for all other uses.

13
Deploying a Windows Application
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Terms youll need to understand:


XCOPY Cabinet (.cab) files Merge Module Bootstrapper Custom actions Delay signing Authenticode signature URL remoting Logo programs

Techniques youll need to master:


Experiment with using setup projects and merge module projects to deploy Windows-based applications. Understand when you should choose to create a setup project versus a merge module project. Work with the different editors that are available in setup and merge module projects, and thoroughly understand the purpose of each of these editors. Understand how digital signing is used when creating a strong name for an assembly. Experiment with placing assemblies in the Global Assembly Cache.

288 Chapter 13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

After creating and testing your application, you must provide the completed product to its users. This chapter focuses on the process involved in deploying simple and complex applications using XCOPY, the Windows Installer, and zero-touch Web-based deployment methods. We also briefly examine the use of shared assemblies and the application requirements for certification in the Microsoft Windows Logo program.

Deployment Tools
The Visual Studio .NET development platform has the new Setup and Deployment projects category, which includes useful templates for creating installation packages for many types of applications. These packages are based on the Microsoft Windows Installer technology, which handles many of the setup and configuration details automatically. When you decide to deploy a package, its complexity and installation requirements will determine the best tool for deployment. You might be able to deploy a simple .NET application that uses managed code and private assemblies by using nothing more than the XCOPY utility to duplicate the applications files to the desired destination. This type of installation is insufficient when an application involves key management, user registration, feature selection, relative path selection, the Global Assembly Cache (GAC) manipulation, or the creation of shortcuts, databases, or a branded interface. To support more complex installation requirements, you can use the Windows Installer technology. Installer packages (.msi) can create shortcuts, set Registry entries, add Start menu items, execute custom scripts, and allow by-feature and on-demand installations. In addition, the Windows Installer provides the capability to roll back an installation process, uninstall an application, and repair a component or an application.
Visual Studio .NET ships with version 2.0 of the Installer, which is compatible with Windows NT 4 (Service Pack 6), Windows ME, Windows 2000, and Windows XP, Windows 2003 Server. Microsoft provides a downloadable earlier version that can be used on Windows NT 4.0, Windows 95, and Windows 98.

Deploying Your Application


Visual Studio .NET includes templates and setup wizards for several forms of application deployment, including these:

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deploying . . . . . .a .Windows . . . . . Application . . . . . . Cab ProjectsUsed to package ActiveX components into redistributable

289

cabinet (.cab) files for Internet download


Merge Module ProjectsUsed to create redistributable packages, includ-

ing shared components and assemblies


Setup ProjectsUsed to create installation packages for Windows appli-

cations to be installed on client computer systems


Web Setup ProjectsUsed to create installation packages for Web applica-

tions to be installed on a Web server Visual Studio .NET also has a Setup Wizard that helps you interactively create these deployment projects. This chapter mainly discusses the Setup Project, which is used to deploy Windows-based applications.

Setup Projects
After you have created an application and compiled it using the Release option, you can wrap your application into a setup project using Visual Studio .NET. You might want to include additional files, such as a license agreement or a ReadMe file, to provide installation instructions or information on the purpose and use of the application. When all of these files have been created, you can create a new Setup project by following these steps:
1. Open a Visual Studio .NET and open the Windows application for

which you want to create a setup project.


2. Add a project to the solution, select Setup and Deployment projects

from the Project Types tree, and then select Setup Wizard from the list of templates on the right. Enter a name and location for the project, and then click OK.
3. The Setup Wizard appears. The first page of the wizard is the welcome

screen. Click Next.


4. The second page of the wizard is the Choose a Project Type screen.

Choose Create a Setup for a Windows Application from the first group of options to create a setup project for Windows applications, as shown in Figure 13.1. Click Next.
5. The third page of the wizard is the Choose Project Outputs to Include

screen. Select Primary Output from the Windows application (in this example, the name of the application is MyProject), as shown in Figure 13.2. Click Next.

290 Chapter 13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Figure 13.1 The Choose a Project Type screen in the Setup Wizard prompts the user to select the project type.

Figure 13.2 The Choose Project Outputs to Include screen in the Setup Wizard prompts the user to select the project output that will be deployed by the installer.

6. The fourth page of the wizard is the Choose Files to Include screen.

You can use this screen to include any additional files in the setup project. Click Next.
7. The final page of the wizard is the Project Summary screen. Click

Finish to create the project.


8. Select the project in the Solution Explorer and provide meaningful

information for Manufacturer, ProductName, Title, and other information as desired using the Properties window for the project.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deploying . . . . . .a .Windows . . . . . Application . . . . . . 9. Build the setup project to create the setup package. When you are

291

done, open Windows Explorer and navigate to the Release folder inside the project folder. You will find the Setup.exe file, along with the installer package (.msi), initialization files (.ini), and any additional executables (.exe) needed. On a machine with the .NET Framework installed, you can install your new application by double-clicking the Setup.exe file. This enables you to specify the destination location during installation.If you later want to uninstall this application, you can do so through Start, Control Panel, Add/Remove Programs; simply select the application from the list of installed packages and select Remove. Easy removability or reinstallation to replace damaged component files is one of the many benefits of using the Windows Installer to deploy your package.
Deployment of your application requires the .NET Framework, which you can install from a source such as the Windows Update site. If you want to include a bootstrapper program that will automatically install the .NET Framework if it is not already present, you can download a sample from http://msdn.microsoft.com/downloads/ sample.asp?url=/msdn-files/027/001/830/msdncompositedoc.xml. Include the bootstrap information within your initialization (.ini) file to direct the setup file to the .NET Framework setup files.

Before deployment, you can modify the configuration settings for your package using the Property Pages dialog box for your project within the Solution Explorer, as shown in Figure 13.3.

Figure 13.3 The configuration settings page for a setup project.

292 Chapter 13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Five primary configuration properties are presented here:


Output filenameUsed to specify the name of the generated installer

(.msi) package.
Package filesUsed to specify whether the files should be packaged as

loose, uncompressed files, within the setup file or as one or more cabinet (.cab) files. If multiple cabinet files are allowed, you can specify the maximum size for each, to reduce the size of each file that must be downloaded by a user installing the package.
BootstrapperUsed to specify whether the installation package should

include the capability to install the Windows Installer utility on the client system if it is not already present, to allow installation of your application.
CompressionUsed to specify whether your files should be compressed

for either size or speed of installation.


Authenticode signatureUsed to specify the file containing an

Authenticode digital signature and private key file that will be used during installation.

Customizing Setup Projects


You can also customize your setup project using the Visual Studio .NET IDE editors. Visual Studio .NET provides different types of editors to customize various aspects of the installation process:
File System EditorUsed to specify the file system configuration that will

be used during installation. Within this editor, placeholders such as the users Startup folder are provided to reflect a mapping to the appropriate location for the user performing the installation. Some of the available special folders include the Application folder, the Common Files folder, the Program Files folder, the users desktop, and the System folder. This editor can be used to configure shortcuts to your application that automatically are installed along with the application.
Registry EditorUsed to specify Registry keys, subkeys, and values that

will be added to the Registry of the users system during installation.


File Types EditorUsed to specify file type associations, allowing your

application to automatically open a file if its type (based on the file extension) matches the associated value.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deploying . . . . . .a .Windows . . . . . Application . . . . . . User Interface EditorUsed to customize the installation interface to

293

include dialog boxes within the start, progress, and end stages of installation. This editor can be used to include rich-text (.rtf) files such as your license agreement and readme files mentioned earlier, so the installation will continue only after the user acknowledges reading the details provided.
Custom Actions EditorUsed to allow the specification of compiled .dll

or .exe files to be executed during the install, commit, rollback, or uninstall phases of installation. These might be used to configure a database for your application or any other type of executable action that is not directly a part of the installation itself. If a custom action fails, the entire installation is rolled back, leaving the target machine to its original state.
Launch Conditions EditorUsed to set conditions that must be met

before an installation can begin, such as whether the .NET Framework is already installed or whether a particular Registry key is present. If the condition is not met, installation terminates. You can view editors by right-clicking the project in the Solution Explorer and then selecting View and the desired editor.
The Condition property is present on Editor elements such as folders, files, Registry keys, custom actions, and launch conditions. The Condition property consists of a valid conditional statement in the form of a string that evaluates to either true or false. If this property does not evaluates to true, the action is not enacted.

Shared Assemblies
Chapter 4, Components and .NET Assemblies, covered the creation of assemblies, noting that a shared assembly is stored in the Global Assembly Cache (GAC) so that it can be shared by several applications. Because the GAC allows multiple versions of the same assembly to be present at once, the assembly must be designated using a strong name; this includes the assemblys text name (the name of the file without its extension), the version number (major, minor, build, and revision), culture information (neutral or localized), and a unique digital signature. The following sections discuss how to digitally sign an assembly and how to add shared assemblies to the GAC.

294 Chapter 13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Signing the Assembly


The digital signature is created using a public key encryption process that involves first creating a public key/private key pair using the Strong Name utility (sn.exe), calculating a hash of the assembly, and then encrypting the hash using the private key. The encrypted hash value and the public key are accessed within the assemblys manifest by the CLR and are used to verify that the assembly remains uncorrupted and unique.
When signing multifile assemblies, you need to sign only the assembly manifest because it contains hash values for the included files. When the signed manifest is verified as unchanged, it is easy to then evaluate the included files to ensure that they are also correct.

Immediate Signing
You can create a public key/private key pair using the Strong Name command-line utility provided within the .NET Framework Software Development Kit (SDK) using this format:
sn k MyKeys.snk

You should then add this file to your component project and use the AssemblyVersion and AssemblyKeyFile attributes in the AssemblyInfo.cs file to specify the version number and keyfile (.snk) to be used when signing this assembly. The settings will look something like this:
[assembly: AssemblyVersion(1.0.*.*)] [assembly: AssemblyKeyFile(@<Path to Keyfile>\MyKeys.snk)]

When you rebuild the component, its digital signature is created to provide a unique strong name. Using asterisks (*) for the build and revision number allows the compiler to update those values automatically each time you rebuild the component.

Delay Signing
It is also possible to sign an assembly using only its public key so that it can later be uniquely signed using a more secure private key. This eliminates the need to provide both public and private keys to all developers. You can extract just the public key from your keyfile using this line:
sn.exe p MyKeys.snk MyPubKey.snk

When using this file to sign your assembly, you must specify the use of a delay sign, as shown here:

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deploying . . . . . .a .Windows . . . . . Application . . . . . .


[assembly: AssemblyVersion(1.0.*.*)] [assembly: AssemblyDelaySign(true)] [assembly: AssemblyKeyFile(@<Path to Keyfile>\MyPubKey.snk)]

295

After development has been completed, you can re-sign the final component using the following private key:
sn.exe R MyComponent.dll MyKeys.snk

Authenticode Signing
An assembly signed with a strong name does not automatically assert a companys identity, such as its name. For that purpose, you can use an Authenticode signature, in which case the companys identity is asserted by a third-party certification authority (such as Verisign or Thawte). You can use the File Signing tool (signcode.exe) to attach an Authenticode signature to the assembly. An important thing to know is the order of commands when signing an assembly using both sn.exe and signcode.exe. You must sign your assembly with the Strong Name tool (sn.exe) before you sign it with the File Signing tool (signcode.exe).

Adding an Assembly to the GAC


When you have associated a strong name with your new assembly, you can add it to the GAC in several ways:
Windows InstallerYou can create a Merge Module (.msm) project with-

in Visual Studio .NET, which then is added to your Setup project for the application that will consume the shared assembly. The Windows Installer then adds the shared assembly to the installation hosts GAC during installation.
Windows ExplorerDuring installation of the .NET Framework, the

Assembly Cache Viewer Shell Extension (shfusion.dll) is installed. This component allows the addition of new assemblies into the GAC by simply navigating to the assembly cache (%systemroot%\WINNT\ assembly or %systemroot%\Windows\assembly) and then dragging and dropping the component (.dll) file into this folder.
Microsoft .NET Framework Configuration toolYou can use the Add an

Assembly option within the .NET Framework Configuration tool to add your component to the GAC. This utility is found in the Administrative Tools section of the Windows Control Panel.

296 Chapter 13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Global Assembly Cache Tool (GacUtil.exe)This command-line utility can

be used to add or remove an assembly from the GAC. The utility accepts switches to install (/i), list (/l), or uninstall (/u) assemblies within the GAC.

Creating and Deploying the Installation Components


Many of your components will make use of additional resources, such as performance counters, event logs, or databases. When you deploy your application, it is important that these additional resources are included in the final installation component. This is accomplished by including an instance of the Installer class in your setup project. The Installer class derives from the System.Configuration.Install.Installer class and includes the following methods:
Commit methodUse this method to write the code that needs to be exe-

cuted after successful installation.


Install methodUse this method to write the code that needs to be exe-

cuted during the applications installation.


Rollback methodUse this method to write the code that needs to be exe-

cuted when the Install method fails to complete. This method is used to undo any changes enacted by the Install method before its failure.
Uninstall methodUse this method to write the code that needs to be

executed when an installed application is selected for uninstallation using the Add/Remove Programs Wizard. When you choose Add Installer within the properties of a class, a new instance of the ProjectInstaller class is added to your project. This object maintains a collection of Installer objects required for the instance to install the component within its Installers property. You can also create a custom class that inherits from the base Installer class to implement your own code and overload the methods of the base class. Within the Setup project, you can use the Custom Actions Editor to add the primary output from the Installer component. This action adds the necessary installation code to the Installer methods of the project. When you install

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deploying . . . . . .a .Windows . . . . . Application . . . . . .

297

this component, the necessary setup configuration is enacted on the installation host, provided that you added the following to your class before compilation:
[RunInstaller(true)]

You can also use the Installer tool (InstallUtil.exe) command-line utility to install an assembly that includes additional component resources, as shown here:
InstallUtil.exe MyComponent.dll InstallUtil.exe MyComponent.dll AnotherComponent.dll

This utility can also be used to uninstall a component as well, as shown here:
InstallUtil.exe /u MyComponent.dll

If you are installing components from multiple assemblies by using the installutil.exe command and any assembly fails to install, installutil.exe rolls back the installations of all other assemblies. However, the process of uninstallation is not transactional.

URL Remoting
The .NET Framework includes a zero-touch deployment model that allows the installation of an application simply by navigating to the proper URL for the applications executable (.exe) file within Internet Explorer. The Web server does not need to have the .NET Framework for this to functionin fact, it does not even need to be a Microsoft Web server. The local systems .NET Framework handles the installation and execution of the application using a zone-based security model. Downloaded assemblies are maintained in a download cache, which is unique for each user and for each download location from which the user has remoted an application. The security model used is based on the zone from which the application is executed, which can be one of the following:
My_Computer_ZoneThis zone includes local file and URL paths on the

same system. By default, this zone has the FullTrust permission.


LocalIntranet_ZoneThis zone includes URLs accessing systems located

on the same network. By default, this zone has the LocalIntranet permission.
Internet_ZoneThis zone includes all addresses outside the local net-

work. By default, this zone has its permissions set to None if the .NET Framework Service Pack 1 (SP-1) has been installed; otherwise, it has the Internet permission.

298 Chapter 13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Trusted Sites ZoneThis zone includes Web sites that you trust to not

damage your computer or data. By default, this zone has the lowest security permission, and most of the code originating from this zone will be capable of executing.
Restricted Sites ZoneThis zone includes Web sites that could potentially

damage your computer or data. By default, this zone has the highest security permission and disallows the code originating from this zone to execute. You can modify the security zone settings using the Microsoft .NET Framework Configuration tool located in the Administrative Tools section of the Windows Control Panel. In the Microsoft .NET Framework Configuration tool, select the Runtime Security Policy, Machine, Code Groups, All_Code, My_Computer_Zone nodes to modify or view the security settings at the machine level. You can also adjust the runtime security policy for a particular assembly within the Runtime Security Policy folder. When you configure the Runtime Security settings for an assembly, you have the option to configure access for only the logged-in user or for all users on the machine.
Remember that if you relax the security for a zone, such as providing FullTrust to the Internet_Zone, you might allow undesired components to run on your system.

Deployment Considerations
Many different methods exist for deployment of your application, including these:
Removable mediaThis deployment form makes use of removable stor-

age such as floppy disks, CD-ROMs, ZIP disks, or even small solid-state storage devices. This is suitable when a user does not have an Internet connection, when the deployable application is so large that file transfers would not be reasonable, or when the tightest security is required for data contained within the application. By configuring the Setup project to use cabinet (.cab) files, you can specify a maximum size for each to allow the application to fit within the capacity of the media type used. The Setup.exe and Installer package (.msi) should be placed on the first disk in a series.
Network downloadThis deployment makes use of file shares to allow

remote users to access and download an application, generally from a

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deploying . . . . . .a .Windows . . . . . Application . . . . . .

299

read-only file share with access security limited by group membership. In this scenario, you can configure the Setup project to create a single setup file for the application, to simplify download for your users.
Administrative installationThis deployment method involves installing

the Windows Installer package to a network file share using the MSIEXEC command with the /a switch (example: MSIEXEC /a MyApp.msi). Users with access to this image within their workgroup can then install and run the application, accessing source files over the network.
Web-based distributionIt is possible to use the Web to distribute an

applications setup files. This method does not require a reproduction and distribution method, as with removable media. In this deployment method, you can allow the Setup project to generate the Installer package and multiple cabinet files so that the application can download its files as needed during installation.

Windows Logo Program Requirements


To reflect the degree to which a new application conforms to the guidelines for Windows development, Microsoft makes available several forms of logo certification. Products branded with a logo must meet at least the basic requirements of each program to be certified. Users thus know to what degree the application is considered compatible with their operating system. Currently, you should be aware of three types of logo programs:
Certified for WindowsThis logo program ensures that an application

meets the technical requirements for the Application Specifications for Windows 2000, detailed at www.microsoft.com/windowsserver2003/ partners/isvscfw.mspx. This site also includes prerelease guidelines for Windows Server 2003 program requirements.
Designed for Microsoft Windows XPThis logo program ensures that an

application meets the technical requirements for Designed for Microsoft Windows XP Application Specifications, detailed at www.microsoft.com/winlogo.
.NET ConnectedThis logo program ensures that applications conform

to varying levels of application specifications within the .NET and XML Web Service Application Specifications. Details of this program can be found at www.microsoft.com/net/logo.

300 Chapter 13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Practice Questions
Question 1
If you want to package a shared assembly for distribution, which of the following templates would be best for this requirement? A. Cab project B. Merge Module project C. Setup project D. Web Setup project

Answer B is correct. A Merge Module project is used to create a redistributable package that includes shared components or assemblies. Answers A and D are incorrect because Cab and Web Setup projects are used to package ActiveX controls and Web applications for deployment to a Web server. Answer C is incorrect because Setup projects are used to create Windows Installer packages for application distribution.

Question 2
After building a Setup project, which files will be present in the Release folder of the setup project? (Select all that apply.) A. .exe B. .ini C. .msi D. .txt

Answers A, B, and C are correct. The Setup project produces the installer package (.msi), initialization files (.ini), and any additional executable files (.exe) needed. Text (.txt) files are not produced directly by this process, making answer D incorrect.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deploying . . . . . .a .Windows . . . . . Application . . . . . .

301

Question 3
When deploying an application packaged as an .msi file to a user accessing the package through a network file share, what components must be loaded first? (Select all that apply.) A. .NET Framework on the server B. .NET Framework on the workstation C. Windows Installer on the server D. Windows Installer on the workstation

Answers B and D are correct. Both the .NET Framework and Windows Installer components must be installed on the users workstation before installing an installer package (.msi). Because all installation processing is performed on the workstation, neither component is specifically required on the server, making answers A and C incorrect.

Question 4
Which Setup project configuration option would be used to specify the creation of .cab files no larger than 1.4MB to fit your application on multiple floppy disks? A. Bootstrapper B. Compression C. Package files D. Output filename

Answer C is correct. The package files option allows specification of the type of file to be generated, including the capability to specify the maximum size for generated cabinet (.cab) files. The Bootstrapper option is used to specify whether the distributable application should carry a copy of the Windows Installer package with it for installation first if the destination system lacks the utility, making answer A incorrect. Answer B is incorrect because the Compression option is used to specify whether the installer package should be compressed to make the file smaller or to speed up its installation. The Output filename is used to specify the name for the generated installer package, making answer D incorrect as well.

302 Chapter 13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Question 5
Which editor should be used to enable the automatic creation of a shortcut icon for your application during the installation in the users desktop? A. Custom Actions Editor B. Launch Conditions Editor C. File Types Editor D. File System Editor E. User Interface Editor

Answer D is correct. The File System Editor allows you to specify shortcuts and icons mapped to user-relative paths such as the users desktop. Answer A is incorrect because the Custom Actions Editor is used to configure additional installation actions to be taken that are not directly a part of the installation itself. The Launch Conditions Editor is used to specify conditions that must be met before installation can occur, making answer B incorrect. Answer C is incorrect because the File Types Editor is used for file type association between the application and files of the type it should handle. The User Interface Editor is used to configure dialog boxes that will be presented to the user during the installation process, making answer E incorrect.

Question 6
You want to execute custom code when the installation of a component is successful. Which of the following methods of the Installer should you choose to write your custom code? A. Install B. Rollback C. Commit D. Uninstall

Answers C is correct. The Commit method executes when the installation is successful. Answer A is not correct because the Install method executes when the installation is performed; the installation might or might not be successful. Answer B is not correct because the Rollback method is executed when the installation fails. Answer D is not correct because the Uninstall method executes to remove an installation.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deploying . . . . . .a .Windows . . . . . Application . . . . . .

303

Question 7
A strong name must include which of the following elements? (Select all that apply.) A. Authenticode signature B. Culture C. Digital signature D. Version E. Text name

Answers C, D, and E are correct. An assemblys strong name must include a text name, a version number, culture information (if specified), and a unique digital signature created from the hashed value of the application. Answer A is not correct because an Authenticode signature can be added to allow thirdparty verification of an assemblys source, but it is not required for its strong name. Answer B is not correct because although culture information may be included, it is not necessary.

Question 8
When using delay signing, which key(s) are used to sign the assembly initially? A. Public key B. Private key C. Both keys D. Hashed key

Answer A is correct. In delay signing, the public key is used to sign the assembly during development. The private key is used later to sign the assembly for deployment, making answers B and C incorrect. Answer D is incorrect because the hashed value is used along with the signing key to create the final digital signature.

304 Chapter 13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Question 9
Which methods can be used to register a shared assembly within the GAC? (Select all that apply.) A. Global Assembly Cache tool B. Internet Explorer C. Microsoft .NET Framework Configuration tool D. Windows Explorer E. Windows Installer

Answers A, C, D, and E are correct. An assembly can be registered in the Global Assembly Cache through the Global Assembly Cache tool (GacUtil.exe), the Microsoft .NET Framework Configuration tool, Windows Explorer, and Windows Installer. Answer B is incorrect because Internet Explorer cannot register a shared assembly in the GAC.

Question 10
Which zone should you edit to allow the execution of an assembly identified by a URL within the same subnet as the client? A. My_Computer_Zone B. My_Network_Zone C. LocalIntranet_Zone D. Internet_Zone

Answer C is correct. The LocalIntranet_Zone is used for URLs within the same network. Answer A is incorrect because My_Computer_Zone is used only for paths local to the users system. There is no My_Network_Zone, making answer B incorrect. Internet_Zone is used for URLs outside the local network, making answer D incorrect.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deploying . . . . . .a .Windows . . . . . Application . . . . . .

305

Need to Know More?


Jeffery Ritcher. Applied Microsoft .NET Framework Programming. Microsoft Press, 2002. Microsoft Developer Network: http://msdn.microsoft.com. Microsoft Windows Update Site: http://windowsupdate. microsoft.com. Certified for Microsoft Windows logo program Web site:
msdn.microsoft.com/certification.

Designed for Microsoft Windows XP logo program Web site: www.microsoft.com/winlogo. Microsoft .NET Connected logo Web site: www.microsoft.com/ net/logo.

Вам также может понравиться