DNA And COM
We explain what COM, DCOM, COM+ and Windows DNA are, and what’s involved
in writing and deploying applications which use them.
By Andrew Ward
M icrosoft has adopted the um-
brella term Windows DNA
(Distributed InterNet Archi-
tecture) to embrace a range of tech-
with software developed using the cli-
Much more important, however, is
the need to be able to develop and
Windows DNA Services can be cat-
egorised in the following way:
nologies - some old, some new - which change applications quickly, in re-
together make up an architecture for sponse to changing business needs. q Presentation Services (client inter-
developing distributed applications This is achieved by separating the pro- face).
on the Windows platform. gram code responsible for the business q Application Services (component
Windows DNA fits into a multi-tier logic (policies and procedures) from services or business logic).
world, and is aimed primarily at the that which has to handle the interfaces q Data Services.
middle tier - although Microsoft does to the client, the back office services q System Services.
of course also provide technologies for (such as database and legacy systems)
the client desktop and, in some cases, and infrastructure services such as di- Presentation Services includes the
for the back office. rectory and security. native Win32 API as well as standards-
From the development point of Windows DNA encompasses serv- based presentation methods such as
view, DNA technologies take care of a ices covering the full spectrum of ap- HTML, DHTML (Dynamic HTML),
significant amount of the necessary in- plication needs, from client-side scripting and even COM components
frastructure that an application needs, presentation services (via the Win32 themselves.
so that it is quicker and easier to de- API, for example) to back-office data Application Services represents the
velop new software. services. Many of these services are heart of Windows DNA, and provides
Applications written for Windows available today, either included with the primary infrastructure to support
DNA will run on Windows NT serv- the Windows desktop operating sys- COM objects (the term which usually
ers, but because parts of the DNA in- tems (and Windows NT 4 with the Op- refers to business logic components).
frastructure are also supported on tion Pack), or provided by additional Application Services include Microsoft
desktops - under Windows 95, 98 and applications such as SQL Server 7.0, but Message Queue (MSMQ), Microsoft
Windows NT Workstation - there is some aren’t due until Windows 2000. Transaction Server (MTS) and COM.
tremendous flexibility. And, as a mid- Nevertheless, it is possible to de- Microsoft Internet Information Server
dle-tier environment, Windows DNA velop applications using Windows (IIS) is usually treated as an application
must provide support for a range of DNA technologies today using Visual service. It provides the ability for active
client devices and communicate with a Studio 6, and deploy them on Win- server pages (ASPs) to invoke COM
number of different back office re- dows NT 4.0 Server together with the objects.
sources such as legacy systems and Option Pack. Data Services really means ADO
databases. As such, it is impossible to
draw a definitive diagram of what
DNA is, beyond the rather bland ge-
neric picture shown in Figure 1. “COM is a CBD technology, and
Enterprise Trends therefore a competitor to Enterprise
Windows DNA draws on a number JavaBeans - the Java world’s answer to
of trends in the enterprise computing
arena. The most obvious is the desire running server-side software components.”
for robust, distributed, scalable appli-
cations, following bad experiences
Issue 107 (May 1999) Page 15
PC Network Advisor File: T1510.1
(ActiveX Data Objects) for data access
and SQL Server 7.0 for data storage.
ADO is a data abstraction technology “COM used to be called OLE, and
designed to provide much greater in-
sulation from the data source than DCOM used to be called Network OLE.”
does, say, ODBC or SQL. For data in-
teroperability, DNA includes RDS (Re-
mote Data Services) and XML
(eXtensible Markup Language). XML ing application) to access an object’s tral. COM objects can even be written
is an interchange language designed data. in Visual Basic.
for complex structured data, to deliver Componentisation is the art of COM enables software developers
flexibility and interoperability for breaking down an application into to build applications from binary soft-
data. XML is to data what HTML is to component pieces that are easier to de- ware components that can be deployed
presentation. velop, test, maintain and re-use than a at any tier of the application model.
Finally, System Services comprises large monolithic program. The developer writes the application to
those unexciting but essential services It is usual to want to separate busi- make use of COM components, and
such as directory, security, manage- ness logic from the client (presenta- these can reside in several different
ment, networking and communica- tion) layer, so that changes in business places. They can be part of the calling
tions. Directory and security services policies and processes - which now program itself, a separate program
can also be considered to be applica- happen more and more frequently - running in the same machine as the
tion services. are quicker and easier to implement. calling program, or even running on
COM enforces the programming disci- another machine.
Component Services pline of separating the interface defini- A COM object can deliver a very
tion from the code (something that high level of functionality. For exam-
The heart of the Windows DNA in- software quality systems have always ple, Microsoft Internet Explorer, and
frastructure is provided by the compo- done, but which is rare in the Visual Microsoft Office applications such as
nent services, COM. Unfortunately, Basic developer’s world today). Excel and Word, all expose a COM
the name COM (Component Object COM is thus a CBD technology, and interface. Hence, a word processor or
Model) confuses componentisation therefore a competitor to Enterprise Web browser can be easily included by
(component-based development or JavaBeans - the Java world’s answer to application programmers.
CBD) with object orientation. In fact, running server-side software compo- However, you can encapsulate any
COM objects are a bit like C++ objects nents. And because COM is a binary type of code or application functional-
in that they usually do have some as- object model, the calling interface ity, such as a user interface control or
sociated data, but unlike them in an- (method invocation) is object-oriented. piece of business object. A component
other way - you cannot access the COM However, there is no need to use an may have one or more interfaces, each
component’s data at all, whereas C++ object-oriented language to write exposing a set of methods and proper-
object pointers do allow a client (call- COM objects - COM is language-neu- ties that can be queried and set by other
components and applications. For ex-
ample, a customer component might
expose various properties such as
name, address and telephone number.
Writing COM Objects
COM+, the version of COM due to
appear in Windows 2000, is the fourth
stage in the development of COM.
These stages are COM, DCOM, MTS
and COM+. Although using COM ob-
jects does yield certain benefits for the
developer, it is a new and different
programming model and there is an
associated learning curve.
COM objects must be accessed indi-
rectly, via interface pointers, rather
than via a direct call. This allows COM
to preserve encapsulation of data and
Figure 1 - Windows DNA is designed to embrace, rather than replace, processing - changes can be made to
non-Windows client and back-office systems. the object’s implementation without
PC Network Advisor Issue 107 (May 1999) Page 16
DNA And COM
such as Visual Basic, and simply
dragged and dropped into the graphi-
“DCOM provides two different ways cal representation of the target applica-
tion. The ActiveX wrapper takes care
for clients to indicate the remote server of the various housekeeping tasks re-
quired to marshal parameters in the
name when an object is created.” correct sequence and then call the un-
derlying COM object.
Before using an interface, a client
application must first query the COM
having to change the calling applica- face Definition Language). This defini- component to find out if the interface
tion. Furthermore, this allows a COM tion is then compiled using the IDL is supported. If so, it will return an
object to be transparently removed compiler, which emits C/C++ defini- interface pointer that can then be used
across the network - a proxy stub re- tions as source code. For example, a to call the methods contained within
mains on the local system to provide header (.h) file is produced so that the interface. For example, we could
the identical interface that the COM other developers can write to your in- have an address book COM compo-
object itself uses to expose its services. terface. You can create these headers nent, with an ILookup interface (inter-
A COM interface will itself com- manually, but it’s preferable to use faces begin with I by convention), and
prise a number of related operations IDL. LookupByName and LookupByCom-
known as methods. Typically, a COM When coding a COM component, pany methods.
component implements a number of the programmer is obliged to include Before we can get to that stage, how-
interfaces for different sets of services, reference counting. COM components ever, there has to be some mechanism
and each interface is known by a have to know when no-one is using to find the COM object. Fortunately,
unique identifier (a 128-bit number them, so that they can safely unload there is a COM library within the sys-
known as a GUID, or Globally Unique from memory. tem that takes care of this - if we pass
IDentifier). The use of a GUID avoids A simple reference counting it a CLSID, it will identify the EXE or
the confusion associated with human- scheme is used so that, when a calling DLL file that contains the COM com-
readable names. Hence, to call a COM application is using a COM interface, it ponent and then load it.
component you must have an interface calls the increment method AddRef,
pointer, and to request the interface which increments a counter. When the DCOM
pointer you must use the GUID. In fact, application no longer requires the
GUIDs that refer to COM component COM interface, it calls the method Re- DCOM (Distributed COM) is a pro-
classes are known as CLSIDs (class lease, which decrements the counter. tocol to allow COM components to
IDs), and GUIDs that refer to interfaces Thus, when the reference count be- communicate over a network by pass-
as IIDs (Interface IDs). comes zero, the component knows that ing COM method invocations across
Interfaces are not allowed to change nothing is using it. the network to a component running
- you can’t have different versions of on a remote machine. COM used to be
the same interface. If new functions are Invoking COM called OLE, and DCOM used to be
added to an interface, or the way in called Network OLE.
which an interface works changes, Invoking a COM object directly - Using DCOM doesn’t require any
then a new GUID is assigned and it that is, calling or activating it from an additional action on the part of the
becomes a new interface. It’s perfectly application or another COM object - is programmer; you still write COM ap-
possible for a developer to ship a COM a low-level activity carried out in C++ plications and not DCOM applica-
component that supports both old and or some other language. But the COM tions. This is possible because of the
new interfaces - thus, there’s no need developer can also create an ActiveX interface pointer method of calling
for any modification or recompilation control, something which provides a COM components - the proxy stub
of any existing clients of that compo- link between an application program looks to the client program exactly like
nent. and a COM object. the memory pointers of a normal COM
When defining a COM interface, the ActiveX controls can be used within interface.
developer actually writes in IDL (Inter- graphical development environments, DCOM contains extensions to han-
dle some of the administrative burden
incurred by remote invocations - for
Where To Get DNA example, object garbage collection and
identity, and call propagation across
COM and DCOM - Windows NT 4.0 and Windows 9x objects. However, it is incumbent upon
MSMQ version 1.0 - Windows NT 4.0 Option Pack C++ developers to check for any com-
Internet Information Server (IIS) 4.0 - Option Pack munications errors (a network or serv-
MTS 2.0 - Option Pack er failure, for example) when using
COM+ - Windows 2000 proxies, by testing the returned value
Issue 107 (May 1999) Page 17
PC Network Advisor File: T1510.3
HRESULTS. In Visual Basic and Java COM objects explicitly. an application to connect users to a
this checking is taken care of on behalf In addition, COM+ eliminates the chargeable service, then user authenti-
of the developer by the run-time envi- need for the programmer to handle cation must take place live and online.
ronment. multiple concurrent users. COM+ will However, the instruction to the billing
Of course, the problem of finding transparently manage multiple in- system to bill for the connect time does
components is increased over a net- stances of certain COM objects that not need to be immediate, and can be
work. For DCOM, the object creation were originally designed for single- queued - but it must get through even-
mechanism in the COM libraries is en- user environments. However, it won’t tually.
hanced to allow object creation on always be that easy. Some objects will Microsoft Message Queue Server
other machines. In order to be able to need to be re-written to be transaction- (MSMQ) provides network communi-
create a remote object, the COM librar- aware. And even if COM+ takes care cations services based on a message-
ies need to know the network name of of much of the work for you, the degree queuing model to achieve these
the server. Once the server name and of knowledge and the programming objectives. It takes care of the issues
the CLSID are known, a portion of the complexity are still too high for the involved in queued messages, such as
COM libraries called the Service Con- typical corporate Visual Basic applica- data privacy and integrity, without the
trol Manager (SCM) on the client ma- tion programmer. developer having to become involved
chine connects to the SCM on the in the detailed communication pro-
server machine and requests creation Deployment gramming. MSMQ services can be ac-
of the object. cessed through a simple interface
DCOM provides two different Although COM allows developers provided by COM components.
ways for clients to indicate the remote to create applications from compo- COM+ queued components will
server name when an object is created. nents, the run-time package delivered combine some of the features of
The server name can be fixed in the to the end-user is usually, to all intents MSMQ with COM, which is useful
registry, or can be passed as a parame- and purposes, a monolithic applica- when using COM interfaces and when
ter to CoCreateInstanceEx, CoGetIn- tion that runs on a single machine. The you don’t need fine-grained control
stanceFromFile, CoGetInstanceFrom- ability to offload processing to other over MSMQ message properties.
Storage, or CoGetClassObject. systems using the DCOM interface is MSMQ is integrated with MTS in
rarely used in practice. that an MTS-based application can in-
MTS And COM+ With COM+, a new capability - clude the act of sending or receiving a
load-balancing - may provide suffi- message within a larger atomic trans-
Microsoft Transaction Server (MTS) cient additional attraction for develop- action. Thus, all the operations in that
is a refinement of the COM program- ers of those applications that have a transaction will succeed or fail as a
ming model which has now taken over significant processing burden. group.
from basic COM. In fact, in Windows COM+ will allow components to be
2000 the name MTS will disappear al- created on one of a number of servers,
together, and COM will be renamed according to load. By default, applica-
COM+. tions cannot be load-balanced in this
COM+ will unify the programming way. Components must be specially
models of COM and MTS, and in prac- created so that they can be load-bal-
tical terms for the programmer this anced: they must be designed for
means that COM+ makes it easier to short-lived instances, since load-bal-
develop distributed applications by ancing occurs only at object creation
eliminating the work associated with time. They must also explicitly manage
having to deal with COM for certain state (for example, store it in a database
services and MTS for others. across application boundaries).
Just as COM is a programming dis-
cipline based on distinguishing inter- Queuing
face and implementation, so MTS (or
COM+) is a programming discipline DCOM expects the remote compo-
based on distinguishing state and be- nent to be present and correct, and will
haviour. A COM object has both state return an error if it isn’t. But there are
and behaviour, and MTS provides the many instances where there could be
necessary infrastructure for state man- valid reasons for the remote compo- The Author
agement. Thus you can, in some cases, nent to be unavailable at a specific mo- Andrew Ward is a freelance jour-
get all the benefits of transaction proc- ment. In these cases, you certainly still nalist and writer who specialises
essing (such as ensuring database in- want the message to get through once in business and technology sub-
tegrity and providing rollbacks in the - and only once - but it doesn’t need to jects. He can be contacted as an-
case of failure) without the cost of pro- happen immediately. email@example.com.
gramming transaction awareness into For example, if you are constructing
PC Network Advisor Issue 107 (May 1999) Page 18
New Reviews from Tech Support Alert
Anti-Trojan Software Reviews
A detailed review of six of the best anti trojan software programs. Two products
were impressive with a clear gap between these and other contenders in their
ability to detect and remove dangerous modern trojans.
Inkjet Printer Cartridge Suppliers
Everyone gets inundated by hundreds of ads for inkjet printer cartridges, all
claiming to be the cheapest or best. But which vendor do you believe? Our
editors decided to put them to the test by anonymously buying printer cartridges
and testing them in our office inkjet printers. Many suppliers disappointed but we
came up with several web sites that offer good quality cheap inkjet cartridges
with impressive customer service.
Windows Backup Software
In this review we looked at 18 different backup software products for home or
SOHO use. In the end we could only recommend six though only two were good
enough to get our “Editor’s Choice” award
The 46 Best Freeware Programs
There are many free utilities that perform as well or better than expensive
commercial products. Our Editor Ian Richards picks out his selection of the very
best freeware programs and he comes up with some real gems.
Tech Support Alert