`
`epsonMire Veer
`
`“It took technical grace to forge a waltz between today’s COM+
`Services and tomorrow's evolved world of Next Generation
`development in C#, and this book is your dancing instructor.”
`— Michael Lane Thomas,
`.NET Series Editor
`
`Py examples and source code
`
`Zynga Ex. 1010, p. 1
`Zynga v. IGT
`IPR2022-00368
`
`
`
`C# COM+
`Programming
`
`Derek Beyer
`
`M&T Books
`An imprint of Hungry Minds,Inc.
`
`Best-Selling Books e Digital Downloads ¢ e-Books « Answer Networks e
`e-Newsletters ¢ Branded WebSites e e-Learning
`
`New York, NY e Cleveland, OH e IndianapofidWF Ex. 1010, p. 2
`Zynga v. IGT
`IPR2022-00368
`
`Zynga Ex. 1010, p. 2
`Zynga v. IGT
`IPR2022-00368
`
`
`
`General Library System
`University of Wisconsin - Madison
`(28 State Street
`Madison, WI 53706-1494
`U.S.A.
`
`C# COM+ Programming
`Published by
`.
`M&T Books
`an imprint of Hungry Minds,Inc.
`909 Third Avenue
`New York, NY 10022
`www.hungryminds.com
`Copyright © 2001 Hungry Minds,Inc. All rights
`reserved. No part of this book, including interior
`design, cover design, and icons, may be
`reproduced or transmitted in any form, by any
`means (electronic, photocopying, recording, or
`otherwise) without the prior written permission of
`the publisher.
`Library of Congress Control Number: 2001089342
`ISBN: 0-7645-4835-2
`Printed in the United States of America
`10987654321
`
`Corporation, Inc., for the Philippines; by
`Contemporanea de Ediciones for Venezuela; by
`Express Computer Distributors for the Caribbean
`and West Indies; by Micronesia Media Distributor,
`Inc. for Micrones iat by Chips Computadoras S.A.
`(
`Seo: be
`Edito
`3
`i
`de C.V. for Mexico; by Editorial Norma de
`Panama S.A. for Panama; by American Bookshops
`for Finland.
`
`For general information on Hungry Minds’
`products and services please contact our Customer
`Care department within the U.5. at 800-762-2974,
`outside the U.S, at 317-572-3993 or fax
`317-572-4002.
`
`For sales inquiries and reseller information,
`including discounts, premium and bulk quantity
`sales, and foreign-language translations, please
`contact our Customer Care departmentat
`800-434-3422, fax 317-572-4002 or write to
`Hungry Minds, Inc., Attn: Customer Care
`Department, 10475 Crosspoint Boulevard,
`Indianapolis, IN 46256.
`For information on licensing foreign or domestic
`tights, please contact our Sub-Rights Customer
`Care department at 212-884-5000.
`For information on using Hungry Minds’ products
`andservices in the classroom orfor ordering
`examination copies, please contact our
`Educational Sales department at 800-434-2086 or
`fax 317-572-4005.
`
`1B/SR/QZ/QR/IN
`Distributed in the United States by
`Hungry Minds, Inc.
`Distributed by CDG Books CanadaInc.for
`Canada; by Transworld Publishers Limited in the
`United Kingdom; by IDG Norge Books for
`Norway; by IDG Sweden Books for Sweden; by
`IDG Books Australia Publishing Corporation Pty.
`Ltd. for Australia and New Zealand; by
`TransQuest Publishers Pte Ltd. for Singapore,
`Forpress review copies, author interviews, or
`Malaysia, Thailand, Indonesia, and Hong Kong;
`other publicity information, please contact our
`by Gotop Information Inc. for Taiwan; by ICG
`Public Relations department at 317-572-3168 or
`Muse,Inc. for Japan; by Intersoft for South
`fax 317-572-4168.
`Africa; by Eyrolles for France; by Intemational
`For authorization to photocopy items for
`Thomson Publishing for Germany, Austria, and
`corporate, personal, or educational use, please
`Switzerland; by Distribuidora Cuspide for
`contact Copyright Clearance Center, 222
`Argentina; by LR International for Brazil; by
`Rosewood Drive, Danvers, MA 01923, or fax
`Galileo Libros for Chile; by Ediciones ZETA S.C.R.
`978-750-4470.
`Ltda. for Peru; by WS Computer Publishing
`
`
`LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND AUTHOR HAVE USED THEIR BEST
`EFFORTS IN PREPARING THIS BOOK. THE PUBLISHER AND AUTHOR MAKE NO REPRESENTATIONS OR
`WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOK
`AND SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
`PARTICULAR PURPOSE. THERE ARE NO WARRANTIES WHICH EXTEND BEYOND THE DESCRIPTIONS
`CONTAINED IN THIS PARAGRAPH. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES
`REPRESENTATIVES OR WRITTEN SALES MATERIALS. THE ACCURACY AND COMPLETENESS OF THE
`INFORMATION PROVIDED HEREIN AND THE OPINIONS STATED HEREIN ARE NOT GUARANTEED OR
`WARRANTED TO PRODUCE ANY PARTICULAR RESULTS, AND THE ADVICE AND STRATEGIES CONTAINED
`HEREIN MAYNOT BE SUITABLE FOR EVERY INDIVIDUAL. NEITHER THE PUBLISHER NOR AUTHOR SHALL
`BE LIABLE FOR ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING BUT NOT
`LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER DAMAGES.
`
`Trademarks: Professional Mindware is a trademark or registered trademark of Hungry Minds, Inc, All other
`trademarks are property oftheir respective owners. Hungry Minds,Inc, is not associated with any product or vendor
`mentioned in this book.
`
`. is a trademark of
`HungryMinds- Hungry Minds, Inc.
`
`oh
`
`is a trademark of
`ob.
`&e? HungryMinds, Inc.
`
`.)0°
`
`Zynga Ex. 1010, p. 3
`Zynga v. IGT
`IPR2022-00368
`
`Zynga Ex. 1010, p. 3
`Zynga v. IGT
`IPR2022-00368
`
`
`
`General Library System
`University of Wisconsin - Madison
`728 State Street
`Madison, WI 53706-1494
`U.S.A.
`
`Zynga Ex. 1010, p. 4
`Zynga v. IGT
`IPR2022-00368
`
`Zynga Ex. 1010, p. 4
`Zynga v. IGT
`IPR2022-00368
`
`
`
`
`Se—————_——————__
`
`
`b89074857913a
`HILO
`
` |
`
`
`
`UL DISK()
`ENCLOSED
`
`w
`
`89074857913
`
`Your Complete Guide to COM+ Servicesit
`Whether you wantto integrate existing COM+ servicesinto the .NET Framework or
`create all-new NET COM+ servicesusing C#, this unique guide shows you the way.
`With lucid explanations and a generous helping of sample components and source
`code, COM+ expert Derek Beyer shows you step by step how to consume COM
`components from .NET, consume .NET components from COM,and create .NETCOM+
`componentsfortransactions, security, events, object pooling, queuing, and remoting.
`
`sad Map toCOM+ and .NET Integration
`
`* Understand the .NET Frarnework and Common Language Runtime
`
`* Convert COM typelibraries into NET namespaces
`* Transform .NET assemblies into COM typelibraries
`¢ HarnessJIT activation, synchronization, and AutoCompletein a transaction
`component
`* Create a role-based security component
`* \Write a loosely coupled events componentandcreate subscriptions with
`COM+ Explorer
`* Learn the ins and outs of object pooling, from attributes to scalability
`* Get the scoop on MSMQ,exceptions error handling, and other queuing issues
`¢ Use SOAP, channels, formatters, proxies, and other tools to create remoting
`serviced components
`
`a) SOURCE CODE ON
`CD-ROM~.examplesfor
`
`developing COM+ components
`in C# including:
`* Queued component
`» Remote component
`* Pooled component
`* Event-driven component
`* Role-based security component,
`and
`‘» C# transactional componentand
`client application
`
`System Requirements:
`PC running Windows. See the
`“What's on the CD-ROM" Appendix
`for further requirements and details.
`
`NDWARE*
`ONAL
`PROFESS&S
`
` nermediat to Advanced
`$39.99 US
`$59.99 CN
`£29.99 UK incl. VAT ieee
`
`ml
`
`ISBN O-7645-4845-ce
`53999
`
`||
`
`780764'5484ynua V.|
`IPR2022-
`
`
`Wwww.omanatbooks.
`
`Zynga Ex. 1010, p. 5
`Zynga v. IGT
`IPR2022-00368
`
`
`
`Contents at a Glance
`
`PLeFACE een crsveisiersiarereeertanaielee eveleta ws EM a Ba ix
`
`Acknowledgments. ........0...0000 cece cues xiii
`
`Part 1
`Interoperating with COM
`
`
`Chapter 1
`Chapter 2
`Chapter 3
`
`Understanding .NET Architecture .............. 3
`Consuming COM Components from .NET ........ 21
`Consuming .NET Components from COM ........ 33
`
`Part Il
`COM+ Core Services
`
`
`Chapter 4
`Chapter 5
`Chapter 6
`Chapter 7
`Chapter 8
`
`Transactions ........ 0.00. c cece ence eevee 47
`Security 2... eee eee eee eas 65
`Events 2... 0. 0c cece cece eee eee eee eens 83
`Object Pooling ....... 0.0... ccc eee ee ee eee 101
`Queued Components ...........0..0 ccc aees 121
`
`Part Ill
`Advanced COM+ Computing
`
`
`Chapter 9
`Chapter 10
`
`Remoting ....... 20.0... e cee cece cease 155
`The Future of COM+ and .NET.............0. 185
`
`Appendix A: What’s on the CD-ROM? ......... 209
`
`Appendix B: The COM+ Shared Property Manager 215
`
`Appendix C: Introduction to C#.............. 233
`
`Appendix D: Compensating Resource Managers .
`
`. 259
`
`Index... ccc ee eee tenes 273
`
`Hungry Minds, Inc. End-User License Agreement . 288
`
`Zynga Ex. 1010, p. 6
`Zynga v. IGT
`IPR2022-00368
`
`Zynga Ex. 1010, p. 6
`Zynga v. IGT
`IPR2022-00368
`
`
`
`Zynga Ex. 1010, p. 7
`Zynga v. IGT
`IPR2022-00368
`
`
`
`This material may be protected by Copyright law (Title 17 U.S. Code)
`
`
`
`88
`Part 11: COM+ Core Services
`
` = ==
`
`
`COM+ Runtime
`
`
`
`Publisher,
`
`|
`
`
`
`
`
`2. COM+ queries catalog™ ‘
`for thelist of subscribers to
`this event class
`
`*
`
`L
`
`1. Publisher creates a new
`_
`instanceofeventclass
`mo
`{
`'\
`on
`f
`iber
`-|}——————>{_ }——_ Event Class =. 4 a
`—
`—
`Class
`To
`Se
`os
`Subscriber
`he Class
`
`oo
`Subscriber
`oo
`<4 Class
`
`|
`
`|
`
`|
`
`3. COM+instantiates new
`instancesofall subscribers and
`Ne calls the corresponding method
`
`COM+ Catalog
`
`q
`
`|
`
`
`
`Figure 6-1: Publisher to subscriber call chain
`
`As a rule of thumb, publishers cannot determine the order in which subscribers
`are notified about an event. The COM+ event system makes this determination.
`Later in this chapter, you see a couple of techniques for influencing the order in
`which subscribers are notified.
`Subscribers need to implement the method(s) the publisher calls on the event
`class in order for all of this to work. The event class does not need to implement the
`methods to which subscribers choose to subscribe. In fact, even if the methods are
`implemented, they are not called when the publisherinitiates the event. Although
`the publisher thinks it has a simple reference to an eventclass, it is talking to the
`COM+ event system, which, in turn, is making calls to subscribers.
`For a subscriber to subscribe to an eventclass’s events (methods), it must imple-
`ment the interface(s) the event class supports. The subscriber does not need to
`implementall the interfaces of the event class, only interfaces that contain methods
`from which the subscriber wishes to receive events. Interface identifiers of the sub-
`scriber and event class (GUIDs) mustalso be the identical to each other.
`Event classes must meet certain criteria to work properly in the LCE system. One
`of the criteria is that the class cannot contain implementations of any of its meth-
`ods. An eventclass’s methods must not contain any output parameters if the event
`class is to have more than one subscriber. In other words, the event class cannot
`contain methods that return a value to the publisher as a parameter. If you think
`about it, this rule makes sense for two reasons. First, if there are multiple sub-
`scribers, each of whom changesthe value of the output parameterbefore it reaches
`the publisher, how does the publisher know if the returned value is correct? The
`publisher cannot know this. Second, if the publisher does not need to know about
`its subscribers, it does not necessarily care about actions or return values sub-
`scribers take.
`An event class must return only success or failure COM HRESULTs. This is not
`something you needto be terribly concerned about if your application runsentirely
`Zynga Ex. 1010, p. 8
`Zyngav. IGT
`IPR2022-00368
`
`Zynga Ex. 1010, p. 8
`Zynga v. IGT
`IPR2022-00368
`
`
`
`Chapter 6: Events
`
`89
`
`in managed code. However, you want to know this if you are writing managed
`event classes unmanaged subscribers use.
`
`Understanding Subscriptions
`COM+ supports two types of subscriptions: persistent and transient. Persistent sub-
`scriptions remain in the COM+ catalog until they are physically taken out. These
`types of subscriptions must be added via the ComponentServices Explorer snap-in
`for both managed and unmanaged code. The .NET Framework does not provide
`attributes for adding subscriptions to the COM+ catalog.
`
`
`
`The COM+ Administration API is COM based and supports programmatic
`administration of the COM+ catalog. All of the functionality (and much
`more) of the ComponentServices snap-in can be reproduced through the
`Admin API.
`
`Transient subscriptions, on the other hand, exist only within the lifetime of the
`subscriber component. Transient subscriptions cannot survive a restart of the
`COM+ event system or a reboot of the machine they are running on. They must be
`added at runtime by using the COM+ Admin API. Unlike persistent subscriptions,
`which instantiate a new instance of the subscriber, transient subscriptions are
`added by making a reference to an already instantiated component in the COM+
`catalog.
`Be aware of one other type of subscription. Per User subscriptions allow you to
`create a subscription when a user logs on to the system. When the user logs off,
`these subscriptions are disabled. These types of subscriptions work only when the
`publisher and the subscriber are on the same computer.
`
`COM+ Attributes
`
`The COM+ attributes for a LCE component application really center on the event
`class. Subscribers and publishers (if the publisher is a COM+ component) do not
`need event-specific attributes set in order for the event system to work. You exam-
`ine the eventattributes and their values in this section; in the last part of the chap-
`ter, you see how these attributes are implemented in the .NET Framework. The
`COM+ event attributes are as follows:
`
`@ Fire in Parallel
`
`@ Allow in-process subscribers
`
`@ Publisher ID
`
`Zynga Ex. 1010, p. 9
`Zynga v. IGT
`IPR2022-00368
`
`Zynga Ex. 1010, p. 9
`Zynga v. IGT
`IPR2022-00368
`
`
`
`Part 11: COM+ Core Services
`
`FIRE IN PARALLEL
`TheFire in Parallel attribute affects the way in which the event system notifies sub-
`scribers. Figure 6-2 shows this attribute as checked in the Advanced tab in
`Component Services Explorer. With this attributed checked, COM+ notifies sub-
`scribers at the sametime. Normally, the event system notifies subscribers in a serial
`fashion. By default, this attribute is not checked.
`
`
`
`
`
`MyEvents. MyEventClass Properties
`
`General | Transactions || Securty | Activation | Concistency Advanced |
`
`Queuing exception clare:
`
`
`
`eees
`» 1 Fre in paratel
`¥ Allow in-process subscribers
`|——=
`| Publcher 10:
`|ePubld
`-_-
`-
`
`
`
`
`
`
`
`
`a SS
`
`||
`
`
`Figure 6-2: Fire in Parallel attribute in ComponentServices Explorer
`
`This attribute can have a positive effect on the performance of your application
`because COM+initiates multiple threads to notify subscribers. If this attribute is not
`checked, the event system notifies subscribers one by one, and it waits for each
`subscriber to return before calling the next.
`
`ALLOW IN-PROCESS SUBSCRIBERS
`By default, the Allow in-process attribute is selected. When this attribute is turned
`off, COM+ does not allow subscribers to run in the same address space of the pub-
`lisher. Even if the subscriber is configured as a library package, COM+ creates a
`new process for the subscriber. The reason for this default behavior stems from
`security concerns. Because the publisher does not necessarily know about sub-
`scribers, it cannot trust subscribers to behave properly inside its process. If, how-
`ever, you are writing a publisher application and you feel you can trust the
`subscribers of your event class, you can enable the Allow in-process subscribers
`attribute. By checking this option, you are trading stability for performance. This
`attribute setting can be found on the Advanced tab of the event class’s properties.
`Refer to Figure 6-2 to see this attribute in Component Services Explorer.
`
`Zynga Ex. 1010, p. 10
`Zyngav. IGT
`IPR2022-00368
`
`Zynga Ex. 1010, p. 10
`Zynga v. IGT
`IPR2022-00368
`
`
`
`
`
`Chapter 6: Events 91
`
`PUBLISHER ID
`The PublisherID attribute (also visible from Figure 6-2) provides another way for a
`subscriber to subscribe to an event class. You have explored one way for a sub-
`scriber to subscribe to an event: the CLSID ofthe event class. Publisher ID allows
`you to use a more user-friendly method for creating a subscription. Understand that
`this attribute applies to the event class, not the publisher. The name can bealittle
`misleading, so do not get confused.
`
`Controlling Subscriber Notification Order
`COM+ provides two methods that allow you to influence the order in which sub-
`scribers are notified of events: publisher filtering and parameterfiltering. Publisher
`filtering is a bit more complicated to implement than parameter filtering, butit
`allows for a finer degree of control.
`
`PUBLISHER FILTERING
`Publisher filtering is a technique that allows publishers to specify a filter compo-
`nent that should be used when eventsare triggered. Thefilter component is respon-
`sible for making decisions about which subscribers should be notified about an
`event and in what order they should be notified.
`The publisher uses the COM+ Admin API to set the PublisherFilterCLSID
`property for an eventclass. This is a read/write property that accepts the CLSID of
`the filter component. Thefilter is simply another COM+ component that imple-
`ments either the IMultiPublisherFilter interface or the IPublisherFilter
`interface.
`the
`system looks at
`the event
`instantiated,
`is
`class
`When the event
`PublisherFilterCLSID property and instantiates the corresponding filter compo-
`nent. When the publisher fires the event on the eventclass, the event system passes
`control to the filter object. The filter object’s responsibility is to forward events to
`subscribers. The filter component accomplishes this by retrieving a collection of
`subscribers and firing the event on each subscriber. The filter component, of course,
`can elect not to fire an event for a particular subscriber. Whenthe filter component
`fires an event, the event system takes over andinitiates the event on subscribers.
`
`PARAMETERFILTERING
`Parameterfiltering can be used in conjunction with publisherfiltering, or it can be
`used by itself. The subscriber component, as opposed to the publisher, implements
`this technique. Through an option in the subscription properties, the subscriber can
`define criteria that can influence whether the event system fires a method.
`Figure 6-3 shows the properties dialog box for a subscription for a subscriber
`component. TheFilter Criteria dialog box on the Options tab defines the parameter
`filter for the subscription. This particular parameterfilter defines a rule that enables
`the subscription if the parameter named Symbo] equals “MSFT” and the parameter
`Price does not equal 60. If the condition defined in thefilter criteria evaluates as
`true, the event is processed for that subscriber. In addition, if you define a fytera Ex. 1010, p. 11
`
`Zynga v. IGT
`IPR2022-00368
`
`Zynga Ex. 1010, p. 11
`Zynga v. IGT
`IPR2022-00368
`
`
`
`Part 11: COM+ Core Services
`
`criteria and your subscription is for all methods of that interface, the criteria are
`applied to all methods. For example, if you define a parameter called Symbol and
`that parameter is not found in one ofthe interface’s methods, your event fails. You
`see how this works in the last section of this chapter.
`
`jSymbotee'M SFT" ANDPrice!=@2)
`
`Figure 6-3: Filter Criteria dialog box for a subscription
`
`The operators for thecriteria string are rather simplistic. The operators include
`equality symbols andlogical operators such as AND, OR, and NOT. If you need a more
`sophisticated strategy, you should consider using publisherfiltering.
`Parameter filtering does not have a direct effect on the order in which sub-
`scribers are notified. Parameter filtering can be used to determineif an eventfires
`for a particular subscription based on the values of parameters at runtime. This
`technique can havetheside effect of determining which publishers get notified and
`possibly in which order.
`
`Writing LCE Components in C#
`
`In thelast part of this chapter, you see how to write different event and subscriber
`classes. The first set of classes is an introduction to writing components that use
`LCE. This example consists of a subscriber component that uses a static subscrip-
`tion to the event class. The second and third examples use some of the other fea-
`tures of COM+, namely object pooling and transactions. For each of the examples,
`a C# console application is the publisher.
`
`Zynga Ex. 1010, p. 12
`Zyngav. IGT
`IPR2022-00368
`
`Zynga Ex. 1010, p. 12
`Zynga v. IGT
`IPR2022-00368
`
`
`
`Chapter 9
`
`Remoting
`
`IN THIS CHAPTER
`
`_ @ The .NET Remoting Framework
`
`@ Introduction to SOAP
`
`@ Remoting ServicedComponents
`
`REMOTING INVOLVES TWO APPLICATIONS talking to each other across a network or some
`other boundary. Prior to using .NET, developers used remoting architectures such as
`DCOM. DCOM enabled developers to call other COM components across the net-
`work or across a Win32 process boundary. Generally, this worked fine if developers
`were makingcalls inside their Intranets. However, as the Internet gained popularity,
`weaknesses appeared in the DCOM computing model. Often, when an Internet appli-
`cation using DCOM needed to makecalls across the Internet, it had to go through
`firewalls, proxy servers, or routers performing Network Address Translation (NAT).
`All of this added up to a veritable minefield for DCOM applications.
`One of the more recent evolutions in remoting is Simple Object Access Protocol
`(SOAP). SOAP is a wire protocol that allows you to send and receive methodcalls
`across the network. SOAP uses XML to encode method calls and HTTP to transport
`those calls to their destinations. SOAP solves manyof the problems that arise when
`DCOMis used for Internet applications. Because SOAP uses HTTP, SOAP method
`calls and normal HTTP requests from a Web browser look virtually the same to a
`firewall or proxy server.
`Nearly seamlessly, the .NET Remoting Framework supports SOAP. In addition,it
`supports remoting by using other transports and encoders, such as TCP/IP and
`binary encoders (also called formatters). The beauty of the .NET Remoting
`Frameworkis that it allows you to mix and match transport protocols and format-
`ters. You can also develop your ownclasses to handle the networking and format-
`ting of methodcalls.
`You may be wondering what .NET remoting has to do with COM+-.It just so hap-
`pens that all classes derived from ServicedComponent can be plugged into the
`.NET Remoting Framework. All ServicedComponent-derived classes inherit from
`System. ContextBound0bject, which inherits from System.MarhsalByRefObject.
`ContextBound0bject
`and MarshalByRefObject
`ensure
`that
`a_
`derived
`ServicedComponent is transported safely across a network or application-domain
`boundary.
`
`155
`Zynga Ex. 1010,p. 13
`Zynga v. IGT
`IPR2022-00368
`
`Zynga Ex. 1010, p. 13
`Zynga v. IGT
`IPR2022-00368
`
`