Com, Dcom, Com+
Com, Dcom, Com+
Com, Dcom, Com+
indigoo.com
COM, DCOM,
COM+
OVERVIEW OF MICROSOFTS COM, DCOM AND
COM+ COMPONENT TECHNOLOGIES
Peter R. Egli
INDIGOO.COM
1/20
Rev. 1.60
indigoo.com
Contents
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
Evolution of COM
COM, DCOM, ActiveX, OLE, COM+
Structure of COM Components
(D)COM IUnknown Interface
Component Lookup and Access
Microsoft IDL File
Execution / Access Models
DCOM Architecture
COM/DCOM/COM+ Tools
Access (D)COM Objects from .Net (COM-.Net Interop)
COM+ Applications
Creation of COM Projects in Visual Studio
Limitations of COM
2/20
Rev. 1.60
indigoo.com
1. Evolution of COM
Over time Microsoft enhanced and rebranded the
different object and integration technologies.
.Net is a technological break because it
is an entirely new technology.
COM+
MTS
ActiveX
Microsoft Transaction
Server.
Runs on top of
COM/DCOM, but is not really
integrated with these
technologies.
Introduced transaction
management, component
deployment and other
services.
DCOM
COM
OLE
DDE
1987
1990
1993
1995
1996
1998
2000
3/20
Rev. 1.60
indigoo.com
ActiveX/OLE uses COM as the underpinning. ActiveX / OLE provide additional services like
reusable / programmable controls (OCX OLE Control Extensions), automation access
between office documents and in-process activation.
COM+ is the successor to the MTS/COM combo and provides a unified distributed
component/object technology including the transaction services of MTS.
COM+ uses the COM component specification and adds additional component services.
Server
Client
MTS
MTS
ActiveX / OLE
ActiveX / OLE
DCOM
COM+
COM
COM
MS RPC
MS RPC
COM+
4/20
Rev. 1.60
indigoo.com
Notation:
IUnknown
uuid: 8DA10...124BC
IViewer
uuid: A42B8...791BA
COM Object
(CoViewer)
IDAO
IPersist
COM Object
(CoDAO)
COM Object
Client
uuid: 71AA0...25A4C
IUnknown
uuid: 09B4C... 4A746
Reference
Type
library
uuid: FD4AD...4255B
5/20
Rev. 1.60
indigoo.com
IUnknown
IViewer
Component
(DLL or exe)
QueryInterface()
AddRef()
Release()
COM Object
(CoViewer)
IDAO
IUnknown
COM Object
(CoDAO)
IPersist
6/20
Rev. 1.60
indigoo.com
Server type, here an inproc object (object is loaded into the clients process).
Alternative: LocalServer32 object running in an executable.
7/20
Rev. 1.60
indigoo.com
Server
Component
Client
application
5. Call on COM
object
Ixyz
COM Object
4. SCM passes
reference to
client
SCM
2. Lookup
in registry
3. SCM instantiates
COM object
Registry
8/20
Rev. 1.60
indigoo.com
Source: http://msdn.microsoft.com/de-ch/magazine/cc188708(en-us).aspx
9/20
Rev. 1.60
indigoo.com
COMHelloWorld.idl
object,
uuid(FD4ADCD2-C7FC-466E-AD75-EBC03024255B),
dual,
nonextensible,
helpstring("ICOMHelloWorld Interface"),
pointer_default(unique)
]
interface ICOMHelloWorld : IDispatch{
[id(1), helpstring("method ShowMessage")] HRESULT ShowMessage(void);
[id(2), helpstring("method ShowMessageWithParam")] HRESULT ShowMessageWithParam([in] BSTR message);
};
...
MIDL.exe
HelloWorld.h
...
public:
STDMETHOD(ShowMessage)(void);
public:
STDMETHOD(ShowMessageWithParam)(BSTR message);
};
...
HelloWorld.cpp
COMHelloWorld.h
COMHelloWorld.cpp
10/20
Rev. 1.60
indigoo.com
Client machine
COM
COM Object
Stub
Local
server
Client
RPC
Local proxy
Remote
server
COM Object
COM
Remote machine
Remote
proxy
Client process
COM
Stub
RPC
COM Object
11/20
Rev. 1.60
indigoo.com
8. DCOM Architecture
Client proxy:
Stub:
Registry:
SCM:
Client
COM Object
Server
Client
component
library
Interface
proxy
COM Object
Interface
stub
SCM
SCM
RPC
RPC
Actual access to
remote object is done
through RPC
Server
component
Registry
indigoo.com
13/20
Rev. 1.60
indigoo.com
.Net object lifetime is managed by garbage collector (COM: lifecycle controlled by client).
.Net clients have far greater introspection possibilities through reflection.
.Net objects reside in a managed environment (managed code).
The .Net environment (CLR: Common Language Runtime) provides wrappers for COM-.Net interoperability:
COM.Net:
COM callable wrapper CCW .
.NetCOM:
Runtime Callable Wrapper (RCW).
The wrappers are contained in DLLs called Interop.xxx.
Tasks of wrappers:
Marshalling of parameters (e.g. MFC-type BSTR .Net string)
RCW: COM object reference counting (RCW); decreases reference count on COM object if object is no
longer needed on .Net managed side.
.Net object reference release (CCW); map COM-side Release() call to .Net managed object release
COM
.Net
Source: http://msdn.microsoft.com/en-us/library/5dxz80y2.aspx
Peter R. Egli 2015
14/20
Rev. 1.60
indigoo.com
COM components
of COM+ Utilities COM+
application
15/20
Rev. 1.60
indigoo.com
16/20
Rev. 1.60
indigoo.com
17/20
Rev. 1.60
indigoo.com
18/20
Rev. 1.60
indigoo.com
Coclass name
Object ProgID
Peter R. Egli 2015
19/20
Rev. 1.60
indigoo.com
20/20
Rev. 1.60