Tài liệu Module 3: Introduction to COM+ pdf

84 515 0
Tài liệu Module 3: Introduction to COM+ pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Module 3: Introduction to COM+ Contents Overview From COM to COM+ COM+ Architecture 16 Administering COM+ Applications 23 Lab 3.1 Building a COM+ Application 40 Debugging a COM+ Component 48 Deploying a COM+ Application 57 Lab 3.2: Debugging COM+ Components 72 Best Practices 75 Review 77 Information in this document is subject to change without notice The names of companies, products, people, characters, and/or data mentioned herein are fictitious and are in no way intended to represent any real individual, company, product, or event, unless otherwise noted Complying with all applicable copyright laws is the responsibility of the user No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Microsoft Corporation If, however, your only means of access is electronic, permission to print one copy is hereby granted 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  2000 Microsoft Corporation All rights reserved Microsoft, BackOffice, MS-DOS, Windows, Windows NT, Active Directory, ActiveX, Microsoft SQL Server, MSDN, PowerPoint, Visual Basic, Visual C++, and Visual Studio are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A and/or other countries The names of companies, products, people, characters, and/or data mentioned herein are fictitious and are in no way intended to represent any real individual, company, product, or event, unless otherwise noted Other product and company names mentioned herein may be the trademarks of their respective owners Module 3: Introduction to COM+ iii Instructor Notes Presentation: 145 minutes Lab: 100 minutes This module describes the origins and advantages of COM+ It introduces the COM+ architecture and explains how to create, debug, and deploy COM+ components After completing this module, students will be able to: ! Describe how the Component Object Model (COM) and Microsoft Transaction Server (MTS) have evolved to become COM+ ! List and describe the COM+ services ! Create and add a component to a COM+ application ! Debug a COM+ component ! Deploy a COM+ application In the labs, students will learn to create, debug, and deploy COM+ applications Materials and Preparation This section provides you with the required materials and preparation tasks that are needed to teach this module Required Materials To teach this module, you need the following materials: ! Microsoft PowerPoint file 1907A_03.ppt ! Module 3: Introduction to COM+ ! Lab 3.1: Building a COM+ Application ! Lab 3.2: Debugging COM+ Components Preparation Tasks To prepare for this module, you should: ! Read all of the materials for this module ! Complete the labs ! Read the instructor notes and the margin notes for the module ! Review Appendix A: Understanding COM Fundamentals and Appendix B: Working with COM Interfaces iv Module 3: Introduction to COM+ Module Strategy Use the following strategy to present this module: ! From COM to COM+ Discuss the evolution of the Component Object Model Explain how classic COM provides a programming model and supporting run-time library, which together assist in the creation of component-based software systems Also explain how MTS changed the programming model by introducing the idea of attribute-based programming, a key concept embraced by COM+ This model allowed developers to tap into MTS-provided infrastructure services simply by establishing a set of attributes within the MTS catalog— the information collectively known as the class’s configuration Explain how the key MTS services have been enhanced and extended by COM+ ! COM+ Architecture Describe the architecture of a COM+ application Discuss the elements of the COM+ environment, which consists of applications and components Discuss some of the supporting services and technologies that work with COM+ to manage system resources and transactions ! Administering COM+ Applications Show students how they can use the Component Services tool to manage and administer existing COM+ applications and components Explain that the Component Services administration tool can also be used to create COM+ applications, add components to applications, and view information about COM+ components Discuss the COM+ catalog, which acts as a data store for COM+ applications and component configuration information Explain how the COM+ administration objects are used by the Component Services tool to access the catalog Explain how these Automation objects are also available to scripted clients, which allows the development of automated administrative utilities There is a practice on creating a COM+ application and adding a component to the newly created application ! Debugging a COM+ Component There are a number of issues that need to be addressed when using Microsoft Visual Basic to debug a COM+ component Explain how to configure a Microsoft ActiveX DLL project for out-of-process debugging Discuss some of the issues and limitations that need to be addressed when debugging COM+ components Demonstrate how to debug an ActiveX DLL component within a COM+ application Refer to the demonstration notes presented in the next section ! Deploying a COM+ Application Explain how to use the Component Services tool to export COM+ applications for deployment on other servers Students should also know how to export application proxies for client-side deployment Finally, discuss the Windows 2000 Class Store, an Active Directory container used for distributed setup and on-demand component installation There is a practice on exporting and importing a COM+ application by using the Component Services tool Module 3: Introduction to COM+ v Note One recommendation (and best practice) is to install a separate tlb file with the component DLL in a COM+ application This approach allows only the type library (and not the entire component DLL) to be deployed for clientside installation While this technique worked well under MTS and should work under COM+, the Component Services Export Wizard generates an error when exporting an application proxy This error only occurs if the type library is installed in addition to a DLL containing an embedded copy of the type library The error displayed is as follows: "Error occurred writing to the application file Either the path cannot be accessed or an existing file cannot be overwritten Make sure you entered the full path for the application file The application was not exported." Visual Basic DLLs always contain an embedded copy of the type library, even if the Remote Server Files option has been selected to generate a separate type library This issue remains unresolved Demonstration This section provides demonstration procedures that will not fit in the margin notes or that are not appropriate for the student notes Debugging COM+ Components The purpose of this demonstration is to demonstrate how to debug an ActiveX DLL component within a COM+ application The other objective is to illustrate how COM+ interjects VB6Debug.dll into the COM+ application for the duration of the debug session This demonstration uses the sample BankApp component DLL located in \Democode\Mod3\Debugging ! Prepare for the demonstration Create a COM+ server application called BankApp Take all the default options when creating this application Insert the BankApp component DLL into the application This DLL contains one class called CAccount, which represents a bank account Familiarize yourself with the BankApp component by loading the BankApp.vbp project in Microsoft Visual Basic Notice that the CAccount class has three public routines: Deposit, Withdraw, and GetBalance Familiarize yourself with the TestHarness executable by loading the TestHarness.vbp project in Visual Basic The main form of the TestHarness project displays three buttons, which call the three public routines of the CAccount class vi Module 3: Introduction to COM+ ! Perform the demonstration Show students the BankApp application within the Component Services tool Display the properties of the BankApp.CAccount class and illustrate the current DLL file location prior to debugging Load the BankApp.vbp project into Visual Basic Set breakpoints within the Deposit, Withdraw, and GetBalance routines Demonstrate how to set the current debugging option to start the TestHarness executable by using the Debugging tab of the Project Properties dialog box Select the Start program option and set the start program to TestHarness.exe Run the BankApp project The TestHarness application will be launched Switch back to the component services tool, refresh the Components folder within the BankApp application, and again view the BankApp.CAccount class properties Show students how the DLL for this class has now been set to VB6Debug.dll Click the Deposit button on the test harness The Visual Basic process will halt at the breakpoint 10 Use F8 to step over the code within the routine and then click the Run button to return control to the test harness 11 Click the remaining buttons on the test harness—Withdraw and GetBalance—to which demonstrate how the breakpoints are hit in each case 12 Now end the debug session by pressing the End toolbar button within Visual Basic 13 Return to the Component Services tool, refresh the Components folder, and view the properties of the BankApp.CAccount class Demonstrate how the original component DLL file has been reestablished within the application 14 Stress that if the debug session ends abnormally, there is a danger of VB6Debug.dll being left as the registered component within the application Module 3: Introduction to COM+ # Overview Slide Objective To provide an overview of the module topics and objectives ! ! Administering COM+ Applications ! Lab 3.1: Building a COM+ Application ! Debugging a COM+ Component ! Deploying a COM+ Application ! Lab 3.2: Debugging COM+ Components ! Best Practices ! In this module, you will learn how to use COM+ queued components and events to provide message-based asynchronous communication COM+ Architecture ! Lead-in From COM to COM+ Review In this module, you will learn about COM+ services and how to use these services to support enterprise systems development The Component Object Model (COM) and Microsoft Transaction Server (MTS) have been integrated to become COM+ in Microsoft Windows 2000 COM+ provides prefabricated infrastructure to support the middle-tier functionality of an enterprise system This module focuses on key COM+ services and the architecture of a COM+ application You will learn how to create, debug, and deploy a COM+ application For information about COM and COM interfaces, see Appendix A: Understanding COM Fundamentals and Appendix B: Working with COM Interfaces Objectives After completing this module, you will be able to: ! Describe how COM and MTS have evolved to become COM+ ! List and describe the COM+ services ! Create and add a component to a COM+ application ! Debug a COM+ component ! Deploy a COM+ application Module 3: Introduction to COM+ # From COM to COM+ ! COM Programming Model ! Using COM Interfaces ! Implementing Interfaces ! Microsoft Transaction Server ! COM+ Programming Model ! COM+ Services In this section, you will learn about the evolution of COM You will learn how classic COM provides a programming model and supporting run-time library, which together assist in the creation of component-based software systems You will learn how MTS enhanced the COM programming model by introducing attribute-based programming With attribute-based programming, COM developers can administratively tap into a rich set of infrastructurerelated services provided by MTS In Windows 2000, COM and MTS have been consolidated to form COM+, the latest component programming model Finally, you will learn how to take advantage of COM+ services to build distributed applications This section includes the following topics: ! COM Programming Model ! Using COM Interfaces ! Implementing Interfaces ! Microsoft Transaction Server ! COM+ Programming Model ! COM+ Services Module 3: Introduction to COM+ COM Programming Model ! COM defines a programming model and provides a supporting run-time library $ ! To facilitate component-based development (CBD) Components provide discrete units of functionality $ Offering a service or services ! Component-based applications are easier to adapt and maintain ! This course focuses on DLL-based components $ EXE components can’t take advantage of COM+ services COM defines a programming model and provides a supporting run-time library that facilitates the development of software components A component can be thought of as a discrete unit of functionality offering a particular service or services In an insurance application, for example, a PremiumCalculator component may provide a calculation service capable of generating insurance premiums based on risk data Another component might search for a customer’s city and state based on the zip code entered The fundamental goal of COM is to enable applications to be constructed from preassembled parts or components Such applications are easier to maintain and change than the so-called monolithic applications built prior to the component era Components provide these advantages because they can be replaced with newer versions over time and with minimal impact on the rest of the system COM components also benefit from vendor independence, language independence, and location transparency Developing COM+ applications in Visual Basic means that you not have to worry about many low-level details of COM However, you should have a fundamental working knowledge of basic COM concepts and terminology before you start developing COM+ applications For more information about COM, see Appendix A: Understanding COM Fundamentals Note In this course, you will focus on DLL-based components because only DLLs can take advantage of the benefits provided by COM+ Windows 2000 supports EXE-based components, but these components will not be able to benefit from the many additional services and features provided by COM+ Module 3: Introduction to COM+ Using COM Interfaces ! The Set statement is used to obtain references to interfaces IUnknown Dim objIAcc As Utils.IAccount Dim objITrade As Utils.ITrade IAccount Set objIAcc = New Utils.IAccount ‘ Use IAccount interface ‘ Query for ITrade interface Set objITrade = objIAcc ‘ Use ITrade interface ‘ Release references Set objIAcc = Nothing Set objITrade = Nothing CTradingAccount ITrade _CTradingAccount Interfaces are central to COM development because objects always interact through a COM interface The interface defines the behavior of the object and specifies the precise syntax of the functions used to communicate with the object When programming in Visual Basic, it is not always apparent that interfaces are being used when interacting with COM objects Visual Basic presents a COM object as an entity exposing a set of methods, properties, and sometimes events Under normal circumstances, a Visual Basic client will be connected to the default interface exposed by the COM object When working in the COM+ environment, it is sometimes necessary to interact with a COM object through several of its supported interfaces For example, the COM+ context object discussed in this module exposes a number of interfaces providing transaction and security-related functionality Sometimes, it is necessary to develop a Visual Basic class module that implements an externally defined COM interface specified in a type library For example, this technique is essential when developing COM+ event classes used with the COM+ Event service For more information about the COM+ Event service, see Module 5: Queued Components and Events Default Interfaces The Set statement is used in conjunction with New or CreateObject to obtain an object’s initial interface This interface is usually the object’s default interface, although the exact interface returned depends on the type of the variable being set Consider an account object exposing IAccount and ITrade interfaces The following illustration shows the COM object together with the client code required to navigate between the two supported interfaces The above illustration shows an interface called _CtradingAccount This interface is the object’s default interface generated by Visual Basic when a class module is compiled The name of this interface is derived from the name of the class module In this example, the default interface contains no public functions because the object’s functionality is exposed solely by means of the IAccount and ITrade interfaces 64 Module 3: Introduction to COM+ In the Application Export Information dialog box, enter the full path of the application proxy file to be created or click Browse to search for an existing file or folder Under Export as, click Application proxy – Install on other machines to enable access to this machine Click Next and then Finish Remote Computer Name One key piece of information contained in the application proxy is the computer name of the server hosting the COM+ application By default, this computer name is the name of the computer from which the application proxy was exported You can change the remote server name by using the Computer Properties dialog box of the Component Services tool To change the remote server name, right-click the name of the computer from which you are exporting application proxies and select Properties Select the Options tab on the Properties dialog box as shown in the following illustration You can enter the name of the remote server computer in the Application proxy RSN field This name will subsequently be used in application proxy files Module 3: Introduction to COM+ 65 Note You can also change the default remote server name in an application proxy file at installation time Installing COM+ Application Proxies After the application proxy has been created as an msi file, you can install the proxy on the client computer in two ways: ! Use Windows Explorer You can use Windows Explorer to locate the application proxy (.msi) file Double-click the file (or right-click and select Install), which will launch the Windows Installer The installer will install the application proxy on the client computer The msi file can reside locally on the client computer or on a network share ! Use the command prompt At the command prompt, you can type the following: msiexec –i [] .msi In addition to the standard Windows Installer property overrides, you can specify the following options Option Description REMOTESERVERNAME= Changes the server to which the client computer will connect from the exported default to the new target server ALLUSERS=0 Installs the application proxy only for the current user By default, the application proxy is installed machine-wide 66 Module 3: Introduction to COM+ Practice: Exporting and Importing a COM+ Application In this practice, you will export the Purchase Order COM+ application by using the COM Application Export Wizard in the Component Services tool You will then delete the Purchase Order application from the COM+ catalog and reimport it using the COM Application Install Wizard ! Export the Purchase Order application Using the Component Services tool, expand My Computer and then expand the COM+ Applications folder Select then right-click the Purchase Order application and select Export Click Next to move past the initial dialog box of the COM Application Export Wizard Click the Browse button and navigate to the \Practices\Mod03 folder In the File Name field, enter POSystem and click Save You will return to the Application Export Information dialog box The msi file extension is automatically appended, resulting in the file name \Practices\Mod03\POSystem.msi Leave the Export As setting to the default Server application – Install this application onto other machines Click Next to export the application Click Finish to close the Application Export Wizard Module 3: Introduction to COM+ 67 Use Windows Explorer to examine the contents of the \Practices\Mod03 folder You will find two files: • POSystem.msi The Windows Installer file containing application details, including component DLLs, type libraries, and configured attributes • POSystem.msi.cab A cabinet file containing a compressed version of the msi file for quicker distribution and download You have exported the Purchase Order application and created a Windows Installer file Now you can delete the Purchase Order application to prepare for reimporting it ! Delete the Purchase Order application Using the Component Services tool, right-click the Purchase Order application and select Delete Click Yes to confirm that you want to delete the Purchase Order application The application will be removed from the COM+ catalog ! Import the Purchase Order application Using the Component Services tool, select and right-click the COM+ Applications folder, point to New, and select Application Click Next to move past the initial dialog box of the COM Application Install Wizard On the Install or Create a New Application dialog box, click Install prebuilt application(s) In the Install from application file dialog box, navigate to the \Practices\Mod03 folder and select the POSystem.msi file Click Open The Select Application Files dialog box will be displayed, showing the application file you have selected This dialog box lets you select additional applications to import Click Next In the Set Application Identity dialog box, leave the Account setting to Interactive user – the currently logged on user Click Next 10 In the Application Installation Options dialog box, leave the Install Directory as Default Directory (as specified by application file) 11 Click Next 12 The application will be imported and added to the COM+ catalog 13 Click Finish to close the COM Application Install Wizard 14 The Purchase Order application will appear under the COM+ Applications folder in the Component Services tool 15 Expand the Purchase Order application and then the Components folder 68 Module 3: Introduction to COM+ 16 Right-click the POBusiness.bus_Order component and select Properties 17 On the General tab of the Properties dialog box, notice the component DLL location The location should be set to \Program Files\COMPlus Applications\{}\POBusiness.dll This location is the default Module 3: Introduction to COM+ 69 The Class Store ! An Active Directory container $ ! Transparent class store access $ ! $ You can optionally show the COMClassStore policy setting within the Group Policy Editor The instructions for locating this setting is presented in the student manuals However, if you choose to so, be sure to be logged onto the instructor machine as Administrator CoCreateInstance has been extended to consult the class store if CLSID is not registered locally Class store access for Visual Basic $ Delivery Tip To simplify distribution of COM and COM+ components COMClassStore policy must be enabled for Visual Basic and legacy clients This policy is disabled by default The Class Store is an Active Directory container that is provided to simplify the distribution of COM and COM+ components The Class Store behaves as if it were a centralized registry for COM-related information and as such can be considered a distributed registry Unlike the Windows registry, the Class Store has been specialized for distributed setup and on-demand component installation The Class Store supports automated installation when an application runs and fails to find the required component locally The application can either go directly to the Class Store to search for missing components, or COM+ can the same thing transparently for the user By placing an application proxy (.msi) file centrally in the Class Store, the application proxy can be installed on demand on client computers If a client computer never requires access to the COM+ (server) application, the application proxy will never be downloaded and therefore registry and disk space on the client computer will be conserved Transparent Class Store Access Access to the class store is transparent from a client’s perspective This transparency has been achieved by extending COM’s activation APIs under Windows 2000 70 Module 3: Introduction to COM+ You may recall that the CoCreateInstance API is called internally by Visual Basic when the New keyword or CreateObject function is used to activate a component When CoCreateInstance is called, COM examines the local registry to see if the required component is already registered under its CLSID If COM finds the component locally, it will be instantiated as usual If it fails to find the CLSID in the local registry, it will consult the Class Store If the CLSID is registered in the Class Store, the MSI package associated with that CLSID is downloaded The msi package will then install and update the registry with the component’s information Next, COM will try again to locate the component in the local registry This time, it will find the component’s information under its CLSID and instantiate it as usual All subsequent calls will be serviced locally Accessing the Class Store and downloading an msi package takes time This download results in a delay the first time that a component for which there is no local registry information is instantiated The length of the delay depends on the distance between the client and Class Store, the network bandwidth, and the size of the package to install Class Store Access for Visual Basic To allow Visual Basic client applications and legacy COM applications to benefit from on-demand installation, you must enable the new COMClassStore policy This policy is disabled by default You must enable the Download missing COM components option in the Group Policy administrative tool to modify the COM run-time behavior so that it checks the Class Store after it fails in the local registry Group policy objects (GPOs) that contain policy settings may be associated with Active Directory containers such as sites, domains, or organizational units ! To enable the COMClassStore policy Start the Active Directory Users and Computers tool • On the Start menu, point to Programs, point to Administrative Tools, and select Active Directory Users and Computers In the left window, select and right-click the domain name and select Properties to display the Properties dialog box In the Properties dialog box, select the Group Policy tab Click Edit to edit the Default Domain Policy Module 3: Introduction to COM+ 71 Expand the Administrative Templates folder under the Computer Configuration node and select the System folder as shown in the following illustration Note The Download missing COM components property is located under both the Computer Configuration and User Configuration nodes so that policy settings can be applied to both computers and users Double-click Download missing COM components to change the policy setting 72 Module 3: Introduction to COM+ Lab 3.2: Debugging COM+ Components Slide Objective To introduce the lab Lead-in In this lab, you will debug a Visual Basic COM+ DLL in the VB environment In this lab, you will debug a Microsoft Visual Basic COM+ DLL by using the Visual Basic environment When debugging a COM+ DLL, Visual Basic uses a special VBdebug.dll to allow the required out-of-process behavior In this lab, you will examine this behavior Objectives After completing this lab, you will be able to: ! Use Visual Basic to debug COM+ DLLs Prerequisites Before working on this lab, you should be familiar with the following: ! Visual Basic debugging tools such as break points and the Immediate window Exercises The following exercise provides practice in working with the concepts and techniques covered in this module: ! Exercise 1: Debugging a COM+ Component In this exercise, you will debug the POBusiness COM+ component by using the Visual Basic debugging tools Estimated time to complete this lab: 30 minutes Module 3: Introduction to COM+ 73 Exercise 1: Debugging a COM+ Component In this exercise, you will debug the POBusiness COM+ component by using the Visual Basic debugging tools ! Set the debugging properties of POBusiness Open the POBusiness.vbp project in you worked on in Lab 3.1 If you did not complete Lab 3.1, you may open the POBusiness.vbp project in the \Labs\Lab03\Solution\POBusiness folder On the Project menu, click POBusiness Properties On the Debugging tab, note the options available when the project starts Select Start browser with URL and enter the URL http://Localhost/POSystem/orderform.asp Select the Use Existing Browser check box (if it is not already selected) and then click OK ! Debug the POBusiness DLL In the Raise method of the bus_Order class module, place a break point on the line of code that states strUser = “Student” Run the project The Purchase Order Web site should open in Microsoft Internet Explorer Add an item to the shopping cart and then click Submit Note that the code stops execution at the break point you set Press F8 to step through the code strUser = “Student” In the Immediate window, type ?strUser and then press Enter The value of strUser will be displayed in the Immediate window Press F8 to trace the program’s execution until the Raise method finishes Close Internet Explorer and stop the Visual Basic project ! Observe Visual Basic debugging behavior for COM+ components Open the Component Services tool • On Start menu, point to Programs, then Administrative Tools, and then click Component Services Navigate to the Components folder of the Purchase Order application Right-click the POBusiness.bus_Order component and then click Properties Note the location of the DLL and then click Cancel In Visual Basic, make sure the break point you set in the previous procedure is still set Run the project and use the Web application to place an order When the code halts at the break point, switch to the Component Services tool 74 Module 3: Introduction to COM+ Select the Components folder in the Purchase Order application, and then click the Refresh button on the toolbar Right-click the POBusiness.bus_Order component, and then click Properties 10 Note the location of the POBusiness.bus_Order DLL and then click Cancel 11 In Visual Basic, stop the project A message box may appear informing you that other applications are currently accessing objects in your program Confirm that you want to end the program 12 Switch to Internet Explorer and verify that an error has occurred 13 Close Internet Explorer 14 In the Component Services tool, refresh the view of the Components folder and then view the properties of the POBusiness.bus_Order component 15 If the DLL location property has not been reset, switch to Visual Basic Recompile the DLL and confirm that the DLL property has been reset 16 Close all open applications Module 3: Introduction to COM+ 75 Best Practices ! Use apartment threading ! Use COM+ server processes to improve security and fault isolation ! Group components that share resources ! Let COM+ manage your transactions ! Compile and test COM+ DLLs outside of the Visual Basic IDE as a first debugging step ! Use the event log to help diagnose problems ! Generate and install separate type libraries When building COM+ solutions, you should observe the following best practices: ! Use apartment threading Use apartment threading when creating COM+ components (DLLs) with Visual Basic Apartment threading allows separate instances of your classes to reside in separate single-threaded apartments (STAs) in the COM+ surrogate server process As a result, separate instances can serve separate clients concurrently, thereby improving performance Avoid building COM DLLs by using the single threading model because all object instances will reside in the server process’s primary STA All requests from clients to these objects will be serialized, creating a serious performance bottleneck ! Use COM+ server processes to improve security and fault isolation A COM+ server application executes as a separate process Every process has its own security context and COM+ will perform security checks whenever a call is made to a COM object inside the process from an external client Separate processes also provide separate fault isolation boundaries A rogue component causing the termination of its host process will not affect components running in other processes ! Group components that share resources You should group components that share resources together in the same COM+ application because resource pooling is on a per-process basis By grouping components that share expensive resources such as database connections, you can improve the scalability of your application ! Let COM+ manage your transactions Do not write code to explicitly manage transactions Use the transaction support provided by COM+ You can enable component transaction support by using the Component Services Administration tool 76 Module 3: Introduction to COM+ ! Compile and test COM+ DLLs outside the Visual Basic IDE as a first debugging step Unless you are specifically debugging a known problem, you should compile and test COM+ DLLs outside the Visual Basic IDE Debugging outside Visual Basic provides "real" behavior when running live, as opposed to “emulated” behavior in the Visual Basic environment ! Use the event log to help diagnose problems COM+ and related system services such as the DTC and MSMQ use both System and Application event logs to record diagnostic information Remember to check the event logs early during problem diagnosis You should also use the event log within your own component code Logging the error code, description, and precise location of the error (function, class, and component) can be a useful debugging aid ! Generate and install separate type libraries When exporting an application proxy, the exported file contains type library information required for COM method remoting on the client (and server) computer If type libraries are contained within COM DLLs, the entire DLL must be distributed and installed on the client computer It is more efficient to install the type library in the COM+ application independent of installing the component DLL because separating type libraries from components makes it possible to install only the type library on the client computer Module 3: Introduction to COM+ 77 Review Slide Objective To reinforce module objectives by reviewing key points The review questions cover some of the key concepts taught in the module Please take a few minutes to answer the questions in your workbook, and then we will discuss them as a class Describe how COM and MTS have evolved to become COM+ ! Lead-in ! List and describe the COM+ services ! Create and add a component to a COM+ application ! Debug a COM+ component ! Deploy a COM+ application What are the two types of COM+ applications? Why would you choose one over the other? Server and Library COM+ server applications provide fault isolation and separate security contexts COM+ library applications offer a slight performance improvement because they run in the client’s process address space Library applications are useful for utility components Why can’t Visual Basic components benefit from object pooling? Object pooling requires the neutral threading model Visual Basic components only support apartment threading Why should you avoid the single threading model when developing COM+ components? The single threading model forces all object instances to run in the server process’s primary Single Threaded Apartment (STA) This restriction will cause requests from all clients to be serialized, which creates a serious performance bottleneck What is the difference between a configured and a nonconfigured component? Configured components have been added to a COM+ application, and as a result, they have an associated set of attributes maintained in the COM+ catalog 78 Module 3: Introduction to COM+ Which system component is responsible for coordinating transactions spanning multiple resource managers? The Distributed Transaction Coordinator (DTC) You design a COM+ component and set its Transaction Support option to "not supported." Later, you make changes to the component, recompile it, and now you would like this component to support transactions How you change the Transaction Support option? Open the projectname.vbp project in design view and change it directly in the properties window You must write code to provide transaction support In the Component Services tool, enable this option on the Properties page of the component What is the primary difference between a resource manager and a resource dispenser? Resource managers manage durable data, ensuring that it is not lost or corrupted in the event of a system failure Resource dispensers manage nondurable data such as database connections What will happen if you export an application while you are debugging it in Visual Basic? The VB6Debug.DLL would be the currently referenced component in the catalog and it would be exported instead of the proper component Name two key items of data contained within an application proxy The remote server name that identifies the server hosting the COM+ application, and type library information used by DCOM for calling methods remotely ... Appendix B: Working with COM Interfaces iv Module 3: Introduction to COM+ Module Strategy Use the following strategy to present this module: ! From COM to COM+ Discuss the evolution of the Component... application Module 3: Introduction to COM+ # Overview Slide Objective To provide an overview of the module topics and objectives ! ! Administering COM+ Applications ! Lab 3.1: Building a COM+ Application... the context wrapper and transparently to the client 10 Module 3: Introduction to COM+ COM+ Programming Model ! Context $ $ ! COM+ uses contexts to group together objects with the same run-time

Ngày đăng: 11/12/2013, 14:15

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan