Chapter 8. COM-Interop and Enterprise Services Gotchas

COM-Interop in .NET allows a .NET component to communicate with a COM component using a Runtime Callable Wrapper. It also makes it possible for unmanaged code to talk to a .NET component as if it’s a COM component by way of a COM Callable Wrapper. These facilities and the related API make it easier to interoperate. However, you need to give due consideration to the object life cycle and threading issues to get the most out of interoperability. Furthermore, the quickest way to expose a .NET object for COM interoperability is to set the project settings to Register for COM interop. While this may be the “it’s that simple” approach, you need to watch out for a number of things. In this chapter I focus on details you should be aware of to make interoperability work for you. I also delve into issues related to Enterprise Services, a set of classes that allows you to programmatically utilize the COM+ services in the .NET Framework.

I assume that you are fairly familiar with COM [Box98]. The discussions in this chapter are intended for programmers with COM knowledge (aCOMplished programmers?!) and interested in .NET to COM interoperability. The gotchas are organized as follows:

  • Gotchas 65-70 discuss issues with using COM components in .NET.

  • Gotchas 71-73 are about using .NET classes from unmanaged code through COM.

  • Gotchas 74-75 deal with Enterprise Services.

GOTCHA #65 Release of COM object is confusing

Programming with COM in C++ has ...

Get .NET Gotchas now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.