Home > Store

.NET and COM Interoperability Handbook, The

Register your product to gain access to bonus material or receive a coupon.

.NET and COM Interoperability Handbook, The

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 2003
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-046130-X
  • ISBN-13: 978-0-13-046130-8

.NET/COM interoperability in depth: comprehensive techniques and strategies

  • The most in-depth guide to .NET/COM interoperability ever published!
  • Covers every .NET/COM interop option, "gotcha," and workaround
  • Offers practical strategies for .NET migration and long-term .NET/COM coexistence
  • Compares .NET to COM and Java
  • Addresses many advanced issues, including Interop marshaling, Primary Interop Assemblies, using ActiveX Controls from managed code, using COM+ Services from managed code, converting your COM+ Applications to XML Web Services and .NET Remoting

The .NET and COM Interoperability Handbook will help you move your Windows(-based software into the future without abandoning the investments you've already made. Writing from the perspective of the experienced COM/COM+ developer, Alan Gordon offers the most realistic, in-depth coverage of .NET/COM interoperability ever presented. He illuminates all your .NET/COM interoperability options, offering practical advice for both migration and long-term coexistence. Coverage includes:

  • What COM/COM+ developers must know first about .NET/COM interoperability
  • Using the .NET/COM interoperability resources built into Visual Studio .NET
  • Calling COM/COM+ components from .NET
  • Calling .NET components from Win32/COM applications
  • Using COM+ Services from .NET applications
  • Turning your COM+ applications into an XML Web Service without writing any code
  • Understanding the impact of COM apartment threading on .NET performance
  • Overcoming mismatches between COM reference counting and .NET garbage collection
  • Interop marshaling, ActiveX controls, .NET remoting, and much more

Sample Content

Online Sample Chapter

Exploring the CLR

Table of Contents



Preface.


Acknowledgments.


About This Series.


1. What's in a Name?

Microsoft .NET. XML Web Services. XML. SOAP.The .NET Framework. The .NET Framework SDK. The CLR. MSIL. The .NET Framework Class Library. ADO.NET. ASP.NET. Windows Forms. Other Microsoft.NET Technologies. Stale .NET-Related Names. Comparing .NET to Java. Summary.



2. Comparing COM and .NET.

What is a Software Component? What Is a Software Bus? Life Cycle Management. Programming Language Independence. Location Transparency. Extensibility. Versioning. Summary.



3. Exploring the CLR.

Describing The CLR. Defining Managed Code and Managed Data. Types. Assemblies. MSIL. How the Runtime Locates Assemblies. Garbage Collection. Code Access Security. Summary.



4. A Quick Introduction to C#.

Getting Started with C#. Creating a Simple Hello World Application. Compiling and Linking the Hello World Application. The Basic Operators in C#. The Primitive Types Available in C#. Creating and Manipulating a String in C#. Creating and Using an Array in C#. Declaring classes in C#. Using Inheritance in C#. Flow of Control Constructs. Exception Handling in C#. Summary.



5. Using Visual Studio .NET.

Introduction. Summary.



6. An Introduction to COM Interop.

Introduction. COM Interop. Using COM Objects from .NET Clients. Using .NET Objects from COM Clients. Platform Invoke. Summary.



7. Advanced .NET to COM Interop.

Object Life Cycle Implications. Using COM Events in Managed Code. Using COM-Rich Error Information in Managed Code. Multithreading and COM Apartments. Primary Interop Assemblies. Advanced Interop Marshaling Considerations Using ActiveX Controls in Managed Code. Performance Considerations. Advanced Aspects of Pinvoke. Summary.



8. Advanced COM to .NET Interop.

Object Creation. Object Life-Cycle Implications. Overloaded Methods. COM Apartments. Using Types from the .NET Framework Class Library. Class Interfaces Revisited. Rich Error Information. Using Windows Forms Controls. ComVisible. Handling Managed Events from a COM Client. Deploying COM/Win32 Applications That Use .NET Components. Summary.



9. Using COM+ (Enterprise Services).

A Couple of Big Caveats. Creating a Serviced Component. Creating a Client. The Implementation of the Serviced Component Methods. Summary.



10. XML Web Services.

Web Services: The Big Picture. The ASP.NET Web Services Infrastructure. Creating a Simple Web Service. Creating and Consuming a Web Service with Visual Studio .NET. XML Web Services and Data. Returning Data Using a Dataset. Transactions. Summary.



11. .NET Remoting.

Why Do We Need .NET Remoting? .NET Remoting Architecture. Categories of Remotable Types. A Simple .NET Remoting Client and Server. Configuration. Code Organization. Soapsuds. Hosting Your Server in IIS. Interoperation Between COM+ and Web Services. Summary.



12. Migration and Interop Strategies.

Migration versus Interop. Vertical Migration. Horizontal Migration. Summary.



Index.

Preface

Preface

At the company for which I work we have just begun the process of planning our migration to .NET. This process has been fraught with both political and technical challenges. The purpose of this book is to help you with the technical challenges of .NET migration, in particular using COM Interop. The only help I can give you on the political challenges is: Beware of people who want to use .NET just because it's "cool", because Microsoft says you should, or to pad their resume. Also, beware of people who don't want to use .NET because of personal biases against Microsoft. Decisions about what technologies should be used should be based on business objectives first, customer satisfaction second, and ease of development and maintenance third. Other agendas must be brushed aside.

But enough about politics, this is a technical book with a target audience of intermediate to advanced COM/COM+ programmers who are looking to make the move to .NET. I assume some knowledge of COM and COM+, but I don't assume any prior knowledge of .NET. This book also functions as a .NET tutorial for COM programmers. I start from first principles defining at an advanced level all of the technologies in the .NET Framework. I have included chapters on the CLR, a one-chapter tutorial on the C# programming language, and chapters on .NET Web Services, and .NET Remoting. All of these chapters are there to provide you with the foundational knowledge that you need to understand the meat of the book, which is the "pure" Interop material in chapters 6 through 9, 11 and chapter 12. Although these only chapters make up slightly more than 40% of the chapter count of the book, they make up about two-thirds of the page count. Chapters 7 and 8, which cover advanced topics in Interop, are particularly "beefy" chapters.

My pedagogical style in writing is similar to the teaching style that I have used at UCLA Extension. My approach when teaching new concepts is as follows:

  1. Explain why it is important for the reader to learn the new concept? What problem does the new concept solve? Why should the reader care about it?
  2. Explain the concept, in theory first, using copious analogies and diagrams.
  3. Have the student use the concepts and theories they have just learned in a hands-on demonstration. The demonstration does not have to be complicated; it just has to illustrate the concept that the student is trying to learn.
  4. Summarize what the reader should have just learned.
  5. Along the way, point the reader to additional resources to consult for further information.

Most of the chapters start by explaining the problem that the .NET technology that you are about to learn about will solve. Next we discuss how this .NET-related technology works and how you will use it. You will find lots of analogies, diagrams and screen shots. Finally, in most of the chapters we will build a demonstration program. I don't think any of the demonstration programs are terribly sophisticated (they weren't meant to be). The example programs are designed to reinforce the topic in that chapter. I show you how to build the example program in enough detail that a beginning C# programmer should have no problem following along. I think you will learn the most by following along and building the example programs yourself, but if you don't want to go through the steps yourself, you can download the demonstration programs from the Web site for this book.

www.objectinnovations.com/dotnet.htm

A link is provided at that Web site for downloading the sample programs for this book.

The sample programs are provided in a self-extracting file. When expanded, a directory structure is created, rooted in c:\OI\NetCom. The sample programs are in directories Chap01, Chap02, and so on. All the samples for a given chapter are in individual folders within the chapter directories. The names of the folders are clearly identified in the text. This book is part of the Integrated .NET Series. The sample programs for other books in the series are located in their own directories underneath c:\OI, so all the .NET examples from all books in the series will be located in a common area as you install them.

All of the source code examples in this book are in C#. I agonized for a long time over which .NET language to use for my source code examples. Although the .NET framework supports a wide variety of programming languages, the two languages that will be the most widely used are C# and VB.NET. Most of the source code examples in the .NET Framework documentation are implemented in both C# and VB.NET. I have seen some .NET books take this approach. After experimenting, I realized that since both languages share a common library, and VB.NET has been endowed with first-class object-oriented capability, there are few semantic differences between C# and VB.NET. The differences between the two languages are primarily syntactic. The choice of which language to use really comes down to which syntax you are most comfortable with. I decided, therefore, that it would be a waste of time—yours and mine—for me to try to write the examples in both languages. Therefore, I chose to do everything in C#. Don't despair if you are a VB programmer; my own experience has been that it is very simple to translate .NET code from VB.NET to C#, and vice versa.

The 12 chapters in this text are divided into three sections. The first five chapters contain introductory and foundational material. Chapter 1 is an executive overview of the names in the .NET namespace. Chapter 2 compares .NET to COM. Chapter 3 explains in detail how the CLR works. Chapter 4 is an introduction to C# and in Chapter 5 you will get the opportunity to build your first .NET component. If you are already familiar with .NET, you can skip some or all of these first chapters.

The meat of the book is in chapters 6, 7, and 8. In these chapters you'll learn all about COM Interop and PInvoke, too. In Chapter 6 I cover the basics of calling unmanaged code from a .NET component or application and calling a .NET component from an unmanaged client. I also cover the basics of Pinvoke. In Chapter 7 I dive into advanced aspects of .NET to COM Interop, that is, calling COM components from managed code. In this chapter I also cover some advanced aspects of Pinvoke. In Chapter 8 I cover advanced aspects of COM/Win32 to .NET Interop, that is, calling .NET components from unmanaged code.

The last four chapters are what I like to call "special topics". In Chapter 9, I discuss serviced components, which is the name in the .NET Framework for managed components that use the COM+ Services. In Chapter 10, I discuss XML Web Services. In this chapter I will give you some tips on exposing your existing COM+ applications as XML Web Services. In Chapter 11, I discuss .NET Remoting, which you can think of as the replacement for DCOM in the .NET Framework. In this chapter I also introduce you to the COM+ Web Services feature which is available in Windows XP and Windows .NET Server. This functionality allows you to expose any COM+ application as an XML Web Service simply by checking a box. Finally, in Chapter 12, I provide some best practices for incremental migrations

.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020