Using COM+ Services
I hesitate to write this section because many things are going to change down the road with respect to using .NET assemblies in COM+ applications. However, for the sake of completion, let’s talk about how to add a .NET class to a COM+ application as of Beta 1.
In the future, the MTS (now COM+) team will migrate all the COM+
services to work seamlessly with all the .NET architecture. For now,
we must use a few COM interop tricks. In essence, the interaction
occurs through the same mechanism explained earlier, by which you
must make your .NET class look like a COM class by adding information
to the registry and using MSCorEE.dll
as the COM
server wrapper for your assembly. However, we must also add
information to the COM+ catalog. Microsoft provides another tool
called RegSvcs.exe
that does the job of RegAsm
with the /tlb
command-line switch, plus adds
information about the class to the catalog. In addition,
RegSvcs.exe
is able to interpret certain
attributes from the assembly, which enables you to set the
declarative attributes in COM+.
For Beta 1, if you want a .NET class to work with COM+ services, you
must derive the class from System.ServicedComponent. Because RegSvcs
is going to generate COM information for the registry, you should
also manage the IIDs and CLSIDs with attributes. For example, the
following VB.NET code shows an interface named
IAccount
implemented in a Checking class:
<Assembly: System.Runtime.InteropServices.GuidAttribute("1D1D3D4C-52BE-46de-9100- ...
Get COM+ Programming with Visual Basic 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.