SlideShare uma empresa Scribd logo
1 de 20
Baixar para ler offline
© Peter R. Egli 2015
1/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
Peter R. Egli
INDIGOO.COM
OVERVIEW OF MICROSOFTS COM, DCOM AND
COM+ COMPONENT TECHNOLOGIES
COM, DCOM,
COM+
© Peter R. Egli 2015
2/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
Contents
1. Evolution of COM
2. COM, DCOM, ActiveX, OLE, COM+
3. Structure of COM Components
4. (D)COM IUnknown Interface
5. Component Lookup and Access
6. Microsoft IDL File
7. Execution / Access Models
8. DCOM Architecture
9. COM/DCOM/COM+ Tools
10. Access (D)COM Objects from .Net (COM-.Net Interop)
11. COM+ Applications
12. Creation of COM Projects in Visual Studio
13. Limitations of COM
© Peter R. Egli 2015
3/20
Rev. 1.60
COM – DCOM - COM+ 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.
DDE
1987
Dynamic Data Exchange.
 One of the first inter-process
communication means in Windows
Technology for compound
documents (e.g. Word document
with embedded Excel
document).
OLE
1990 1993 1995 1996 1998 2000
COM
DCOM
ActiveX
MTS
COM+Object Linking and Embedding.
 Based on DDE.
 Technology for embedding and
linking of documents in other
documents.
Component Object Model.
 Object technology
confined to single machines.
Distributed COM (COM over
RPC).
 Technology with
remotable objects.
 Microsoft‘s answer to
CORBA.
 Renamed part of OLE
related to networking.
 The parts of OLE relating
to compound documents
remained OLE.
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.
 Fusing of COM/DCOM and
MTS plus additional
services.
 Uses COM as object
technology.
© Peter R. Egli 2015
4/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
2. What are COM, DCOM, ActiveX, OLE, COM+ ?
COM is Microsofts object / component technology.
DCOM = remote access to COM objects / components (wire protocol = MSRPC which is a
version of DCE RPC).
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.
COM
ActiveX / OLE
MS RPC
MTS
COM+ COM
ActiveX / OLE
MS RPC
MTS
COM+
Client Server
DCOM
© Peter R. Egli 2015
5/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
3. Structure of COM Components
Relationship of objects, components, interfaces, classes, applications:
• A COM component contains 1..* objects.
• A COM component exists either as DLL (linked to the calling client, in-process) or as a
separately running executable (out-of-process server).
• A COM object implements 1..* interfaces which are defined in the IDL-file.
• All objects (classes) of a component make up a type library.
• Every object has an IUnknown interface (see below).
• Component type library, every interface and every class / object has a globally unique ID
(GUID, uuid).
COM Object
(CoDAO)
IUnknown
IDAO
IPersist
Component (DLL or exe)
COM Object
(CoViewer)
IUnknown
IViewer
uuid: FD4AD...4255B
uuid: A42B8...791BA uuid: 71AA0...25A4C
uuid: 09B4C... 4A746
uuid: 26B4D... D3C86
uuid: 8DA10...124BC
Type
library
Notation:
Client
Reference COM Object
Lollipop = (provided) interface.
Arrow = call of a method of on the
interface
© Peter R. Egli 2015
6/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
4. (D)COM IUnknown Interface
Every COM object has an IUnknown interface.
The IUnknown interface is used for:
a. Introspection / reflection:
Method QueryInterface() allows to dynamically discover other interfaces of an object (check
if an object supports a specific interface identified by an interface ID).
b. Life-cycle control / garbage collection (GC):
AddRef()  Client increases reference count.
Release()  Client releases its reference thus decrementing the reference count.
GC collects object once the reference count becomes 0.
COM Object
(CoViewer)
IUnknown
IViewer
COM Object
(CoDAO)
IUnknown
IDAO
IPersist
Component
(DLL or exe)
QueryInterface()
AddRef()
Release()
© Peter R. Egli 2015
7/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
5. Component Lookup and Access (1/3)
Objects are registered in the registry under HKEY_CLASSES_ROOT/CLSID.
Every object and interface has a registry entry.
The registry is consulted for locating (lookup) objects based on a ProgID (mapping of
GUID/uuid to implementation).
Location of server DLL containing the object class
Server type, here an inproc object (object is loaded into the client‘s process).
Alternative: LocalServer32 object running in an executable.
ProgID containing the version
Example „COMHelloWorld.COMHelloWorld.1“
ProgID without version
„COMHelloWorld.COMHelloWorld“
© Peter R. Egli 2015
8/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
5. Component Lookup and Access (2/3)
Clients contact the SCM (Service Control Manager) in order to obtain an object reference.
In case of remote objects (DCOM), the local SCM contacts the remote SCM.
Client
application
Server
Component
SCM
COM Object
Ixyz
1. Request with CLSID
(GUID, uuid)
Registry
2. Lookup
in registry
3. SCM instantiates
COM object
4. SCM passes
reference to
client
5. Call on COM
object
© Peter R. Egli 2015
9/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
5. Component Lookup and Access (3/3)
Problem of registry-based component lookup:
DLL-hell (different applications requiring different and possibly incompatible versions of
COM-libraries).
Solution:
Registry free creation of objects (requires Windows XP or higher). Also called „isolated COM“.
• Different applications may use different versions of COM-components.
• COM-components no longer need to be registered but may be deployed with XCOPY-
deployment (simple copying of components without creating registry entries by an installer).
• Component is described in a manifest file which is used by the calling application to load
and create the component.
Visual Studio settings (create manifest file as part of build):
Source: http://msdn.microsoft.com/de-ch/magazine/cc188708(en-us).aspx
© Peter R. Egli 2015
10/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
HelloWorld.cpp
6. Microsoft IDL File
IDL-files for COM use the MIDL-format (Microsoft IDL).
IDL files are compiled with MIDL.exe (automatically in Visual Studio ATL-project).
MIDL.exe
...
[
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);
};
...
COMHelloWorld.idl
...
public:
STDMETHOD(ShowMessage)(void);
public:
STDMETHOD(ShowMessageWithParam)(BSTR message);
};
...
HelloWorld.h
COMHelloWorld.h COMHelloWorld.cpp
© Peter R. Egli 2015
11/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
7. Execution / Access Models
In-proc access: Component resides in a DLL.
The client loads the component into its process.
Local server: Component resides in an executable and runs in its own process on the
local machine. Access through RPC.
Remote server: Component resides in an executable and runs on a remote machine.
Access through RPC.
COM Object
Client
COM
Local proxy
Remote
proxy
Client process
Client machine
COM
Stub
COM Object
RPC
Remote machine
COM
Stub
RPC
COM Object
In-process
access
Local
server
Remote
server
© Peter R. Egli 2015
12/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
8. DCOM Architecture
Client proxy: Proxy object on client side for accessing the server object.
Stub: Server interface stub that complements the client interface proxy.
Registry: Contains a list of mappings of class / object GUID to implementation library.
SCM: Service Control Manager (RPCSS.exe) which consults registry and creates /
instantiates a new server object based on the GUID (comparable to ORB in CORBA).
The SCM hides the registry from (D)COM.
COM Object
Interface
stub
SCM
COM Object
Interface
proxy
SCM Registry
Client Server
RPC RPC
Interface on SCM for
remote activation:
IRemoteActivation::
RemoteActivation
Client
component
library
Server
component
Actual access to
remote object is done
through RPC
ORB: Object Request Broker
© Peter R. Egli 2015
13/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
9. COM / DCOM / COM+ Tools
Register COM component:
regsvr32 <COM-lib>.dll
Registry of objects:
Windows registry (edit with regedit.exe or regedt32.exe)
Component service explorer:
Control Panel  Administrative Tools
 Component Services
or simply start dcomcnfg.exe
© Peter R. Egli 2015
14/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
10. Access (D)COM Objects from .Net (COM-.Net Interop)
.Net introduced an entirely new object model:
• .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 .
.NetCOM: 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
Source: http://msdn.microsoft.com/en-us/library/5dxz80y2.aspx
COM .Net
© Peter R. Egli 2015
15/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
11. COM+ Applications
COM+ applications host (contain) 1..n COM-components.
Dcomcnfg.exe shows a list of active COM+ applications.
COM components
of „COM+ Utilities“ COM+
application
© Peter R. Egli 2015
16/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
12. Creation of COM Projects in Visual Studio (1/4)
1. Create Visual Studio ATL C++ project with the following settings:
2. Add a new class to the COM component:
© Peter R. Egli 2015
17/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
12. Creation of COM Projects in Visual Studio (2/4)
3. ATL Simple Object Wizard:
Set names (Class, Coclass and Interface names may be different):
4. Add method to interface (e.g. ShowMessage()):
© Peter R. Egli 2015
18/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
12. Creation of COM Projects in Visual Studio (3/4)
5. Implement interface method (ShowMessage()):
Add user code to implementation of method in implementation class (HelloWorld.cpp):
STDMETHODIMP CHelloWorld::ShowMessage(void)
{
::MessageBox(::GetActiveWindow( ),_T("Hello World from COMHelloWorld."),
_T("First COM+ Application"),MB_OK);
return S_OK;
}
6. Compile ATL COM project
7. Register COM:
Open command shell, change to debug directory of COM project.
>regsvr32.exe COMHelloWorld.dll
8. Create client, e.g. in Excel-VBA:
Create new Excel file
ToolsMacroVisual Basic Editor
Add reference to COM component (ToolsReferences):
© Peter R. Egli 2015
19/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
12. Creation of COM Projects in Visual Studio (4/4)
9. Access the COM component from VBA code:
'TestHelloClient_TLB accesses the COM component using the COM type library (TLB)
'that has to be added to this project in the references (Menu Tools->References)
Sub TestHelloWorldClient_TLB()
Dim hw As COMHelloWorld
Dim gw As COMGoodbyeWorld
Set hw = New COMHelloWorld
hw.ShowMessage
Set gw = New COMGoodbyeWorld
gw.ShowMessage
End Sub
'TestHelloWorldClient_ProgID access the COM component using the ProgID
Sub TestHelloWorldClient_ProgID()
Dim obj As Object
Set obj = CreateObject("COMHelloWorld.COMHelloWorld")
obj.ShowMessage
Set obj = CreateObject("COMHelloWorld.COMGoodbyeWorld")
obj.ShowMessage
End Sub
ATL project name Coclass name
Object ProgID
© Peter R. Egli 2015
20/20
Rev. 1.60
COM – DCOM - COM+ indigoo.com
13. Limitations of COM
COM is still widely used by many applications to provide programmatic access for automation
purposes.
However, due to many technological limitations (see below) COM was technologically
superseded by .Net.
No true inheritance (may be emulated with aggregation and containment).
No exceptions (only return codes).
Inconsistent use of IDL (COM uses IDL, but VB or scripting languages like VBA use binary
representation (type library)).
No OO-features (static modifier, virtual functions, overloaded methods).

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Ppt 11 - netopeer
Ppt   11 - netopeerPpt   11 - netopeer
Ppt 11 - netopeer
 
Cs6703 grid and cloud computing unit 3
Cs6703 grid and cloud computing unit 3Cs6703 grid and cloud computing unit 3
Cs6703 grid and cloud computing unit 3
 
6 two phasecommit
6 two phasecommit6 two phasecommit
6 two phasecommit
 
Lamport’s algorithm for mutual exclusion
Lamport’s algorithm for mutual exclusionLamport’s algorithm for mutual exclusion
Lamport’s algorithm for mutual exclusion
 
Locks In Disributed Systems
Locks In Disributed SystemsLocks In Disributed Systems
Locks In Disributed Systems
 
Operating system 22 threading issues
Operating system 22 threading issuesOperating system 22 threading issues
Operating system 22 threading issues
 
Distributed system architecture
Distributed system architectureDistributed system architecture
Distributed system architecture
 
Chapter 3 - Processes
Chapter 3 - ProcessesChapter 3 - Processes
Chapter 3 - Processes
 
Atom and rss
Atom and rssAtom and rss
Atom and rss
 
TCP/IP model
TCP/IP modelTCP/IP model
TCP/IP model
 
Uml Common Mechanism
Uml Common MechanismUml Common Mechanism
Uml Common Mechanism
 
CORBA - Introduction and Details
CORBA - Introduction and DetailsCORBA - Introduction and Details
CORBA - Introduction and Details
 
Cisco Packet Tracer Overview
Cisco Packet Tracer OverviewCisco Packet Tracer Overview
Cisco Packet Tracer Overview
 
Interconnection Network
Interconnection NetworkInterconnection Network
Interconnection Network
 
Fault tolerance
Fault toleranceFault tolerance
Fault tolerance
 
Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram
 
Distributed database management system
Distributed database management  systemDistributed database management  system
Distributed database management system
 
Upgrading to Exchange 2016
Upgrading to Exchange 2016Upgrading to Exchange 2016
Upgrading to Exchange 2016
 
Distributed deadlock
Distributed deadlockDistributed deadlock
Distributed deadlock
 
Remote invocation
Remote invocationRemote invocation
Remote invocation
 

Destaque

Dcom vs. corba
Dcom vs. corbaDcom vs. corba
Dcom vs. corba
Mohd Arif
 
Distributed objects & components of corba
Distributed objects & components of corbaDistributed objects & components of corba
Distributed objects & components of corba
Mayuresh Wadekar
 
Como crear Clientes/Servidores en COM-DCOM
Como crear Clientes/Servidores en COM-DCOMComo crear Clientes/Servidores en COM-DCOM
Como crear Clientes/Servidores en COM-DCOM
Eliana Ruiz
 

Destaque (20)

COM and DCOM
COM and DCOMCOM and DCOM
COM and DCOM
 
Dcom vs. corba
Dcom vs. corbaDcom vs. corba
Dcom vs. corba
 
ASP, ASP.NET, JSP, COM/DCOM
ASP, ASP.NET, JSP, COM/DCOMASP, ASP.NET, JSP, COM/DCOM
ASP, ASP.NET, JSP, COM/DCOM
 
Distributed objects & components of corba
Distributed objects & components of corbaDistributed objects & components of corba
Distributed objects & components of corba
 
DCOM
DCOMDCOM
DCOM
 
DCOM Comparison
DCOM ComparisonDCOM Comparison
DCOM Comparison
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
 
Evolution of com
Evolution of comEvolution of com
Evolution of com
 
Unit 6 dcom
Unit 6 dcom   Unit 6 dcom
Unit 6 dcom
 
Como crear Clientes/Servidores en COM-DCOM
Como crear Clientes/Servidores en COM-DCOMComo crear Clientes/Servidores en COM-DCOM
Como crear Clientes/Servidores en COM-DCOM
 
Com
ComCom
Com
 
Dcom visualC++
Dcom visualC++Dcom visualC++
Dcom visualC++
 
Distributed system
Distributed systemDistributed system
Distributed system
 
Corba model ppt
Corba model pptCorba model ppt
Corba model ppt
 
Multi-touch Interface for Controlling Multiple Mobile Robots
Multi-touch Interface for Controlling Multiple Mobile RobotsMulti-touch Interface for Controlling Multiple Mobile Robots
Multi-touch Interface for Controlling Multiple Mobile Robots
 
Giáo trình lập trình GDI+
Giáo trình lập trình GDI+Giáo trình lập trình GDI+
Giáo trình lập trình GDI+
 
Restful web service
Restful web serviceRestful web service
Restful web service
 
AXCIOMA, the component framework for distributed, real-time and embedded systems
AXCIOMA, the component framework for distributed, real-time and embedded systemsAXCIOMA, the component framework for distributed, real-time and embedded systems
AXCIOMA, the component framework for distributed, real-time and embedded systems
 
Client Server Model and Distributed Computing
Client Server Model and Distributed ComputingClient Server Model and Distributed Computing
Client Server Model and Distributed Computing
 

Semelhante a Component Object Model (COM, DCOM, COM+)

MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
Thomas Conté
 
The .net remote systems
The .net remote systemsThe .net remote systems
The .net remote systems
Raghu nath
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDE
Benjamin Cabé
 
Qtp not just for gui anymore
Qtp   not just for gui anymoreQtp   not just for gui anymore
Qtp not just for gui anymore
Pragya Rastogi
 
Introdot Netc Sharp En
Introdot Netc Sharp EnIntrodot Netc Sharp En
Introdot Netc Sharp En
Gregory Renard
 
DotNet Introduction
DotNet IntroductionDotNet Introduction
DotNet Introduction
nandhu8124
 

Semelhante a Component Object Model (COM, DCOM, COM+) (20)

CFInterop
CFInteropCFInterop
CFInterop
 
MSMDC_CLI363
MSMDC_CLI363MSMDC_CLI363
MSMDC_CLI363
 
Component based software development
Component based software developmentComponent based software development
Component based software development
 
AXCIOMA, the internals, the component framework for distributed, real-time, a...
AXCIOMA, the internals, the component framework for distributed, real-time, a...AXCIOMA, the internals, the component framework for distributed, real-time, a...
AXCIOMA, the internals, the component framework for distributed, real-time, a...
 
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
 
COM
COMCOM
COM
 
AXCIOMA, the internals, the component framework for distributed, real-time, a...
AXCIOMA, the internals, the component framework for distributed, real-time, a...AXCIOMA, the internals, the component framework for distributed, real-time, a...
AXCIOMA, the internals, the component framework for distributed, real-time, a...
 
Overview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technologyOverview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technology
 
Microsoft.Net Platform Basics
Microsoft.Net Platform BasicsMicrosoft.Net Platform Basics
Microsoft.Net Platform Basics
 
The .net remote systems
The .net remote systemsThe .net remote systems
The .net remote systems
 
Session 1
Session 1Session 1
Session 1
 
WIndows Embedded Compact 2013 – What’s news
WIndows Embedded Compact 2013 – What’s newsWIndows Embedded Compact 2013 – What’s news
WIndows Embedded Compact 2013 – What’s news
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDE
 
Qtp not just for gui anymore
Qtp   not just for gui anymoreQtp   not just for gui anymore
Qtp not just for gui anymore
 
Introdot Netc Sharp En
Introdot Netc Sharp EnIntrodot Netc Sharp En
Introdot Netc Sharp En
 
DotNet Introduction
DotNet IntroductionDotNet Introduction
DotNet Introduction
 
DOTNET
DOTNETDOTNET
DOTNET
 
Chapter 6-Remoting
Chapter 6-RemotingChapter 6-Remoting
Chapter 6-Remoting
 
Microsoft .NET Platform
Microsoft .NET PlatformMicrosoft .NET Platform
Microsoft .NET Platform
 
RICOH THETA x IoT Developers Contest : Cloud API Seminar
 RICOH THETA x IoT Developers Contest : Cloud API Seminar RICOH THETA x IoT Developers Contest : Cloud API Seminar
RICOH THETA x IoT Developers Contest : Cloud API Seminar
 

Mais de Peter R. Egli

Mais de Peter R. Egli (20)

LPWAN Technologies for Internet of Things (IoT) and M2M Scenarios
LPWAN Technologies for Internet of Things (IoT) and M2M ScenariosLPWAN Technologies for Internet of Things (IoT) and M2M Scenarios
LPWAN Technologies for Internet of Things (IoT) and M2M Scenarios
 
Data Networking Concepts
Data Networking ConceptsData Networking Concepts
Data Networking Concepts
 
Communication middleware
Communication middlewareCommunication middleware
Communication middleware
 
Transaction Processing Monitors (TPM)
Transaction Processing Monitors (TPM)Transaction Processing Monitors (TPM)
Transaction Processing Monitors (TPM)
 
Business Process Model and Notation (BPMN)
Business Process Model and Notation (BPMN)Business Process Model and Notation (BPMN)
Business Process Model and Notation (BPMN)
 
Overview of Cloud Computing
Overview of Cloud ComputingOverview of Cloud Computing
Overview of Cloud Computing
 
MQTT - MQ Telemetry Transport for Message Queueing
MQTT - MQ Telemetry Transport for Message QueueingMQTT - MQ Telemetry Transport for Message Queueing
MQTT - MQ Telemetry Transport for Message Queueing
 
Enterprise Application Integration Technologies
Enterprise Application Integration TechnologiesEnterprise Application Integration Technologies
Enterprise Application Integration Technologies
 
Android Native Development Kit
Android Native Development KitAndroid Native Development Kit
Android Native Development Kit
 
Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)
 
Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)
 
Web services
Web servicesWeb services
Web services
 
Overview of Spanning Tree Protocol (STP & RSTP)
Overview of Spanning Tree Protocol (STP & RSTP)Overview of Spanning Tree Protocol (STP & RSTP)
Overview of Spanning Tree Protocol (STP & RSTP)
 
MSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message QueueingMSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message Queueing
 
Common Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBACommon Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBA
 
JMS - Java Messaging Service
JMS - Java Messaging ServiceJMS - Java Messaging Service
JMS - Java Messaging Service
 
Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)
 
REST - Representational State Transfer
REST - Representational State TransferREST - Representational State Transfer
REST - Representational State Transfer
 
MOM - Message Oriented Middleware
MOM - Message Oriented MiddlewareMOM - Message Oriented Middleware
MOM - Message Oriented Middleware
 
Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF)Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF)
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 

Component Object Model (COM, DCOM, COM+)

  • 1. © Peter R. Egli 2015 1/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com Peter R. Egli INDIGOO.COM OVERVIEW OF MICROSOFTS COM, DCOM AND COM+ COMPONENT TECHNOLOGIES COM, DCOM, COM+
  • 2. © Peter R. Egli 2015 2/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com Contents 1. Evolution of COM 2. COM, DCOM, ActiveX, OLE, COM+ 3. Structure of COM Components 4. (D)COM IUnknown Interface 5. Component Lookup and Access 6. Microsoft IDL File 7. Execution / Access Models 8. DCOM Architecture 9. COM/DCOM/COM+ Tools 10. Access (D)COM Objects from .Net (COM-.Net Interop) 11. COM+ Applications 12. Creation of COM Projects in Visual Studio 13. Limitations of COM
  • 3. © Peter R. Egli 2015 3/20 Rev. 1.60 COM – DCOM - COM+ 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. DDE 1987 Dynamic Data Exchange.  One of the first inter-process communication means in Windows Technology for compound documents (e.g. Word document with embedded Excel document). OLE 1990 1993 1995 1996 1998 2000 COM DCOM ActiveX MTS COM+Object Linking and Embedding.  Based on DDE.  Technology for embedding and linking of documents in other documents. Component Object Model.  Object technology confined to single machines. Distributed COM (COM over RPC).  Technology with remotable objects.  Microsoft‘s answer to CORBA.  Renamed part of OLE related to networking.  The parts of OLE relating to compound documents remained OLE. 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.  Fusing of COM/DCOM and MTS plus additional services.  Uses COM as object technology.
  • 4. © Peter R. Egli 2015 4/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com 2. What are COM, DCOM, ActiveX, OLE, COM+ ? COM is Microsofts object / component technology. DCOM = remote access to COM objects / components (wire protocol = MSRPC which is a version of DCE RPC). 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. COM ActiveX / OLE MS RPC MTS COM+ COM ActiveX / OLE MS RPC MTS COM+ Client Server DCOM
  • 5. © Peter R. Egli 2015 5/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com 3. Structure of COM Components Relationship of objects, components, interfaces, classes, applications: • A COM component contains 1..* objects. • A COM component exists either as DLL (linked to the calling client, in-process) or as a separately running executable (out-of-process server). • A COM object implements 1..* interfaces which are defined in the IDL-file. • All objects (classes) of a component make up a type library. • Every object has an IUnknown interface (see below). • Component type library, every interface and every class / object has a globally unique ID (GUID, uuid). COM Object (CoDAO) IUnknown IDAO IPersist Component (DLL or exe) COM Object (CoViewer) IUnknown IViewer uuid: FD4AD...4255B uuid: A42B8...791BA uuid: 71AA0...25A4C uuid: 09B4C... 4A746 uuid: 26B4D... D3C86 uuid: 8DA10...124BC Type library Notation: Client Reference COM Object Lollipop = (provided) interface. Arrow = call of a method of on the interface
  • 6. © Peter R. Egli 2015 6/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com 4. (D)COM IUnknown Interface Every COM object has an IUnknown interface. The IUnknown interface is used for: a. Introspection / reflection: Method QueryInterface() allows to dynamically discover other interfaces of an object (check if an object supports a specific interface identified by an interface ID). b. Life-cycle control / garbage collection (GC): AddRef()  Client increases reference count. Release()  Client releases its reference thus decrementing the reference count. GC collects object once the reference count becomes 0. COM Object (CoViewer) IUnknown IViewer COM Object (CoDAO) IUnknown IDAO IPersist Component (DLL or exe) QueryInterface() AddRef() Release()
  • 7. © Peter R. Egli 2015 7/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com 5. Component Lookup and Access (1/3) Objects are registered in the registry under HKEY_CLASSES_ROOT/CLSID. Every object and interface has a registry entry. The registry is consulted for locating (lookup) objects based on a ProgID (mapping of GUID/uuid to implementation). Location of server DLL containing the object class Server type, here an inproc object (object is loaded into the client‘s process). Alternative: LocalServer32 object running in an executable. ProgID containing the version Example „COMHelloWorld.COMHelloWorld.1“ ProgID without version „COMHelloWorld.COMHelloWorld“
  • 8. © Peter R. Egli 2015 8/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com 5. Component Lookup and Access (2/3) Clients contact the SCM (Service Control Manager) in order to obtain an object reference. In case of remote objects (DCOM), the local SCM contacts the remote SCM. Client application Server Component SCM COM Object Ixyz 1. Request with CLSID (GUID, uuid) Registry 2. Lookup in registry 3. SCM instantiates COM object 4. SCM passes reference to client 5. Call on COM object
  • 9. © Peter R. Egli 2015 9/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com 5. Component Lookup and Access (3/3) Problem of registry-based component lookup: DLL-hell (different applications requiring different and possibly incompatible versions of COM-libraries). Solution: Registry free creation of objects (requires Windows XP or higher). Also called „isolated COM“. • Different applications may use different versions of COM-components. • COM-components no longer need to be registered but may be deployed with XCOPY- deployment (simple copying of components without creating registry entries by an installer). • Component is described in a manifest file which is used by the calling application to load and create the component. Visual Studio settings (create manifest file as part of build): Source: http://msdn.microsoft.com/de-ch/magazine/cc188708(en-us).aspx
  • 10. © Peter R. Egli 2015 10/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com HelloWorld.cpp 6. Microsoft IDL File IDL-files for COM use the MIDL-format (Microsoft IDL). IDL files are compiled with MIDL.exe (automatically in Visual Studio ATL-project). MIDL.exe ... [ 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); }; ... COMHelloWorld.idl ... public: STDMETHOD(ShowMessage)(void); public: STDMETHOD(ShowMessageWithParam)(BSTR message); }; ... HelloWorld.h COMHelloWorld.h COMHelloWorld.cpp
  • 11. © Peter R. Egli 2015 11/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com 7. Execution / Access Models In-proc access: Component resides in a DLL. The client loads the component into its process. Local server: Component resides in an executable and runs in its own process on the local machine. Access through RPC. Remote server: Component resides in an executable and runs on a remote machine. Access through RPC. COM Object Client COM Local proxy Remote proxy Client process Client machine COM Stub COM Object RPC Remote machine COM Stub RPC COM Object In-process access Local server Remote server
  • 12. © Peter R. Egli 2015 12/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com 8. DCOM Architecture Client proxy: Proxy object on client side for accessing the server object. Stub: Server interface stub that complements the client interface proxy. Registry: Contains a list of mappings of class / object GUID to implementation library. SCM: Service Control Manager (RPCSS.exe) which consults registry and creates / instantiates a new server object based on the GUID (comparable to ORB in CORBA). The SCM hides the registry from (D)COM. COM Object Interface stub SCM COM Object Interface proxy SCM Registry Client Server RPC RPC Interface on SCM for remote activation: IRemoteActivation:: RemoteActivation Client component library Server component Actual access to remote object is done through RPC ORB: Object Request Broker
  • 13. © Peter R. Egli 2015 13/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com 9. COM / DCOM / COM+ Tools Register COM component: regsvr32 <COM-lib>.dll Registry of objects: Windows registry (edit with regedit.exe or regedt32.exe) Component service explorer: Control Panel  Administrative Tools  Component Services or simply start dcomcnfg.exe
  • 14. © Peter R. Egli 2015 14/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com 10. Access (D)COM Objects from .Net (COM-.Net Interop) .Net introduced an entirely new object model: • .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 . .NetCOM: 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 Source: http://msdn.microsoft.com/en-us/library/5dxz80y2.aspx COM .Net
  • 15. © Peter R. Egli 2015 15/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com 11. COM+ Applications COM+ applications host (contain) 1..n COM-components. Dcomcnfg.exe shows a list of active COM+ applications. COM components of „COM+ Utilities“ COM+ application
  • 16. © Peter R. Egli 2015 16/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com 12. Creation of COM Projects in Visual Studio (1/4) 1. Create Visual Studio ATL C++ project with the following settings: 2. Add a new class to the COM component:
  • 17. © Peter R. Egli 2015 17/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com 12. Creation of COM Projects in Visual Studio (2/4) 3. ATL Simple Object Wizard: Set names (Class, Coclass and Interface names may be different): 4. Add method to interface (e.g. ShowMessage()):
  • 18. © Peter R. Egli 2015 18/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com 12. Creation of COM Projects in Visual Studio (3/4) 5. Implement interface method (ShowMessage()): Add user code to implementation of method in implementation class (HelloWorld.cpp): STDMETHODIMP CHelloWorld::ShowMessage(void) { ::MessageBox(::GetActiveWindow( ),_T("Hello World from COMHelloWorld."), _T("First COM+ Application"),MB_OK); return S_OK; } 6. Compile ATL COM project 7. Register COM: Open command shell, change to debug directory of COM project. >regsvr32.exe COMHelloWorld.dll 8. Create client, e.g. in Excel-VBA: Create new Excel file ToolsMacroVisual Basic Editor Add reference to COM component (ToolsReferences):
  • 19. © Peter R. Egli 2015 19/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com 12. Creation of COM Projects in Visual Studio (4/4) 9. Access the COM component from VBA code: 'TestHelloClient_TLB accesses the COM component using the COM type library (TLB) 'that has to be added to this project in the references (Menu Tools->References) Sub TestHelloWorldClient_TLB() Dim hw As COMHelloWorld Dim gw As COMGoodbyeWorld Set hw = New COMHelloWorld hw.ShowMessage Set gw = New COMGoodbyeWorld gw.ShowMessage End Sub 'TestHelloWorldClient_ProgID access the COM component using the ProgID Sub TestHelloWorldClient_ProgID() Dim obj As Object Set obj = CreateObject("COMHelloWorld.COMHelloWorld") obj.ShowMessage Set obj = CreateObject("COMHelloWorld.COMGoodbyeWorld") obj.ShowMessage End Sub ATL project name Coclass name Object ProgID
  • 20. © Peter R. Egli 2015 20/20 Rev. 1.60 COM – DCOM - COM+ indigoo.com 13. Limitations of COM COM is still widely used by many applications to provide programmatic access for automation purposes. However, due to many technological limitations (see below) COM was technologically superseded by .Net. No true inheritance (may be emulated with aggregation and containment). No exceptions (only return codes). Inconsistent use of IDL (COM uses IDL, but VB or scripting languages like VBA use binary representation (type library)). No OO-features (static modifier, virtual functions, overloaded methods).