Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
23
CHAPTER
Deploying a Windows-Based Application In this chapter, you will • Plan and set up a web-based deployment • Plan and set up a network deployment • Learn the Windows Installer files and requirements • Be able to register components and assemblies • Recognize security policies
In this chapter, we will explore how you package and deploy an application, as it pertains to the Microsoft exam. You will need to know how to plan the deployment of a Windows-based application from removable media, from the Web, and from a network. You will also need to understand the Windows Installer requirements. One topic of great concern to developers is how you install an application that allows components and assemblies to be registered properly. Over the past few years, it has been difficult to ensure that an uninstalled application actually removed all of its components. Users often have to “clean out” the Registry of entries left behind when an application is dropped from the system. We will see, in this chapter, how that concern is addressed by .NET. If you haven’t had a chance to look at Chapter 6 in any detail, you should take the time now. We will briefly review assemblies and the Global Assembly Cache (GAC) in this chapter, but it has been covered in detail in Chapter 6. Security plays a big part in a properly deployed application, and we will discuss security policies and look at configuration files.
Review of Assemblies An assembly is a group of files and resources that make up a single, executable unit. The unit can be deployed, it has a version number, and it can be secured. An application is made up of one or more assemblies.
1 P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:44 PM
Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide
2 Each assembly is self-describing. This means that there is metadata (data about data) for each assembly. The metadata identifies the version of the assembly, the security restrictions, the types that are implemented by the assembly, the list of files included in the assembly, and so forth. For years, developers have been plagued by versioning and security issues, which arise from component information being stored in the Windows Registry. By using assemblies, the .NET Framework includes the metadata information with the assembly files and, as a result, has removed it from the Registry and has eliminated the problems associated with it. The previous problems included having a newer component replace an older one when some applications needed the old component and some needed the new one. .NET has solved this problem by having every application keep track of its own components. Now we can have several applications using different versions of the same type of component (this is called side-by-side versioning). This is a huge improvement over earlier component versioning, and developers are very excited by the possibilities. An assembly contains the following: • Assembly name
This can be private or strong.
• Cryptographic hash • Locale
This provides a check for version and security.
This identifies the .culture.
• Manifest
This is the metadata describing all the rest.
• Security
This specifies the permissions.
• Types • Version
This identifies the scope of all types. This is the version number.
Strong Named Assemblies By default, assemblies are private. This means that they run within the context of the application domain and will never cross the boundary into another application’s namespace. However, assemblies can be shared. Shared assemblies are installed into the Global Assembly Cache (GAC) and can be made available to other applications. In that case, a shared assembly must have a unique name that is referred to as the strong name. A shared assembly is created in order to provide code reusability between applications or to control versions. You can create a strongly named assembly by using the Strong Name utility included in the SDK: Sn –k myAKeys.snk
This will create a file with public and private keys that will be used to give the assembly a guaranteed unique name. Refer to Chapter 6 for more information on creating the strong-name key file.
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:44 PM
Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
Chapter 23: Deploying a Windows-Based Application
3 The next step is to tell your application to use the key. You do this by signing the assembly (adding the key to the assembly). Locate the file in the Solution Explorer called AssemblyInfo.cs. Open the file and change this line: [assembly: AssemblyKeyFile("")]
to this: [assembly: AssemblyKeyFile("myAKeys.snk")]
The compiler will now know to digitally sign the assembly using the keys found in the .snk (strong-name key) file. EXAM TIP You must recompile your program in order to apply the changes made to the AssemblyInfo.cs file.
Installing an Assembly into GAC The Global Assembly Cache is a local machine storage area that holds shared assemblies. It is used to store assemblies that can be shared among several applications.
You can find the GAC in one of two locations, depending on the version of Windows: • c:\Winnt\Assembly for Windows NT or Windows 2000 versions • c:\windows\assembly for Windows 98/XP versions The cache can be accessed using the GAC tool—gacutil.exe. This tool allows you to view and change the contents of the GAC. In particular, it allows you to install assemblies into the cache or remove them from the cache. The syntax is as follows: gacutil [options] [assembly]
Table 23-1 displays the options available for the GAC tool. EXAM TIP
Table 23-1 The gacutil.exe Options
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:45 PM
You need administrative privileges to access the GAC.
Option
Description
/h /I /u /l
Displays help topics for the gacutil.exe tool. Installs an assembly into the GAC. Uninstalls an assembly from the GAC. Lists the contents of the GAC.
PART IV
EXAM TIP The cache can contain one or more versions of the same assembly. This is called side-by-side versioning.
Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide
4 EXAM TIP Here is an example of installing myFile.dll into the GAC—gacutil /i myFile.dll. Before we leave the discussion of assemblies, keep the following in mind. Shared assemblies allow you to • Reuse code modules. • Maintain a unique namespace for the assembly (using strong names). • Maintain versions of assemblies (side-by-side versioning).
Precompiling Assemblies Instead of having your assemblies generated on the fly, you can run the Ngen.exe utility and create a native image. This should cause the application to load faster, since the work of compiling the code has been done in advance. When an assembly is executed, the runtime searches for the native image (a file containing compiled processor-specific code). If it is unable to find it, the runtime will look for the JIT (just-in-time) compilation of the assembly. EXAM TIP The syntax of the Ngen.exe utility is as follows: ngen [options] [AssemblyName]. Some of the Ngen.exe options are shown in Table 23-2. EXAM TIP Remember that the reason to use Ngen.exe is to allow the assembly to load and execute faster. Not every application will benefit from using a precompiled assembly. You must do a comparison between the JIT compiler and a precompiled assembly. The most benefit will be seen in startup times and, in that case, a CPU-intensive startup would benefit greatly from precompiling assemblies with Ngen.exe.
Table 23-2 Options for Ngen.exe
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:45 PM
Option
Description
/debug /delete /help /show
Generates the image used by a debugger. Deletes the native image files in the native image cache. Provides assistance. Lists the existing files in the native image cache.
Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
Chapter 23: Deploying a Windows-Based Application
5 EXAM TIP Using Ngen.exe eliminates the possibility of creating runtime optimizations on the code. It also doesn’t allow for deploying your application with the .NET redistributables (CLR for applications).
Deploying a Windows Application
• Setup project You can create a Windows Installer package that includes setup files that will handle the actual installation. The setup files manage your application files and resources and create an uninstall procedure to remove the application. • Web Setup project This is the same process as the Setup project, but you can deploy your application from a web server. • CAB project Remember the days of cabinet files? Well, they’re still around. This is similar to having a ZIP file that contains all the necessary files and resources. You can deploy it from an HTML page using a CAB project. • Merge Module project This is the first step in creating a deployment project that includes many different modules that must be brought together into one. Let’s look at each one of these in more detail.
Creating a Setup Project A Setup project allows you to create an installer for a Windows application. Visual Studio .NET provides you with many tools to customize your installer package. In this section, we will create an installation package for the college application.
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:46 PM
PART IV
This section will cover the deployment of a Windows-based application. When you finish an application, you work through the deployment process in order to create something that can be run on a client’s machine. The “something” is made up of different solutions—an executable file, an installer package, a web download, and so forth. When you deploy a solution, you must answer a number of questions—What files are needed? Where will the solution be hosted? and so on. Depending on your deployment scenario, the answers may be simple or as complicated as you wish. The good news is that you could very easily deploy a Windows-based application by simply copying the assembly into a new machine. Sound simple? It is. You don’t need to worry about the Registry as you did in days gone by. Just copy the executable created from your project into the new machine and Presto! It works! Having said that, we all know that large applications will be more difficult to approach in this manner. What about shared assemblies? What about security? What about location and icons? All these questions can be answered by deploying your application in one of the following ways:
Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide
6 To create the Setup project, start with these steps: 1. Open Visual Studio .NET. 2. Open the college application. 3. Add a new project by selecting File | Add Project | New Project. 4. Select Setup and Deployment Projects from the Project Types list. EXAM TIP Notice that the templates available from Setup and Deployment Projects include Setup Project (which creates a Windows installer), Web Setup Project (for deploying from a web server), Merge Module Project (which accumulates modules), Setup Wizard, and Cab Project. At this point you have two choices for a Setup project. You can either let the Setup Wizard assist you through the process, or you can choose Setup Project and customize the setup on your own (see Figure 23-1). We will start with the Setup Wizard here, and then examine the more hands-on approach using Setup Project in the next section.
Using the Setup Wizard When you use the Setup Wizard, it will take you through five different windows, each one designed to let you customize the Setup project. Although the wizard will do most of the work for you, you will still be able to customize the project after it is completed. Refer to the next section for customization options. To use the Setup Wizard, follow these steps: 1. Choose Setup Wizard from the Templates in the Add New Project dialog box (see Figure 23-1). Figure 23-1 New project templates
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:46 PM
Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
Chapter 23: Deploying a Windows-Based Application
7 2. The Setup Wizard will first display the Welcome screen. Click Next.
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:46 PM
PART IV
3. The second wizard screen of the Setup Wizard (see the following illustration) asks you to choose a project type—whether you are creating a Setup project for a Windows or a web application. For this example, choose the Windows application. This screen also asks whether you want to create a redistributable package—a merge module or downloadable CAB file.
Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide
8 EXAM TIP A redistributable package is required for applications that will be installed on machines that don’t have the .NET Framework installed. The package will contain the CLR, which needs to be installed for applications to run, and it is supported for Windows 98, ME, NT 4.0, 2000, XP, and .NET Server. Internet Explorer 5.01 or later must be on the machine, as well. If the redistributable package is to be installed on a server, the server must have MDAC 2.6 (MDAC 2.7 recommended for data applications) installed. 4. The third wizard screen asks which output groups you want to include in the Setup project. Notice that you can select from documentation files, localized resources, source files, and so forth.
5. Add any other files that need to be added to the Setup project in the fourth wizard screen. Click the Add button and browse for your files. Then click Next.
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:47 PM
Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
Chapter 23: Deploying a Windows-Based Application
9
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:47 PM
PART IV
6. The last wizard screen is the summary window. It’s a good idea to read the summary and make sure that you have included everything you need in the project. The summary window will tell you if there were any errors and specifies the output directory for the Setup project. If everything is okay, click Finish.
Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide
10 Once your project has been created with the Setup Wizard, you can make modifications. This is explained in the “Modifying Installers” section in this chapter.
Using the Setup Project The alternative to using the Setup Wizard is to select the Setup Project template in the Add New Project dialog box. These steps will create your project: 1. Select Setup Project from the Templates in the Add New Project dialog box (see Figure 23-2). For this example, name the project “My College Installer” and then click OK. 2. You will notice that the Solution Explorer has added your Setup project to the list (see Figure 23-3). This figure also shows the properties of the new project. You can set the author’s name, a description, manufacturer information, support phone numbers, and version numbers, to name just a few of the properties. EXAM TIP The name that you give the Setup project is important. This is the name that will be displayed in project folders and the Add/Remove Programs dialog box. 3. In Figure 23-4, you will see the format of the installer, and you can work with the properties of the destination machine. In the File System on Target Machine section, you can adjust the application folder, the user’s desktop, and the user’s program menu as it pertains to your application. Figure 23-2 Choose the Setup Project template
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:48 PM
Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
Chapter 23: Deploying a Windows-Based Application
11 Figure 23-3 The Setup project is shown in the Solution Explorer
PART IV
4. The next step is to add your application to the installer. Select your Setup project in the Solution Explorer, right-click on it, and choose Add | Project Output. You will see the Add Project Output Group dialog box shown in the following illustration. Here you can specify the parts of the project that will be added to the installer. For example, you can add documentation files,
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:48 PM
Color profile: Generic CMYK printer profile Composite Default All-In-One screen All-In-One / MCAD/MCSD / MCSD Visual Visual C#C# .NET .NET Certification Certification All-in-One All-in-One Exam Exam Guide Guide / Rempel / Rempel & Lind & Lind / 222443-6 / 222443-6 / Chapter / Chapter 23
23
MCSD Visual C# .NET Certification All-in-One Exam Guide
12
Figure 23-4
Set the file system for the application
localized resources, or, as shown in the illustration, the primary output, which is the actual .DLL or .EXE built by the project.
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:48 PM
Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
Chapter 23: Deploying a Windows-Based Application
13 5. The final step in this process is to build the installer. Select Build | Build <Setup Project Name> from the menus to create the installer. Once the basic installer program is created, you can check the local file system for your project directory, and you will see the files that have been created (see Figure 23-5). The Windows Installer package has been created (My College Installer.msi), along with the Setup application. EXAM TIP Notice that our files are listed in a subdirectory called “Debug”. You must ensure that you use a Release Build to create Setup projects. Use the properties of the solution to set the Configuration to Release (see Figure 23-6).
Modifying Installers There are a number of modifications you can make to your installer package after it’s been created. You may want to create a shortcut on the user’s desktop or insert additional files in the package. This can all be done from Visual Studio .NET. The following list explains three of the modifications you can make to the package:
Figure 23-5
The installer files that have been created
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:49 PM
PART IV
• Add a shortcut to the user’s desktop Select the Primary output from
from the Solution Explorer. Find the “Primary output from ” in the File System Editor, right-click on it, and choose Create Shortcut To. This will create a shortcut (which you can rename). Drag the new shortcut to the User’s Desktop folder.
Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide
14
Figure 23-6
Setting the project to create a release build
• Add Registry entries for the application Select the installer project from the Solution Explorer, right-click on it, and choose View | Registry. You will notice that the left side of the screen changes, as shown in Figure 23-7. You can then work with the Registry, and add keys and values. For example, you might want to set an application property in the Registry called “Start-up mode.” By adjusting the entry at this point, you can set the default value for the Registry and, in the actual application, allow the user to change it. • Set up custom installation windows Select the installer project from the Solution Explorer, right-click on it, and choose View | User Interface. In the User Interface tab (see Figure 23-8), choose the Start tab, right-click on it, and make your choice. In the example shown in Figure 23-8, we asked for Checkboxes from the Add Dialog dialog box. This will insert an additional, customized dialog box into the installation procedure. Using this customized dialog box, the user can make choices during the installation of the software.
Running the Installer Once you have the installation package set up the way you want it, you can run your setup program and let the installation run. Double-click the Setup.exe file, and you
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:49 PM
Color profile: Generic CMYK printer profile Composite Default screen All-In-One All-In-One / MCAD/MCSD / MCSD Visual Visual C#C# .NET .NET Certification Certification All-in-One All-in-One Exam Exam Guide Guide / Rempel / Rempel & Lind & Lind / 222443-6 / 222443-6 / Chapter / Chapter 23
23
Chapter 23: Deploying a Windows-Based Application
15
Adding Registry entries
Figure 23-8
Adding custom installation procedures
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:50 PM
PART IV
Figure 23-7
Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide
16 will see the installation windows shown in Figures 23-9 through 23-11. (Figure 23-11 will only be displayed if you add a custom dialog box to the installation.) Figure 23-9 shows the installer’s welcome screen. Figure 23-10 shows the Select Installation Folder screen, which allows the user to choose the location of the installed files. Finally, Figure 23-11 shows our customized dialog box (it’s not too exciting, but you can see the possibilities).
Creating a Web Setup Project In the previous section, we discussed creating a Setup project that would be deployed in a traditional manner. The output from the Setup project can be copied (deployed) onto a CD or onto a hard disk. However, you can also deploy from a web server—the installer can be deployed to a web server so that a user can download and run it from the server. In order to create a Web Setup project, you need to select Web Setup Project in the Templates list in the Add New Project dialog box (Figure 23-1). Instead of seeing the Application Folder, User’s Desktop, and User’s Programs Menu in the Solution Explorer, you will simply see the Web Application Folder (see Figure 23-12). At this point, little is different from creating a standard Setup project. You can add project output groups, add resources, and so forth, in the same fashion. Once the Web Setup project has been built, you can copy it to the web server computer and make it available for download by the users. EXAM TIP In order to deploy to a network solution, create the Web Setup project and copy the installer to a server computer. The installer can then be downloaded over a network. Figure 23-9 Windows Installer
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:50 PM
Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
Chapter 23: Deploying a Windows-Based Application
17 Figure 23-10 Setup Installation Folder
Creating a CAB project is perhaps the easiest of all solutions. A CAB project (a project containing cabinet files) consists of a single, compressed file that contains all of the Figure 23-11 Customized dialog box
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:50 PM
PART IV
Creating a CAB Project
Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide
18
Figure 23-12
Creating a Web Setup project
setup files. The project can be placed into an HTML page on an intranet or Internet site and downloaded to the client computer from there. Once the user runs the setup program, the CAB file’s contents are extracted and installed onto the user’s computer. Here’s how you create a CAB project: 1. Select File | Add project | New Project from the menus. 2. Choose Setup and Deployment Projects from the Project Types list in the Add New Project dialog box. 3. Select CAB Project in the Templates list. When you choose it, a CAB file will be added to the Solution Explorer. Right-click on the CAB file and select Add. The Add Project Output Group dialog box will be displayed, as shown in the following illustration.
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:51 PM
Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
Chapter 23: Deploying a Windows-Based Application
19
Creating a Merge Module Project You create a Merge Module project to package files and components that will be shared amongst multiple applications. All of the files, resources, and Registry entries will be found in the merge module file. The file has an extension of .msm. A component that will be shared amongst applications should be placed into its own merge module. EXAM TIP A merge module (.msm) is added into other deployment projects and is used by developers. A Windows installer (.msi) is created for an end user of the application. To create a Merge Module project, select Merge Module Project from the Setup and Deployment Projects dialog box. To add a Merge Module project to an existing solution, select File | Add | Existing Project from the menus. EXAM TIP A merge module can also be used to deploy patches or new versions of a component.
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:51 PM
PART IV
EXAM TIP Creating a CAB project packages the files into a single, compressed file with a .cab extension.
Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide
20 Conforming to Windows Standards An application should conform to the Windows Installer requirements, and you may also want to conform to the Windows logo program requirements. The Microsoft exam objectives suggest that you need to understand that the application must conform to both of them. In order to comply with Windows Installer requirements, your application must do the following: • Manage version-checking of shared components. • Be self-repairing. • Have a reliable uninstall program and correctly handle shared components. For example, the uninstall procedure should not arbitrarily uninstall shared components. • Be able to install on client machines for which the user is not an administrator. • Make full use of Windows 2000 IntelliMirror, which essentially allows the user access to their policy settings from anywhere on the network. In order to ensure that your application meets with the requirements for the Windows logo program, which allows you to distribute your application with “Designed for Windows” attached to it, you must follow the requirements set forth in this web site: http://www.microsoft.com/winlogo/software/.
Security Policies In the next chapter, we will deal with security issues you should be aware of when preparing your application for user delivery. In short, policies are the set of rules that the runtime uses when it loads your code. These policies can be configured in one of two ways: • By editing the XML configuration file (see Chapter 24). • By using the .NET Framework Configuration tool—Mscorcfg.msc. The configuration tool can be run by selecting Start | Programs | Administrative Tools | Microsoft .NET Framework Configuration. Figure 23-13 shows the .NET Framework Configuration tool. We will explore this tool in greater detail in the next chapter. Notice in Figure 23-13 that you can configure the assembly cache, manage assemblies, adjust remoting services, manage applications, and configure security policies. If you select the latter, you will see the Code Access Security Policy window shown in Figure 23-14. Stay tuned to Chapter 24 for more information on security and security policies.
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:51 PM
Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
Chapter 23: Deploying a Windows-Based Application
21
The .NET Framework Configuration tool
Figure 23-14
The Code Access Security Policy window
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:52 PM
PART IV
Figure 23-13
Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide
22
Summary Proper planning when deploying your application is crucial to its success. In this chapter, we discussed the various methods of packaging your application: • Windows Installer 2.0 files have the packages in a single .msi file, and they are installed by running the Setup.exe program. • CAB files have the packages in a single .cab file, and they can be downloaded from a network server or an HTML page. • The assemblies and executables can be provided in their original folders and can be copied to the client machine using XCOPY or FTP. We also looked at deployment of an application, which takes the packaged files and sends them to a location for download or installation. Keep the advantages and disadvantages of each technique in mind when studying for the exam. EXAM TIP Windows Installer is the preferred method of packaging and deploying. In the next chapter, we will look at security issues and expand on the discussion we started in this chapter. We will also look at how you can optimize your final product. Finally, we will wrap up all the loose ends that have not been covered yet, but that you are liable to see one or two questions about on the exam. You’re almost there—hang in.
Test Questions 1. Which tool allows you to install an assembly into the GAC? A. Ngen.exe B. Mscorcfg.msc C. Setup.exe D. sn.exe 2. Which of the following accurately describes a strong named assembly? A. A private assembly with a unique name within an application domain. B. A private assembly with a unique name within a global domain. C. A shared assembly with a unique name within an application domain. D. A shared assembly with a unique name within a global domain. 3. Which template must be chosen from the Add New Project dialog box’s Templates list in order to have an application downloaded from an IIS (Internet Information Server) server?
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:52 PM
Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
Chapter 23: Deploying a Windows-Based Application
23 A. Windows Setup Project. B. CAB Project. C. IIS Project. D. Web Setup Project. 4. You have followed the steps in creating a Windows Installer Setup project, and after deployment you notice that it does not install properly on the client. Which of the following could be the problem? A. You forgot to run the sn.exe utility. B. The shortcut was not configured properly. C. The release type is set to Debug. D. The Registry entry is incorrect. 5. Why did Microsoft invent assemblies? A. To allow applications to take care of their own components. B. To speed up processing. D. To ensure that all components register properly in the Registry. 6. Select two techniques for viewing the GAC. A. .NET Configuration Viewer. B. .NET Configuration tool. C. gacutil.exe D. gacview.exe 7. What can be configured using the .NET Configuration tool? A. GAC cache. B. Assemblies. C. Security. D. Policy levels. E. All of the above. F. None of the above. 8. Which of the following command-line entries would allow you to install an assembly into the GAC? A. gacutil /l myAssembly.exe B. gacutil /i myAssembly.exe C. gacutil /s myAssembly.exe D. gacutil /h myAssembly.exe
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:53 PM
PART IV
C. To confuse developers studying for the .NET development exams.
Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide
24 9. Which command would you use to list the existing files in the native image cache? A. Ngen.exe /list B. Ngen.exe /cache C. Ngen.exe /debug D. Ngen.exe /show 10. What kind of project can you create from the Setup and Deployment Projects list? A. Web Setup project. B. GAC project. C. Setup project. D. CAB project. E. B, C, and D. F. A, C, and D. 11. If the redistributable package is to be installed on a server, what must be in place? A. .NET Framework B. SQL Server C. MDAC 2.6 D. CLR 12. Why is the Setup project name important? A. Setup looks for files under that name. B. It is the name in the Add/Remove Programs dialog box. C. There cannot be any spaces in the name. D. The name goes in the Registry. 13. What can you expect to find in an assembly? Choose all that apply. A. Security hash. B. Locale specifications. C. Registry GUID. D. Version numbers. E. Program ID. 14. Which line must exist in the AssemblyInfo.cs file in order to “sign” the assembly? A. [assembly: AssemblyKeyFile("")] B. [key: AssemblyKeyFile("")]
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:53 PM
Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter
23
Chapter 23: Deploying a Windows-Based Application
25 C. [assembly: AssemblyKeyFile("myKeys.snk")] D. [key: AssemblyKeyFile("myKeys.snk")] 15. Where is the GAC located by default? A. Windows directory. B. Programs directory. C. Documents and Settings directory. D. Application directory.
Test Answers 1. A. 2. B. 3. D. 4. C. 5. A. 7. E. 8. B. 9. D. 10. F. 11. C. 12. B. 13. A, B, D. 14. C. 15. A.
P:\010Comp\All-in-1\443-6\ch23.vp Friday, August 23, 2002 5:05:53 PM
PART IV
6. B, C.