Microsofts Distributed Component Object Model DCOM A semitechnical

Microsoft’s Distributed Component Object Model (DCOM) A semi-technical overview Jim Ries Jim. R@acm. org Updated 10/5/1999

Genealogy n DCOM comes from COM and OSF (now Open Group) DCE u DCE F Remote Procedure Calls (RPC) F Interface Definition Language (IDL) u Component Object Model (COM) u ORPC n OMG CORBA - a parallel standard u Different RPC u Different IDL u COM proxy == CORBA stub u COM stub == CORBA skeleton

Microsoft proprietary, but. . . n Open Group’s COMSource: http: //www. opengroup. org/comsource/ n Software AG’s Entire. X: http: //www. softwareag. com/entirex/default. htm n The Active Group: http: //www. activex. org/

COM Goals n n n n n Encapsulation (separate implementation from interface) Versioning Execution context independence Language independence Object Creation / Lifetime Control Standard error code (HRESULT) Solve object discovery problem Scripting The Holy Grail of Reuse

Alphabet soup: COM/OLE/Active. X n n n COM is a binary standard and a style for creating objects. OLE is (was) a set of COM interfaces for embedding documents (originally “Object Linking and Embedding”). Active. X is a marketing buzz-word meaning COM and/or OLE, but usually applied to Internet-oriented components.

Later and later binding n n “Editor inheritance” binds at compile time. Link libraries (. LIB) bind to “components” at link time. Dynamic link libraries (. DLL) bind at run time, but need a header at compile time, and path at runtime. COM components bind at runtime and may need neither a header, nor a path! (though typelib contains header-like “meta-data”)

Interfaces n n n COM enforces the concept of interfaces being separate from implementation. Interface == Abstract Base Class Objects support multiple interfaces through multiple inheritance. Interfaces NEVER change! A “control” is just a COM component with the right interfaces.

GUID’s (or UUID’s) n n n Globally Unique Identifiers (Universally Unique Identifiers) Needed to avoid name collisions A class is associated with a GUID (CLSID). An interface is associated with a GUID (IID). The Windows Registry: a hierarchical database.

Execution Context n n n In proc - DLL’s (no marshalling) Out of proc - EXE’s (LRPC) Remote - EXE’s using DCOM u RPC u DCE “compatible” (see “Interconnecting Personal Computers with the Distributed Computing Environment” by Jim Ries, UMC Thesis, 1998. )

Coding Tools n n n n C - Raw C++ - ATL C++ - MFC Visual Basic J++ (pseudo Java) Binary standard ==> any language COULD produce COM components.

Platforms n Win 32 u Windows 95 (DCOM as separate download; included in OSR 2) u Windows NT 4. 0 u Windows 98 u Windows 2000 n Unix platforms (with some help)

Nuts and Bolts n n n Co. Initialize() Co. Create. Instance() IUnknown u Query. Interface() u Add. Ref() u Release() n Co. Uninitialize()

Demonstration - IDL [ object, uuid(75 D 873 CD-7 B 63 -11 D 3 -9 D 43 -00 C 0 F 031 CDDE), helpstring("IServer Interface"), pointer_default(unique) ] interface IServer : IUnknown { HRESULT Hello([in, string] char * psz. Message); };

Demonstration - Server Code // Prototype class CServer : public IServer, public CCom. Object. Root, public CCom. Co. Class<CServer, &CLSID_Server> { //. . . Some code omitted for brevity // IServer public: HRESULT STDMETHODCALLTYPE Hello(unsigned char * psz. Message); }; // Code HRESULT STDMETHODCALLTYPE CServer: : Hello(unsigned char * psz. Message) { char sz. Buf[256]; wsprintf(sz. Buf, "%s", psz. Message); : : Message. Box(0, sz. Buf, "Server", MB_OK); return(S_OK); }

Demonstration - Client Code if (SUCCEEDED( hr=Co. Create. Instance(CLSID_Server, NULL, CLSCTX_LOCAL_SERVER, IID_IServer, (void **)&p. Server))) { if (SUCCEEDED(hr=p. Server->Hello((unsigned char *)"Hello from the client"))) Message. Box("Client: Server printed the message"); else { wsprintf(sz. Buffer, "Hello() method failed: 0 x%l. X. n", hr); Message. Box(sz. Buffer); } p. Server->Release(); } else { wsprintf(sz. Buffer, "Unable to create a server: 0 x%l. X. n", hr); Message. Box(sz. Buffer); }

Distributed Scenario n From “DCOM Architecture” a Microsoft white paper.

Demonstration n Run DCOM “Hello world” demo here.

Additional Technologies n COM+ u MTS - Microsoft Transaction Server u MSMQ - Microsoft Message Queue u Compiler supported IUnknown, etc. n ADS - Active Directory Service u As “distributed registry” u As namespace abstraction n All Microsoft products are COM based: u IIS - Internet Information Server u Exchange u Internet Explorer u Word, Excel, etc.

References n n n n n Microsoft DCOM page IETF DCOM Standard Proposal Inside OLE by Kraig Brockschmidt, Microsoft Press, 1995. Essential COM by Don Box, Addison Wesley, 1998. Inside COM by Dale Rogerson, Microsoft Press, 1997. Don Box homepage Active. X COM Control Programming by Sing Li and Panos Economopoulos, Wrox Press, 1997. COM-CORBA Interoperability by Geraghty, et. al. , Prentice Hall, 1999. Microsoft Developer Network
- Slides: 19