Module 9: Deploying Windows Forms Applications
Total Page:16
File Type:pdf, Size:1020Kb
Module 9: Deploying Windows Forms Applications Contents Overview 1 Lesson: .NET Assemblies 2 Lesson: Deploying Windows Forms Applications 24 Review 46 Lab 9.1: Deploying an Application 48 Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, place or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. 2002 Microsoft Corporation. All rights reserved. Microsoft, MS-DOS, Windows, Windows NT, Active X, Authenticode, FrontPage, IntelliSense, MSDN, PowerPoint, Visual Basic, Visual C#, Visual Studio, Win32, and Windows Media are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. The names of actual companies and products mentioned herein may be the trademarks of their respective owners. Module 9: Deploying Windows Forms Applications iii Instructor Notes Presentation: In this module, students learn about assemblies and the use of strong-named 120 minutes assemblies and the global assembly cache in the Microsoft® .NET Framework. Students also learn how to configure and deploy Windows Forms applications. Lab: 60 minutes After completing this module, students will be able to: Use strong-named assemblies in .NET applications. Use application configuration files to configure and use Microsoft Windows® Installer 2.0 to package and deploy .NET applications. Required materials To teach this module, you need Microsoft PowerPoint® file 2555A_09.ppt. Preparation tasks To prepare for this module: Read all of the materials for this module. Complete the demonstrations, practices and lab. iv Module 9: Deploying Windows Forms Applications How to Teach This Module This section contains information that will help you to teach this module. If students are interested in referencing code examples in other languages, point them to “Language Equivalents” in the Help documentation for the Microsoft Visual Studio® .NET development system. This section provides examples in languages such as Microsoft Visual Basic® .NET, C#, and Java. Lab 9.1, Deploying an Application is based on the Expense Report application used throughout Course 2555A, Developing Microsoft .NET Applications for Windows (Visual C#™ .NET) and is intended to simulate a real-world environment in which students will demonstrate what they learned during the lecture and practice portions of the module. The lab does not provide step-by-step detailed instructions; instead, the students are given tasks to complete in the left column and a list of resources that they can use (if they need help) in the right column. Students get the hands-on experience that they need by completing the practice activity in the module. Lesson: .NET Assemblies This section describes the instructional methods for teaching this lesson. The key points of this lesson are for the student to understand the difference between private and strong-named assemblies and the appropriate scenarios for the use of each. How to Install Also, be sure to emphasize that the GACUtile.exe utility is for use during Assemblies into the application development. For application development, assemblies should be Global Assembly Cache installed in the global assembly cache by using the .NET Framework configuration tool (Mscorcfg.msc) or Windows Installer setup projects. Lesson: Deploying Windows Forms Applications This section describes the instructional methods for teaching this lesson. In this lesson, point out to students that the deployment of Windows Forms applications is easier thanks to the support added by the .NET Framework, which avoids the old problem of dynamic link-library (DLL) versioning issues. Lab 9.1: Deploying an Application This section describes the instructional methods for teaching this lab. If a student opens the InternalBusinessApplication.sln solution file for Exercise 3, Deploying a .NET Application, the work area is initially blank. Tell students that to view the file system editor, in Solution Explorer they must right-click InternalBusinessApplication, click View, and then click File System. Module 9: Deploying Windows Forms Applications 1 Overview .NET Assemblies Deploying Windows Forms Applications Introduction In this module, you will learn about assemblies and the use of strong-named assemblies and the global assembly cache in the Microsoft® .NET Framework. You will also learn how to configure and deploy your .NET applications. Objectives After completing this module, you will be able to: Use strong-named assemblies in .NET applications. Use application configuration files to configure and use Microsoft Windows® Installer 2.0 to package and deploy .NET applications. 2 Module 9: Deploying Windows Forms Applications Lesson: .NET Assemblies What is an Assembly? What Are Private Assemblies? What Are Strong-Named Assemblies? How to Build a Strong-Named Assembly How to Call a Strong-Named Assembly Demonstration: Viewing Assembly Metadata Practice: Calling a Strong-Named Assembly How to Install Assemblies into the Global Assembly Cache Demonstration: Using the .NET Framework Configuration Tool to Work with the Global Assembly Cache Practice: Working with the Global Assembly Cache Introduction In this lesson, you will learn about the difference between private and strong- named assemblies, how to build and call strong-named assemblies. You will learn how to install strong-named assemblies in the global assembly cache and why you would want to do so. You will also learn how to use the Fusion Log Viewer (FusLogVw utility) to trace the assembly load process to troubleshoot application activation problems. Lesson objectives After completing this lesson, you will be able to: Describe the difference between private and strong-named assemblies. Build strong-named assemblies and call them from an application. Install strong-named assemblies in the global assembly cache. Use the FusLogVw utility to trace the assembly load process to troubleshoot application activation problems. Module 9: Deploying Windows Forms Applications 3 What is an Assembly? A functional unit of sharing, versioning, and identity in the .NET Framework A unit for which permissions are requested and granted Can be shared across .NET applications Introduction Applications in the .NET Framework always consist of one or more assemblies. Definition An assembly: Is a functional unit of sharing, versioning, and identity in the .NET Framework. Is a unit for which permissions are requested and granted. Can be shared across .NET applications. In the simplest case, an application can consist of one assembly that contains one managed module with all the code and resources for the application. In most scenarios, however, an application has multiple assemblies, and each assembly may have multiple files. References between assemblies are not resolved until the code making the call is executed. So, all assemblies of an application need not be present at run time. Assemblies, such as localization resources, can be retrieved on demand. All assemblies are self-describing. Each assembly contains metadata that includes the identity and version of the assembly and the types implemented by that assembly. You can use the Microsoft intermediate language (MSIL) Disassembler (Ildasm.exe) to view the contents of the assembly file. At the command prompt, type the following command: ildasm <assembly name> 4 Module 9: Deploying Windows Forms Applications What are Private Assemblies? Private assemblies Private assemblies are deployed with and used exclusively by a single application Where private assemblies can reside z Default probing process Application folder tree z Use Assembly.LoadFrom for these locations Any folder on the local computer Any folder on a remote computer A URL AssemblyAssembly PrivateAssembly;PrivateAssembly; PrivateAssemblyPrivateAssembly = = Assembly.LoadFrom("C:\\PrivateAssembly.dll");Assembly.LoadFrom("C:\\PrivateAssembly.dll"); //// ObtainObtain aa referencereference toto aa methodmethod knownknown toto existexist inin assembly.assembly. MethodInfoMethodInfo Method Method == PrivateAssembly.GetTypes()[0].GetMethod("CalculateSum");PrivateAssembly.GetTypes()[0].GetMethod("CalculateSum"); Introduction In the .NET Framework, you can create source code by using any programming language that is compatible with the .NET Framework. You then use the corresponding compiler to build a managed module. A managed module is a standard portable executable (PE) file for the Windows operating system