2020ok  Directory of FREE Online Books and FREE eBooks

Free eBooks > Computers & Internet > Web Development > Internet Commerce > General > NET and COM Interoperability Handbook

NET and COM Interoperability Handbook

by Alan Gordon

Download Book

If you are the author or the publisher, and would like to link to your site here, please contact us.

About Book

Book Description

This book explains the .NET Framework from the perspective of a COM/COM+ programmer. It compares COM/COM+ and .NET. It also shows readers how to use their existing COM/COM+ components from .NET and how to call .NET components from their Win32/COM applications. This is not the kind of cursory coverage of COM interoperability that is found in most .NET Framework books. The author delves deep into the subject, covering items such as the effect of the COM Apartment threading model, ActiveX controls, late binding, and the impedance mismatch between reference counting in COM and garbage collection in .NET. The book also features extensive coverage of how to use the COM+ Services from a .NET application. In the initial stages of the hype surrounding Microsoft's introduction of .NET and the .NET Framework, many people assumed that the .NET Framework was the end of COM/COM+. It turns out that quite the opposite is true. Very few companies have the luxury of halting new work for several months while they migrate all of their code to use the .NET framework. At most organizations, .NET code and COM code will need to work together (interoperate) for some time to come. Microsoft's acceptance of this reality shows in the substantial amount of effort that they have put into .NET/COM interoperability.

From the Back Cover

.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

About the Author

ALAN GORDON, Group Program Manager at FieldCentrix in Irvine, CA, is responsible for FX Service Center, an Internet-based service management and dispatch application built with ASP, COM+, and SQL Server. He is also responsible for E-Service, an ASP.NET-based product that allows field service companies to quickly enable their customers to make and track service calls on the Web.

Excerpt. © Reprinted by permission. All rights reserved.


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.


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




PLEASE READ: All comments must be approved before appearing in the thread; time and space constraints prevent all comments from appearing. We will only approve comments that are directly related to the article, use appropriate language and are not attacking the comments of others.

Message (please, no HTML tags. Web addresses will be hyperlinked):

Related Free eBooks

Related Tags

DIGG This story   Save To Google   Save To Windows Live   Save To Del.icio.us   diigo it   Save To blinklist
Save To Furl   Save To Yahoo! My Web 2.0   Save To Blogmarks   Save To Shadows   Save To stumbleupon   Save To Reddit