interopbook: about the book

about the book: .net 2.0 interoperability recipes

This book is appropriate for any .NET developer who needs to interoperate between .NET code and non-.NET Windows code. You may be an experienced .NET developer who has never had the need to interoperate with native code before. Or you may be completely new to .NET and are just learning the languages and class libraries associated with .NET. In either case, this book is for you.

Most of the examples in this book are presented in both C# and Visual Basic. You will be able to understand the examples as long as you know one of these languages. But this book isn’t designed to teach you a language. Likewise, you should already be familiar with the basics of the .NET Framework Class Library (FCL). You don’t have to be a guru, but you should at least know the basics.

Since the book is all about interop with existing code, the examples also typically use one or more native Windows languages. For example, the chapters covering the use of C-style functions use examples written in native C++ code. The chapter that focuses on the use of COM components presents Visual Basic 6.0 (VB6) and C++ ATL example components that are used by .NET client code. These same native languages are later used as client code when managed classes are exposed to COM.

While unmanaged code is used extensively in the examples, it is not the primary focus of this book. So if you know VB6 but don’t know C++, that’s OK—you’ll still benefit from the examples. Most of the .NET code works the same way regardless of the unmanaged language used. If there are differences, they are noted in the examples.

Likewise, the chapters covering COM and COM+ assume that you are already familiar with these technologies. This is not a book about learning COM and COM+, but it will show you how to use COM and COM+ from .NET.

obtaining this book’s source code

When you are ready to execute the example code, you don’t have to enter it yourself. You can download all of the code presented in this book from the Apress site at; go to the Book Resources Source Code section to download the source code.

software requirements

To run the examples in this book, you need some way to build and run C# or VB.NET code. The bare minimum for this is the .NET Framework SDK and a source code editor. While this minimal setup allows you to run the example code, many of the recipes show you how to use features of Visual Studio .NET 2005 to simplify the job of interop. Therefore, use of Visual Studio .NET 2005 is highly recommended.

All of the code in this book was originally developed using beta 2 and release candidate 1 of Visual Studio .NET 2005 (or later). It was subsequently checked using the final release to manufacturing (RTM) version.

All of the C++ unmanaged code used in the examples can be built with Visual Studio .NET 2005 (or later). You don’t need the older 6.0 version of Visual C++ for this purpose. However, many of the COM examples use VB6. Since VB6 is a drastically different language than VB.NET, you’ll need VB6 to build and run those examples.

chapter overview

A brief overview of each chapter is presented here.

sample chapter

Apress has made a sample chapter of this book available for download in PDF format. You can obtain this sample chapter from the Apress page for this book.


Changes that were discovered since the initial publication can be found at the Apress site.