<s>
Component	B-Application
Object	I-Application
Model	I-Application
(	O
COM	O
)	O
is	O
a	O
binary-interface	B-Operating_System
standard	O
for	O
software	B-Architecture
components	I-Architecture
introduced	O
by	O
Microsoft	O
in	O
1993	O
.	O
</s>
<s>
It	O
is	O
used	O
to	O
enable	O
inter-process	B-Operating_System
communication	I-Operating_System
object	O
creation	O
in	O
a	O
large	O
range	O
of	O
programming	O
languages	O
.	O
</s>
<s>
COM	O
is	O
the	O
basis	O
for	O
several	O
other	O
Microsoft	O
technologies	O
and	O
frameworks	O
,	O
including	O
OLE	B-Operating_System
,	O
OLE	B-Application
Automation	I-Application
,	O
Browser	B-Application
Helper	I-Application
Object	I-Application
,	O
ActiveX	B-Application
,	O
COM+	O
,	O
DCOM	B-Operating_System
,	O
the	O
Windows	B-Application
shell	I-Application
,	O
DirectX	B-Application
,	O
UMDF	B-Application
and	O
Windows	O
Runtime	B-Library
.	O
</s>
<s>
For	O
well-authored	O
components	B-Architecture
,	O
COM	O
allows	O
reuse	O
of	O
objects	O
with	O
no	O
knowledge	O
of	O
their	O
internal	O
implementation	O
,	O
as	O
it	O
forces	O
component	B-Architecture
implementers	O
to	O
provide	O
well-defined	O
interfaces	O
that	O
are	O
separated	O
from	O
the	O
implementation	O
.	O
</s>
<s>
The	O
different	O
allocation	O
semantics	O
of	O
languages	O
are	O
accommodated	O
by	O
making	O
objects	O
responsible	O
for	O
their	O
own	O
creation	O
and	O
destruction	O
through	O
reference-counting	B-General_Concept
.	O
</s>
<s>
COM	O
is	O
an	O
interface	B-Application
technology	O
defined	O
and	O
implemented	O
as	O
standard	O
only	O
on	O
Microsoft	B-Application
Windows	I-Application
and	O
Apple	O
's	O
Core	B-Operating_System
Foundation	I-Operating_System
1.3	O
and	O
later	O
plug-in	O
application	B-Application
programming	I-Application
interface	I-Application
(	O
API	B-Application
)	O
.	O
</s>
<s>
The	O
latter	O
only	O
implements	O
a	O
subset	O
of	O
the	O
whole	O
COM	O
interface	B-Application
.	O
</s>
<s>
For	O
some	O
applications	O
,	O
COM	O
has	O
been	O
replaced	O
at	O
least	O
to	O
some	O
extent	O
by	O
the	O
Microsoft	B-Application
.NET	I-Application
framework	I-Application
,	O
and	O
support	O
for	O
Web	O
Services	O
through	O
the	O
Windows	B-Application
Communication	I-Application
Foundation	I-Application
(	O
WCF	B-Application
)	O
.	O
</s>
<s>
However	O
,	O
COM	B-Application
objects	I-Application
can	O
be	O
used	O
with	O
all	O
.NET	B-Application
languages	O
through	O
.NET	B-Application
COM	B-Device
Interop	I-Device
.	O
</s>
<s>
Networked	O
DCOM	B-Operating_System
uses	O
binary	O
proprietary	O
formats	O
,	O
while	O
WCF	B-Application
encourages	O
the	O
use	O
of	O
XML-based	O
SOAP	B-Protocol
messaging	O
.	O
</s>
<s>
COM	O
is	O
very	O
similar	O
to	O
other	O
component	B-Architecture
software	I-Architecture
interface	B-Application
technologies	O
,	O
such	O
as	O
CORBA	B-Architecture
and	O
Enterprise	B-Language
JavaBeans	I-Language
,	O
although	O
each	O
has	O
its	O
own	O
strengths	O
and	O
weaknesses	O
.	O
</s>
<s>
Unlike	O
C++	B-Language
,	O
COM	O
provides	O
a	O
stable	O
application	B-Operating_System
binary	I-Operating_System
interface	I-Operating_System
(	O
ABI	O
)	O
that	O
does	O
not	O
change	O
between	O
compiler	B-Language
releases	O
.	O
</s>
<s>
This	O
makes	O
COM	O
interfaces	O
attractive	O
for	O
object-oriented	B-Language
C++	B-Language
libraries	O
that	O
are	O
to	O
be	O
used	O
by	O
clients	O
compiled	B-Language
using	O
different	O
compiler	B-Language
versions	O
.	O
</s>
<s>
One	O
of	O
the	O
first	O
methods	B-Language
of	O
interprocess	B-Operating_System
communication	I-Operating_System
in	O
Windows	O
was	O
Dynamic	B-Operating_System
Data	I-Operating_System
Exchange	I-Operating_System
(	O
DDE	B-Operating_System
)	O
,	O
first	O
introduced	O
in	O
1987	O
,	O
that	O
allowed	O
sending	O
and	O
receiving	O
messages	O
in	O
so-called	O
"	O
conversations	O
"	O
between	O
applications	O
.	O
</s>
<s>
Antony	O
Williams	O
,	O
who	O
was	O
involved	O
in	O
the	O
creation	O
of	O
the	O
COM	O
architecture	O
,	O
later	O
distributed	O
two	O
internal	O
papers	O
in	O
Microsoft	O
that	O
embraced	O
the	O
concept	O
of	O
software	B-Architecture
components	I-Architecture
:	O
Object	O
Architecture	O
:	O
Dealing	O
With	O
the	O
Unknown	O
–	O
or	O
–	O
Type	O
Safety	O
in	O
a	O
Dynamically	O
Extensible	O
Class	O
Library	O
in	O
1988	O
and	O
On	O
Inheritance	O
:	O
What	O
It	O
Means	O
and	O
How	O
To	O
Use	O
It	O
in	O
1990	O
.	O
</s>
<s>
Object	B-Operating_System
Linking	I-Operating_System
and	I-Operating_System
Embedding	I-Operating_System
(	O
OLE	B-Operating_System
)	O
,	O
Microsoft	O
's	O
first	O
object-based	O
framework	O
,	O
was	O
built	O
on	O
top	O
of	O
DDE	B-Operating_System
and	O
designed	O
specifically	O
for	O
compound	O
documents	O
.	O
</s>
<s>
It	O
was	O
introduced	O
with	O
Word	B-Application
for	I-Application
Windows	I-Application
and	O
Excel	B-Application
in	O
1991	O
,	O
and	O
was	O
later	O
included	O
with	O
Windows	O
,	O
starting	O
with	O
version	O
3.1	O
in	O
1992	O
.	O
</s>
<s>
An	O
example	O
of	O
a	O
compound	O
document	O
is	O
a	O
spreadsheet	B-Application
embedded	O
in	O
a	O
Word	B-Application
for	I-Application
Windows	I-Application
document	O
:	O
as	O
changes	O
are	O
made	O
to	O
the	O
spreadsheet	B-Application
within	O
Excel	B-Application
,	O
they	O
appear	O
automatically	O
inside	O
the	O
Word	O
document	O
.	O
</s>
<s>
In	O
1991	O
,	O
Microsoft	O
introduced	O
Visual	B-Library
Basic	I-Library
Extensions	I-Library
(	O
VBX	B-Library
)	O
with	O
Visual	B-Application
Basic	I-Application
1.0	O
.	O
</s>
<s>
A	O
VBX	B-Library
is	O
a	O
packaged	O
extension	O
in	O
the	O
form	O
of	O
a	O
dynamic-link	O
library	O
(	O
DLL	O
)	O
that	O
allows	O
objects	O
to	O
be	O
graphically	O
placed	O
in	O
a	O
form	O
and	O
manipulated	O
by	O
properties	B-Language
and	O
methods	B-Language
.	O
</s>
<s>
These	O
were	O
later	O
adapted	O
for	O
use	O
by	O
other	O
languages	O
such	O
as	O
Visual	B-Application
C++	I-Application
.	O
</s>
<s>
In	O
1992	O
,	O
when	O
version	O
3.1	B-Application
of	I-Application
Windows	I-Application
was	O
released	O
,	O
Microsoft	O
released	O
OLE	B-Operating_System
2	O
with	O
its	O
underlying	O
object	B-Application
model	I-Application
.	O
</s>
<s>
The	O
COM	O
Application	B-Operating_System
binary	I-Operating_System
interface	I-Operating_System
(	O
ABI	O
)	O
was	O
the	O
same	O
as	O
the	O
MAPI	O
ABI	O
(	O
released	O
in	O
1992	O
)	O
,	O
and	O
like	O
it	O
was	O
based	O
on	O
MSRPC	B-General_Concept
and	O
ultimately	O
on	O
the	B-Application
Open	I-Application
Group	I-Application
's	O
DCE/RPC	B-General_Concept
.	O
</s>
<s>
While	O
OLE	B-Operating_System
1	O
was	O
focused	O
on	O
compound	O
documents	O
,	O
COM	B-Application
and	I-Application
OLE	I-Application
2	O
were	O
designed	O
to	O
address	O
software	B-Architecture
components	I-Architecture
in	O
general	O
.	O
</s>
<s>
Text	O
conversations	O
and	O
Windows	O
messages	O
had	O
proved	O
not	O
to	O
be	O
flexible	O
enough	O
to	O
allow	O
sharing	O
application	O
features	O
in	O
a	O
robust	O
and	O
extensible	O
way	O
,	O
so	O
COM	O
was	O
created	O
as	O
a	O
new	O
foundation	O
,	O
and	O
OLE	B-Operating_System
changed	O
to	O
OLE2	O
.	O
</s>
<s>
In	O
1994	O
OLE	B-Operating_System
custom	B-Library
controls	I-Library
(	O
OCXs	O
)	O
were	O
introduced	O
as	O
the	O
successor	O
to	O
VBX	B-Library
controls	O
.	O
</s>
<s>
At	O
the	O
same	O
time	O
,	O
Microsoft	O
stated	O
that	O
OLE	B-Operating_System
2	O
would	O
just	O
be	O
known	O
as	O
"	O
OLE	B-Operating_System
"	O
,	O
and	O
that	O
OLE	B-Operating_System
was	O
no	O
longer	O
an	O
acronym	O
,	O
but	O
a	O
name	O
for	O
all	O
of	O
the	O
company	O
's	O
component	B-Architecture
technologies	O
.	O
</s>
<s>
In	O
early	O
1996	O
,	O
Microsoft	O
found	O
a	O
new	O
use	O
for	O
OLE	B-Operating_System
Custom	B-Library
Controls	I-Library
,	O
expanding	O
their	O
Web	O
browser	O
's	O
capability	O
to	O
present	O
content	O
,	O
renamed	O
some	O
parts	O
of	O
OLE	B-Operating_System
relating	O
to	O
the	O
Internet	O
"	O
ActiveX	B-Application
"	O
,	O
and	O
gradually	O
renamed	O
all	O
OLE	B-Operating_System
technologies	O
to	O
ActiveX	B-Application
,	O
except	O
the	O
compound	O
document	O
technology	O
that	O
was	O
used	O
in	O
Microsoft	B-Application
Office	I-Application
.	O
</s>
<s>
Later	O
that	O
year	O
,	O
Microsoft	O
extended	O
COM	O
to	O
work	O
across	O
the	O
network	O
with	O
DCOM	B-Operating_System
.	O
</s>
<s>
COM	O
replaced	O
DDE	B-Operating_System
as	O
the	O
preferred	O
form	O
of	O
interprocess	B-Operating_System
communication	I-Operating_System
.	O
</s>
<s>
As	O
a	O
cross-language	O
component	B-Architecture
model	O
,	O
COM	O
relies	O
on	O
an	O
interface	B-Application
definition	O
language	O
,	O
or	O
IDL	O
,	O
to	O
describe	O
the	O
objects	O
and	O
associated	O
functions	O
.	O
</s>
<s>
The	O
COM	O
IDL	O
is	O
based	O
heavily	O
on	O
the	O
feature-rich	O
DCE/RPC	B-General_Concept
IDL	O
,	O
with	O
object-oriented	B-Language
extensions	O
.	O
</s>
<s>
Microsoft	O
's	O
own	O
implementation	O
of	O
DCE/RPC	B-General_Concept
,	O
known	O
as	O
MSRPC	B-General_Concept
,	O
is	O
heavily	O
used	O
as	O
the	O
primary	O
inter-process	B-Operating_System
communication	I-Operating_System
mechanism	O
for	O
Windows	O
NT	O
services	O
and	O
internal	O
components	B-Architecture
,	O
making	O
it	O
an	O
obvious	O
choice	O
of	O
foundation	O
.	O
</s>
<s>
DCOM	B-Operating_System
(	O
Distributed	O
COM	O
)	O
extended	O
the	O
reach	O
of	O
COM	O
from	O
merely	O
supporting	O
a	O
single	O
user	O
with	O
separate	O
applications	O
communicating	O
on	O
the	O
Windows	O
desktop	O
,	O
to	O
activating	O
objects	O
running	O
under	O
different	O
security	O
contexts	O
,	O
and	O
on	O
different	O
machines	O
across	O
the	O
network	O
.	O
</s>
<s>
In	O
order	O
for	O
Microsoft	O
to	O
provide	O
developers	O
with	O
support	O
for	O
distributed	B-General_Concept
transactions	I-General_Concept
,	O
resource	O
pooling	O
,	O
disconnected	O
applications	O
,	O
event	O
publication	O
and	O
subscription	O
,	O
better	O
memory	O
and	O
processor	O
(	O
thread	B-Operating_System
)	O
management	O
,	O
as	O
well	O
as	O
to	O
position	O
Windows	O
as	O
an	O
alternative	O
to	O
other	O
enterprise-level	O
operating	O
systems	O
,	O
Microsoft	O
introduced	O
a	O
technology	O
called	O
Microsoft	B-Operating_System
Transaction	I-Operating_System
Server	I-Operating_System
(	O
MTS	B-Operating_System
)	O
on	O
Windows	O
NT	O
4	O
.	O
</s>
<s>
With	O
Windows	O
2000	O
,	O
that	O
significant	O
extension	O
to	O
COM	O
was	O
incorporated	O
into	O
the	O
operating	O
system	O
(	O
as	O
opposed	O
to	O
the	O
series	O
of	O
external	O
tools	O
provided	O
by	O
MTS	B-Operating_System
)	O
and	O
renamed	O
COM+	O
.	O
</s>
<s>
At	O
the	O
same	O
time	O
,	O
Microsoft	O
de-emphasized	O
DCOM	B-Operating_System
as	O
a	O
separate	O
entity	O
.	O
</s>
<s>
Components	B-Architecture
that	O
made	O
use	O
of	O
COM+	O
services	O
were	O
handled	O
more	O
directly	O
by	O
the	O
added	O
layer	O
of	O
COM+	O
,	O
in	O
particular	O
by	O
operating	O
system	O
support	O
for	O
interception	O
.	O
</s>
<s>
In	O
the	O
first	O
release	O
of	O
MTS	B-Operating_System
,	O
interception	O
was	O
tacked	O
on	O
-	O
installing	O
an	O
MTS	B-Operating_System
component	B-Architecture
would	O
modify	O
the	O
Windows	B-Protocol
Registry	I-Protocol
to	O
call	O
the	O
MTS	B-Operating_System
software	O
,	O
and	O
not	O
the	O
component	B-Architecture
directly	O
.	O
</s>
<s>
Windows	O
2000	O
also	O
revised	O
the	O
Component	B-Architecture
Services	O
control	O
panel	O
application	O
used	O
to	O
configure	O
COM+	O
components	B-Architecture
.	O
</s>
<s>
An	O
advantage	O
of	O
COM+	O
was	O
that	O
it	O
could	O
be	O
run	O
in	O
"	O
component	B-Architecture
farms	O
"	O
.	O
</s>
<s>
Instances	O
of	O
a	O
component	B-Architecture
,	O
if	O
coded	O
properly	O
,	O
could	O
be	O
pooled	O
and	O
reused	O
by	O
new	O
calls	O
to	O
its	O
initializing	O
routine	O
without	O
unloading	O
it	O
from	O
memory	O
.	O
</s>
<s>
Components	B-Architecture
could	O
also	O
be	O
distributed	O
(	O
called	O
from	O
another	O
machine	O
)	O
.	O
</s>
<s>
COM+	O
and	O
Microsoft	B-Application
Visual	I-Application
Studio	I-Application
provided	O
tools	O
to	O
make	O
it	O
easy	O
to	O
generate	O
client-side	O
proxies	O
,	O
so	O
although	O
DCOM	B-Operating_System
was	O
used	O
to	O
make	O
the	O
remote	O
call	O
,	O
it	O
was	O
easy	O
to	O
do	O
for	O
developers	O
.	O
</s>
<s>
COM+	O
also	O
introduced	O
a	O
subscriber/publisher	O
event	O
mechanism	O
called	O
COM+	O
Events	O
,	O
and	O
provided	O
a	O
new	O
way	O
of	O
leveraging	O
MSMQ	B-Application
(	O
a	O
technology	O
that	O
provides	O
inter-application	O
asynchronous	O
messaging	O
)	O
with	O
components	B-Architecture
called	O
Queued	B-Application
Components	I-Application
.	O
</s>
<s>
COM+	O
events	O
extend	O
the	O
COM+	O
programming	O
model	O
to	O
support	O
late-bound	O
(	O
see	O
Late	O
binding	B-Application
)	O
events	O
or	O
method	B-Language
calls	I-Language
between	O
the	O
publisher	O
or	O
subscriber	O
and	O
the	O
event	O
system	O
.	O
</s>
<s>
Microsoft	B-Application
.NET	I-Application
provides	O
means	O
both	O
to	O
provide	O
component	B-Architecture
technology	O
,	O
and	O
to	O
interact	O
with	O
COM+	O
(	O
via	O
COM-interop-assemblies	O
)	O
;	O
.NET	B-Application
provides	O
wrappers	O
to	O
most	O
of	O
the	O
commonly	O
used	O
COM	O
controls	O
.	O
</s>
<s>
Microsoft	B-Application
.NET	I-Application
hides	O
most	O
detail	O
from	O
component	B-Architecture
creation	O
and	O
therefore	O
eases	O
development	O
.	O
</s>
<s>
.NET	B-Application
can	O
leverage	O
COM+	O
via	O
the	O
System.EnterpriseServices	O
namespace	O
,	O
and	O
several	O
of	O
the	O
services	O
that	O
COM+	O
provides	O
have	O
been	O
duplicated	O
in	O
recent	O
releases	O
of	O
.NET	B-Application
.	O
</s>
<s>
For	O
example	O
,	O
the	O
System.Transactions	O
namespace	O
in	O
.NET	B-Application
provides	O
the	O
TransactionScope	O
class	O
,	O
which	O
provides	O
transaction	O
management	O
without	O
resorting	O
to	O
COM+	O
.	O
</s>
<s>
Similarly	O
,	O
queued	B-Application
components	I-Application
can	O
be	O
replaced	O
by	O
Windows	B-Application
Communication	I-Application
Foundation	I-Application
with	O
an	O
MSMQ	B-Application
transport	O
.	O
</s>
<s>
(	O
MSMQ	B-Application
is	O
a	O
native	O
COM	O
component	B-Architecture
,	O
however	O
.	O
)	O
</s>
<s>
A	O
COM	B-Application
object	I-Application
may	O
be	O
used	O
in	O
.NET	B-Application
by	O
implementing	O
a	O
Runtime	B-Application
Callable	I-Application
Wrapper	I-Application
(	O
RCW	O
)	O
.	O
</s>
<s>
NET	O
objects	O
that	O
conform	O
to	O
certain	O
interface	B-Application
restrictions	O
may	O
be	O
used	O
in	O
COM	B-Application
objects	I-Application
by	O
calling	O
a	O
COM	O
callable	O
wrapper	O
(	O
CCW	O
)	O
.	O
</s>
<s>
From	O
both	O
the	O
COM	O
and	O
.NET	B-Application
sides	O
,	O
objects	O
using	O
the	O
other	O
technology	O
appear	O
as	O
native	O
objects	O
.	O
</s>
<s>
See	O
COM	B-Device
Interop	I-Device
.	O
</s>
<s>
WCF	B-Application
(	O
Windows	B-Application
Communication	I-Application
Foundation	I-Application
)	O
eases	O
a	O
number	O
of	O
COM	O
's	O
remote	O
execution	O
challenges	O
.	O
</s>
<s>
For	O
instance	O
,	O
it	O
allows	O
objects	O
to	O
be	O
transparently	O
marshalled	B-Application
by	O
value	O
across	O
process	O
or	O
machine	O
boundaries	O
more	O
easily	O
.	O
</s>
<s>
Microsoft	O
's	O
Windows	O
Runtime	B-Library
(	O
or	O
WinRT	O
,	O
not	O
to	O
be	O
confused	O
with	O
Windows	B-Operating_System
RT	I-Operating_System
)	O
programming	O
and	O
application	O
model	O
is	O
essentially	O
a	O
COM-based	O
API	B-Application
,	O
although	O
it	O
relies	O
on	O
an	O
enhanced	O
COM	O
.	O
</s>
<s>
Because	O
of	O
its	O
COM-like	O
basis	O
,	O
Windows	O
Runtime	B-Library
allows	O
relatively	O
easy	O
interfacing	O
from	O
multiple	O
languages	O
,	O
just	O
as	O
COM	O
does	O
,	O
but	O
it	O
is	O
essentially	O
an	O
unmanaged	O
,	O
native	O
API	B-Application
.	O
</s>
<s>
The	O
API	B-Application
definitions	O
are	O
,	O
however	O
,	O
stored	O
in	O
"	O
.winmd	O
"	O
files	O
,	O
which	O
are	O
encoded	O
in	O
ECMA	O
335	O
metadata	O
format	O
,	O
the	O
same	O
CLI	O
metadata	O
format	O
that	O
.NET	B-Application
uses	O
with	O
a	O
few	O
modifications	O
.	O
</s>
<s>
This	O
common	O
metadata	O
format	O
allows	O
for	O
significantly	O
less	O
overhead	O
than	O
P/Invoke	O
when	O
WinRT	O
is	O
invoked	O
from	O
.NET	B-Application
applications	O
,	O
and	O
its	O
syntax	O
is	O
much	O
simpler	O
.	O
</s>
<s>
Nano-COM	O
is	O
an	O
extremely	O
small	O
subset	O
of	O
the	O
Component	B-Application
Object	I-Application
Model	I-Application
that	O
is	O
focused	O
exclusively	O
on	O
the	O
Application	B-Operating_System
Binary	I-Operating_System
Interface	I-Operating_System
(	O
ABI	O
)	O
aspects	O
of	O
COM	O
that	O
enable	O
function	O
and	O
method	B-Language
calls	I-Language
across	O
independently	O
compiled	B-Language
modules/components	O
.	O
</s>
<s>
Nano-COM	O
can	O
be	O
expressed	O
easily	O
in	O
a	O
single	O
C++	B-Language
header	O
file	O
that	O
is	O
portable	O
to	O
all	O
C++	B-Language
compilers	B-Language
.	O
</s>
<s>
The	O
basis	O
of	O
Nano-COM	O
was	O
used	O
by	O
Mozilla	O
to	O
bootstrap	O
Firefox	O
(	O
called	O
XPCOM	B-Application
)	O
,	O
and	O
is	O
currently	O
in	O
use	O
as	O
the	O
base	O
ABI	O
technology	O
for	O
DirectX/Direct3D/DirectML	O
.	O
</s>
<s>
Some	O
implementations	O
of	O
Nano-COM	O
such	O
as	O
Direct3D	B-Application
eschew	O
the	O
allocator	O
functions	O
and	O
restrict	O
themselves	O
to	O
only	O
use	O
caller-allocated	O
buffers	O
.	O
</s>
<s>
Rather	O
,	O
object	O
references	O
are	O
simply	O
passed	O
across	O
function	O
boundaries	O
and	O
allocated	O
via	O
standard	O
language	O
constructs	O
(	O
e.g.	O
,	O
C++	B-Language
new	O
operator	O
)	O
.	O
</s>
<s>
COM	O
and	O
ActiveX	B-Application
components	I-Application
are	O
run	O
as	O
native	O
code	O
on	O
the	O
user	O
's	O
machine	O
,	O
with	O
no	O
sandboxing	O
.	O
</s>
<s>
The	O
prior	O
practice	O
of	O
embedding	O
ActiveX	B-Application
components	I-Application
on	O
web	O
pages	O
with	O
Internet	B-Application
Explorer	I-Application
did	O
therefore	O
lead	O
to	O
problems	O
with	O
malware	O
infections	O
.	O
</s>
<s>
Microsoft	O
recognized	O
the	O
problem	O
with	O
ActiveX	B-Application
as	O
far	O
back	O
as	O
1996	O
when	O
Charles	O
Fitzgerald	O
said	O
,	O
"	O
We	O
never	O
made	O
the	O
claim	O
up	O
front	O
that	O
ActiveX	B-Application
is	O
intrinsically	O
secure	O
"	O
.	O
</s>
<s>
Recent	O
versions	O
of	O
Internet	B-Application
Explorer	I-Application
prompt	O
the	O
user	O
before	O
installing	O
ActiveX	B-Application
controls	I-Application
,	O
enabling	O
the	O
user	O
to	O
disallow	O
installation	O
of	O
controls	O
from	O
sites	O
that	O
the	O
user	O
does	O
not	O
trust	O
.	O
</s>
<s>
The	O
ActiveX	B-Application
controls	I-Application
are	O
signed	O
with	O
digital	O
signatures	O
to	O
guarantee	O
their	O
authenticity	O
.	O
</s>
<s>
It	O
is	O
also	O
possible	O
to	O
disable	O
ActiveX	B-Application
controls	I-Application
altogether	O
,	O
or	O
to	O
allow	O
only	O
a	O
selected	O
few	O
.	O
</s>
<s>
The	O
transparent	O
support	O
for	O
out-of-process	O
COM	B-Application
servers	I-Application
still	O
promotes	O
software	O
safety	O
in	O
terms	O
of	O
process	O
isolation	O
.	O
</s>
<s>
COM	O
programmers	O
build	O
their	O
software	O
using	O
COM-aware	O
components	B-Architecture
.	O
</s>
<s>
Different	O
component	B-Architecture
types	O
are	O
identified	O
by	O
class	O
IDs	O
(	O
CLSIDs	O
)	O
,	O
which	O
are	O
Globally	O
Unique	O
Identifiers	O
(	O
GUIDs	O
)	O
.	O
</s>
<s>
Each	O
COM	O
component	B-Architecture
exposes	O
its	O
functionality	O
through	O
one	O
or	O
more	O
interfaces	O
.	O
</s>
<s>
The	O
different	O
interfaces	O
supported	O
by	O
a	O
component	B-Architecture
are	O
distinguished	O
from	O
each	O
other	O
using	O
interface	B-Application
IDs	O
(	O
IIDs	O
)	O
,	O
which	O
are	O
GUIDs	O
too	O
.	O
</s>
<s>
COM	O
interfaces	O
have	O
bindings	O
in	O
several	O
languages	O
,	O
such	O
as	O
C	B-Language
,	O
C++	B-Language
,	O
Visual	B-Application
Basic	I-Application
,	O
Delphi	B-Language
,	O
Python	B-Language
and	O
several	O
of	O
the	O
scripting	O
languages	O
implemented	O
on	O
the	O
Windows	O
platform	O
.	O
</s>
<s>
All	O
access	O
to	O
components	B-Architecture
is	O
done	O
through	O
the	O
methods	B-Language
of	O
the	O
interfaces	O
.	O
</s>
<s>
This	O
allows	O
techniques	O
such	O
as	O
inter-process	O
,	O
or	O
even	O
inter-computer	O
programming	O
(	O
the	O
latter	O
using	O
the	O
support	O
of	O
DCOM	B-Operating_System
)	O
.	O
</s>
<s>
All	O
COM	O
components	B-Architecture
implement	O
the	O
IUnknown	B-Application
(	O
custom	O
)	O
interface	B-Application
,	O
which	O
exposes	O
methods	B-Language
for	O
reference	B-General_Concept
counting	I-General_Concept
and	O
type	O
conversion	O
(	O
casting	O
)	O
.	O
</s>
<s>
A	O
custom	O
IUnknown	B-Application
interface	B-Application
consists	O
of	O
a	O
pointer	O
to	O
a	O
virtual	B-Language
method	I-Language
table	I-Language
that	O
contains	O
a	O
list	O
of	O
pointers	O
to	O
the	O
functions	O
that	O
implement	O
the	O
functions	O
declared	O
in	O
the	O
interface	B-Application
,	O
in	O
the	O
same	O
order	O
that	O
they	O
are	O
declared	O
in	O
the	O
interface	B-Application
.	O
</s>
<s>
The	O
in-process	O
invocation	O
overhead	O
is	O
therefore	O
comparable	O
to	O
virtual	O
method	B-Language
calls	I-Language
in	O
C++	B-Language
.	O
</s>
<s>
In	O
addition	O
to	O
custom	O
interfaces	O
,	O
COM	O
also	O
supports	O
dispatch	O
interfaces	O
inheriting	O
from	O
IDispatch	B-Application
.	O
</s>
<s>
Dispatch	O
interfaces	O
support	O
late	O
binding	B-Application
for	O
OLE	B-Application
Automation	I-Application
.	O
</s>
<s>
A	O
COM	O
class	O
(	O
"	O
coclass	O
"	O
)	O
is	O
a	O
concrete	O
implementation	O
of	O
one	O
or	O
more	O
interfaces	O
,	O
and	O
closely	O
resembles	O
classes	O
in	O
object-oriented	B-Language
programming	I-Language
languages	I-Language
.	O
</s>
<s>
Classes	O
are	O
created	O
based	O
on	O
their	O
class	O
ID	O
(	O
CLSID	O
)	O
or	O
based	O
on	O
their	O
programmatic	O
identifier	O
string	O
(	O
ProgID	B-Application
)	O
.	O
</s>
<s>
Like	O
many	O
object-oriented	B-Language
languages	I-Language
,	O
COM	O
provides	O
a	O
separation	O
of	O
interface	B-Application
from	O
implementation	O
.	O
</s>
<s>
COM	O
also	O
has	O
support	O
for	O
multiple	O
implementations	O
of	O
the	O
same	O
interface	B-Application
,	O
so	O
that	O
clients	O
at	B-Library
runtime	I-Library
can	O
choose	O
which	O
implementation	O
of	O
an	O
interface	B-Application
to	O
instantiate	O
.	O
</s>
<s>
These	O
types	O
are	O
described	O
using	O
Microsoft	B-Application
Interface	I-Application
Definition	I-Application
Language	I-Application
(	O
MSIDL/IDL	O
)	O
.	O
</s>
<s>
IDL	O
files	O
define	O
object-oriented	B-Language
classes	O
,	O
interfaces	O
,	O
structures	O
,	O
enumerations	O
and	O
other	O
user-defined	O
types	O
in	O
a	O
language	O
independent	O
manner	O
.	O
</s>
<s>
IDL	O
is	O
similar	O
in	O
appearance	O
to	O
C++	B-Language
declarations	O
with	O
some	O
additional	O
keywords	O
such	O
as	O
"	O
interface	B-Application
"	O
and	O
"	O
library	O
"	O
for	O
defining	O
interfaces	O
and	O
collections	O
of	O
classes	O
.	O
</s>
<s>
IDL	O
also	O
supports	O
the	O
use	O
of	O
bracketed	O
attributes	O
before	O
declarations	O
to	O
provide	O
additional	O
information	O
,	O
such	O
as	O
interface	B-Application
GUIDs	O
and	O
the	O
relationships	O
between	O
pointer	O
parameters	O
and	O
length	O
fields	O
.	O
</s>
<s>
IDL	O
files	O
are	O
compiled	B-Language
by	O
the	O
MIDL	B-Application
compiler	B-Language
.	O
</s>
<s>
For	O
C/C	O
++	O
,	O
the	O
MIDL	B-Application
compiler	B-Language
generates	O
a	O
compiler-independent	O
header	O
file	O
containing	O
struct	O
definitions	O
to	O
match	O
the	O
vtbls	B-Language
of	O
the	O
declared	O
interfaces	O
and	O
a	O
C	B-Language
file	O
containing	O
declarations	O
of	O
the	O
interface	B-Application
GUIDs	O
.	O
</s>
<s>
C++	B-Language
source	O
code	O
for	O
a	O
proxy	O
module	O
can	O
also	O
be	O
generated	O
by	O
the	O
MIDL	B-Application
compiler	B-Language
.	O
</s>
<s>
This	O
proxy	O
contains	O
method	O
stubs	O
for	O
converting	O
COM	O
calls	O
into	O
remote	B-Operating_System
procedure	I-Operating_System
calls	I-Operating_System
to	O
enable	O
DCOM	B-Operating_System
for	O
out-of-process	O
communication	O
.	O
</s>
<s>
IDL	O
files	O
can	O
also	O
be	O
compiled	B-Language
by	O
the	O
MIDL	B-Application
compiler	B-Language
into	O
a	O
type	O
library	O
(	O
TLB	O
)	O
.	O
</s>
<s>
TLB	O
files	O
contain	O
binary	O
metadata	O
that	O
can	O
be	O
processed	O
by	O
different	O
language	B-Language
compilers	I-Language
and	O
runtime	B-Library
environments	O
(	O
e.g.	O
</s>
<s>
VB	O
,	O
Delphi	B-Language
,	O
.NET	B-Application
etc	O
.	O
)	O
</s>
<s>
For	O
C++	B-Language
,	O
this	O
will	O
convert	O
the	O
TLB	O
back	O
to	O
its	O
IDL	O
representation	O
.	O
</s>
<s>
Because	O
COM	O
is	O
a	O
runtime	B-Library
framework	O
,	O
types	O
have	O
to	O
be	O
individually	O
identifiable	O
and	O
specifiable	O
at	B-Library
runtime	I-Library
.	O
</s>
<s>
Each	O
COM	O
type	O
is	O
designated	O
its	O
own	O
GUID	O
for	O
identification	O
at	B-Library
runtime	I-Library
.	O
</s>
<s>
In	O
order	O
for	O
information	O
on	O
COM	O
types	O
to	O
be	O
accessible	O
at	O
both	O
compile	B-Language
time	O
and	O
runtime	B-Library
,	O
COM	O
uses	O
type	O
libraries	O
.	O
</s>
<s>
The	O
above	O
code	O
fragment	O
declares	O
a	O
COM	O
class	O
named	O
SomeClass	O
which	O
implements	O
an	O
interface	B-Application
named	O
ISomeInterface	O
.	O
</s>
<s>
This	O
is	O
conceptually	O
equivalent	O
to	O
defining	O
the	O
following	O
C++	B-Language
class	O
:	O
</s>
<s>
where	O
ISomeInterface	O
is	O
a	O
C++	B-Language
pure	O
virtual	O
class	O
(	O
sometimes	O
called	O
an	O
abstract	O
base	O
class	O
)	O
.	O
</s>
<s>
The	O
IDL	O
files	O
containing	O
COM	O
interfaces	O
and	O
classes	O
are	O
compiled	B-Language
into	O
type	O
libraries	O
(	O
TLB	O
)	O
files	O
,	O
which	O
can	O
later	O
be	O
parsed	O
by	O
clients	O
at	B-Library
runtime	I-Library
to	O
determine	O
which	O
interfaces	O
an	O
object	O
supports	O
,	O
and	O
invoke	O
an	O
object	O
's	O
interface	B-Application
methods	B-Language
.	O
</s>
<s>
In	O
C++	B-Language
,	O
COM	B-Application
objects	I-Application
are	O
instantiated	O
with	O
the	O
CoCreateInstance	O
function	O
that	O
takes	O
the	O
class	O
ID	O
(	O
CLSID	O
)	O
and	O
interface	B-Application
ID	O
(	O
IID	O
)	O
as	O
arguments	O
.	O
</s>
<s>
In	O
this	O
example	O
,	O
the	O
COM	O
sub-system	O
is	O
used	O
to	O
obtain	O
a	O
pointer	O
to	O
an	O
object	O
that	O
implements	O
ISomeInterface	O
interface	B-Application
,	O
and	O
coclass	O
CLSID_SomeClass	O
's	O
particular	O
implementation	O
of	O
this	O
interface	B-Application
is	O
required	O
.	O
</s>
<s>
All	O
COM	B-Application
objects	I-Application
utilize	O
reference	B-General_Concept
counting	I-General_Concept
to	O
manage	O
object	O
lifetimes	O
.	O
</s>
<s>
The	O
reference	B-General_Concept
counts	I-General_Concept
are	O
controlled	O
by	O
the	O
clients	O
through	O
the	O
AddRef	O
and	O
Release	O
methods	B-Language
in	O
the	O
mandatory	O
IUnknown	B-Application
interface	B-Application
that	O
all	O
COM	B-Application
objects	I-Application
implement	O
.	O
</s>
<s>
COM	B-Application
objects	I-Application
are	O
then	O
responsible	O
for	O
freeing	O
their	O
own	O
memory	O
when	O
the	O
reference	B-General_Concept
count	I-General_Concept
drops	O
to	O
zero	O
.	O
</s>
<s>
Visual	B-Application
Basic	I-Application
)	O
provide	O
automatic	O
reference	B-General_Concept
counting	I-General_Concept
so	O
that	O
COM	B-Application
object	I-Application
developers	O
need	O
not	O
explicitly	O
maintain	O
any	O
internal	O
reference	O
counter	O
in	O
their	O
source	O
codes	O
.	O
</s>
<s>
In	O
C++	B-Language
,	O
a	O
coder	O
may	O
either	O
perform	O
explicit	O
reference	B-General_Concept
counting	I-General_Concept
or	O
use	O
smart	B-Language
pointers	I-Language
to	O
automatically	O
manage	O
the	O
reference	B-General_Concept
counts	I-General_Concept
.	O
</s>
<s>
The	O
following	O
are	O
guidelines	O
for	O
when	O
to	O
call	O
AddRef	O
and	O
Release	O
on	O
COM	B-Application
objects	I-Application
:	O
</s>
<s>
Functions	O
and	O
methods	B-Language
that	O
return	O
interface	B-Application
references	O
(	O
via	O
return	O
value	O
or	O
via	O
"	O
out	O
"	O
parameter	O
)	O
shall	O
increment	O
the	O
reference	B-General_Concept
count	I-General_Concept
of	O
the	O
returned	O
object	O
before	O
returning	O
.	O
</s>
<s>
Release	O
must	O
be	O
called	O
on	O
an	O
interface	B-Application
pointer	O
before	O
the	O
pointer	O
is	O
overwritten	O
or	O
goes	O
out	O
of	O
scope	O
.	O
</s>
<s>
If	O
a	O
copy	O
is	O
made	O
on	O
an	O
interface	B-Application
reference	O
pointer	O
,	O
AddRef	O
should	O
be	O
called	O
on	O
that	O
pointer	O
.	O
</s>
<s>
AddRef	O
and	O
Release	O
must	O
be	O
called	O
on	O
the	O
specific	O
interface	B-Application
which	O
is	O
being	O
referenced	O
since	O
an	O
object	O
may	O
implement	O
per-interface	O
reference	B-General_Concept
counts	I-General_Concept
in	O
order	O
to	O
allocate	O
internal	O
resources	O
only	O
for	O
the	O
interfaces	O
which	O
are	O
being	O
referenced	O
.	O
</s>
<s>
Not	O
all	O
reference	B-General_Concept
count	I-General_Concept
calls	O
are	O
sent	O
to	O
remote	O
objects	O
over	O
the	O
wire	O
;	O
a	O
proxy	O
keeps	O
only	O
one	O
reference	O
on	O
the	O
remote	O
object	O
and	O
maintains	O
its	O
own	O
local	O
reference	B-General_Concept
count	I-General_Concept
.	O
</s>
<s>
To	O
simplify	O
COM	O
development	O
,	O
Microsoft	O
introduced	O
ATL	O
(	O
Active	B-Language
Template	I-Language
Library	I-Language
)	O
for	O
C++	B-Language
developers	O
.	O
</s>
<s>
It	O
also	O
shields	O
COM	O
client	O
application	O
developers	O
from	O
the	O
need	O
to	O
directly	O
maintain	O
reference	B-General_Concept
counting	I-General_Concept
,	O
by	O
providing	O
smart	B-Language
pointer	I-Language
objects	O
.	O
</s>
<s>
Other	O
libraries	O
and	O
languages	O
that	O
are	O
COM-aware	O
include	O
the	O
Microsoft	B-Language
Foundation	I-Language
Classes	I-Language
,	O
the	O
VC	B-Application
Compiler	B-Language
COM	O
Support	O
,	O
VBScript	B-Application
,	O
Visual	B-Application
Basic	I-Application
,	O
ECMAScript	B-Language
(	O
JavaScript	B-Language
)	O
and	O
Borland	B-Language
Delphi	I-Language
.	O
</s>
<s>
COM	O
is	O
a	O
language	B-Language
agnostic	I-Language
binary	O
standard	O
that	O
can	O
be	O
developed	O
in	O
any	O
programming	O
language	O
capable	O
of	O
understanding	O
and	O
implementing	O
its	O
binary	O
defined	O
data	O
types	O
and	O
interfaces	O
.	O
</s>
<s>
COM	O
implementations	O
are	O
responsible	O
for	O
entering	O
and	O
leaving	O
the	O
COM	O
environment	O
,	O
instantiating	O
and	O
reference-counting	B-General_Concept
COM	B-Application
objects	I-Application
,	O
querying	O
objects	O
for	O
supported	O
interfaces	O
,	O
as	O
well	O
as	O
handling	O
errors	O
.	O
</s>
<s>
The	O
Microsoft	B-Application
Visual	I-Application
C++	I-Application
compiler	B-Language
supports	O
extensions	O
to	O
the	O
C++	B-Language
language	I-Language
referred	O
to	O
as	O
C++	B-Language
Attributes	O
.	O
</s>
<s>
These	O
extensions	O
are	O
designed	O
to	O
simplify	O
COM	O
development	O
and	O
remove	O
much	O
of	O
the	O
boilerplate	O
code	O
required	O
to	O
implement	O
COM	B-Application
servers	I-Application
in	O
C++	B-Language
.	O
</s>
<s>
In	O
Windows	O
,	O
COM	O
classes	O
,	O
interfaces	O
and	O
type	O
libraries	O
are	O
listed	O
by	O
GUIDs	O
in	O
the	O
registry	B-Protocol
,	O
under	O
HKEY_CLASSES_ROOT	O
\CLSID	O
for	O
classes	O
and	O
HKEY_CLASSES_ROOT	O
\Interface	O
for	O
interfaces	O
.	O
</s>
<s>
COM	O
libraries	O
use	O
the	O
registry	B-Protocol
to	O
locate	O
either	O
the	O
correct	O
local	O
libraries	O
for	O
each	O
COM	B-Application
object	I-Application
or	O
the	O
network	O
location	O
for	O
a	O
remote	O
service	O
.	O
</s>
<s>
Registration-Free	O
COM	O
(	O
RegFree	O
COM	O
)	O
is	O
a	O
technology	O
introduced	O
with	O
Windows	B-Application
XP	I-Application
that	O
allows	O
Component	B-Application
Object	I-Application
Model	I-Application
(	O
COM	O
)	O
components	B-Architecture
to	O
store	O
activation	O
metadata	O
and	O
CLSID	O
(	O
Class	O
ID	O
)	O
for	O
the	O
component	B-Architecture
without	O
using	O
the	O
registry	B-Protocol
.	O
</s>
<s>
Instead	O
,	O
the	O
metadata	O
and	O
CLSIDs	O
of	O
the	O
classes	O
implemented	O
in	O
the	O
component	B-Architecture
are	O
declared	O
in	O
an	O
assembly	O
manifest	O
(	O
described	O
using	O
XML	B-Protocol
)	O
,	O
stored	O
either	O
as	O
a	O
resource	O
in	O
the	O
executable	O
or	O
as	O
a	O
separate	O
file	O
installed	O
with	O
the	O
component	B-Architecture
.	O
</s>
<s>
This	O
allows	O
multiple	O
versions	O
of	O
the	O
same	O
component	B-Architecture
to	O
be	O
installed	O
in	O
different	O
directories	O
,	O
described	O
by	O
their	O
own	O
manifests	O
,	O
as	O
well	O
as	O
XCOPY	B-Application
deployment	I-Application
.	O
</s>
<s>
This	O
technique	O
has	O
limited	O
support	O
for	O
EXE	O
COM	B-Application
servers	I-Application
and	O
cannot	O
be	O
used	O
for	O
system-wide	O
components	B-Architecture
such	O
as	O
MDAC	B-Library
,	O
MSXML	B-Application
,	O
DirectX	B-Application
or	O
Internet	B-Application
Explorer	I-Application
.	O
</s>
<s>
Only	O
if	O
the	O
lookup	O
fails	O
,	O
the	O
registry	B-Protocol
is	O
scanned	O
.	O
</s>
<s>
COM	B-Application
objects	I-Application
can	O
also	O
be	O
created	O
manually	O
,	O
given	O
the	O
path	O
of	O
the	O
DLL	O
file	O
and	O
GUID	O
of	O
the	O
object	O
.	O
</s>
<s>
This	O
does	O
not	O
require	O
the	O
DLL	O
or	O
GUID	O
to	O
be	O
registered	O
in	O
the	O
system	B-Protocol
registry	I-Protocol
,	O
and	O
does	O
not	O
make	O
use	O
of	O
manifest	O
files	O
.	O
</s>
<s>
Calling	O
DllGetClassObject	O
with	O
the	O
desired	O
GUID	O
and	O
IID_IClassFactory	O
provides	O
an	O
instance	O
of	O
a	O
factory	B-Application
object	I-Application
.	O
</s>
<s>
The	O
Factory	B-Application
object	I-Application
has	O
a	O
CreateInstance	O
method	O
,	O
which	O
can	O
create	O
instances	O
of	O
an	O
object	O
given	O
an	O
interface	B-Application
GUID	O
.	O
</s>
<s>
This	O
is	O
the	O
same	O
process	O
internally	O
used	O
when	O
creating	O
instances	O
of	O
registered	O
COM	O
components	B-Architecture
.	O
</s>
<s>
If	O
the	O
created	O
COM	B-Application
object	I-Application
instantiates	O
another	O
COM	B-Application
object	I-Application
using	O
the	O
generic	O
CoCreateInstance	O
API	B-Application
,	O
it	O
will	O
try	O
to	O
do	O
so	O
in	O
the	O
usual	O
generic	O
way	O
,	O
using	O
the	O
registry	B-Protocol
or	O
manifest	O
files	O
.	O
</s>
<s>
COM	B-Application
objects	I-Application
can	O
be	O
transparently	O
instantiated	O
and	O
referenced	O
from	O
within	O
the	O
same	O
process	O
(	O
in-process	O
)	O
,	O
across	O
process	O
boundaries	O
(	O
out-of-process	O
)	O
,	O
or	O
remotely	O
over	O
the	O
network	O
(	O
DCOM	B-Operating_System
)	O
.	O
</s>
<s>
Out-of-process	O
and	O
remote	O
objects	O
use	O
marshalling	B-Application
to	O
serialize	B-Application
method	B-Language
calls	I-Language
and	O
return	O
values	O
over	O
process	O
or	O
network	O
boundaries	O
.	O
</s>
<s>
This	O
marshalling	B-Application
is	O
invisible	O
to	O
the	O
client	O
,	O
which	O
accesses	O
the	O
object	O
as	O
if	O
it	O
were	O
a	O
local	O
in-process	O
object	O
.	O
</s>
<s>
An	O
individual	O
COM	B-Application
object	I-Application
lives	O
in	O
exactly	O
one	O
apartment	O
,	O
which	O
might	O
either	O
be	O
single-threaded	B-Operating_System
or	O
multi-threaded	B-Operating_System
.	O
</s>
<s>
There	O
are	O
three	O
types	O
of	O
apartments	O
in	O
COM	O
:	O
Single-Threaded	B-Operating_System
Apartment	O
(	O
STA	O
)	O
,	O
Multi-Threaded	B-Operating_System
Apartment	O
(	O
MTA	O
)	O
,	O
and	O
Thread	B-Operating_System
Neutral	O
Apartment	O
(	O
NA	O
)	O
.	O
</s>
<s>
Each	O
apartment	O
represents	O
one	O
mechanism	O
whereby	O
an	O
object	O
's	O
internal	O
state	O
may	O
be	O
synchronized	O
across	O
multiple	O
threads	B-Operating_System
.	O
</s>
<s>
A	O
process	O
can	O
consist	O
of	O
multiple	O
COM	B-Application
objects	I-Application
,	O
some	O
of	O
which	O
may	O
use	O
STA	O
and	O
others	O
of	O
which	O
may	O
use	O
MTA	O
.	O
</s>
<s>
All	O
threads	B-Operating_System
accessing	O
COM	B-Application
objects	I-Application
similarly	O
live	O
in	O
one	O
apartment	O
.	O
</s>
<s>
The	O
choice	O
of	O
apartment	O
for	O
COM	B-Application
objects	I-Application
and	O
threads	B-Operating_System
are	O
determined	O
at	O
run-time	O
,	O
and	O
cannot	O
be	O
changed	O
.	O
</s>
<s>
Apartment	O
type	O
Description	O
Single-Threaded	B-Operating_System
ApartmentMicrosoft	O
MSDN	O
:	O
Single-Threaded	B-Operating_System
Apartments	O
(	O
STA	O
)	O
,	O
(	O
ThreadingModel	O
=	O
Apartment	O
)	O
A	O
single	B-Operating_System
thread	I-Operating_System
is	O
dedicated	O
to	O
execute	O
the	O
methods	B-Language
of	O
the	O
object	O
.	O
</s>
<s>
In	O
such	O
an	O
arrangement	O
,	O
method	B-Language
calls	I-Language
from	O
threads	B-Operating_System
outside	O
of	O
the	O
apartment	O
are	O
marshalled	B-Application
and	O
automatically	O
queued	O
by	O
the	O
system	O
(	O
via	O
a	O
standard	O
Windows	O
message	O
queue	B-Application
)	O
.	O
</s>
<s>
Thus	O
,	O
the	O
COM	O
run-time	O
provides	O
automatic	O
synchronization	O
to	O
ensure	O
that	O
each	O
method	B-Language
call	I-Language
of	O
an	O
object	O
is	O
always	O
executed	O
to	O
completion	O
before	O
another	O
is	O
invoked	O
.	O
</s>
<s>
The	O
developer	O
therefore	O
does	O
not	O
need	O
to	O
worry	O
about	O
thread	B-Operating_System
locking	O
or	O
race	O
conditions	O
.	O
</s>
<s>
Multi-Threaded	B-Operating_System
ApartmentMicrosoft	O
MSDN	O
:	O
Multithreaded	O
Apartments	O
(	O
MTA	O
)	O
,	O
(	O
ThreadingModel	O
=	O
Free	O
)	O
The	O
COM	O
run-time	O
provides	O
no	O
synchronization	O
,	O
and	O
multiple	O
threads	B-Operating_System
are	O
allowed	O
to	O
call	O
COM	B-Application
objects	I-Application
simultaneously	O
.	O
</s>
<s>
COM	B-Application
objects	I-Application
therefore	O
need	O
to	O
perform	O
their	O
own	O
synchronization	O
to	O
prevent	O
simultaneous	O
access	O
from	O
multiple	O
threads	B-Operating_System
from	O
causing	O
a	O
race	O
condition	O
.	O
</s>
<s>
Calls	O
to	O
an	O
MTA	O
object	O
from	O
a	O
thread	B-Operating_System
in	O
an	O
STA	O
are	O
also	O
marshalled	B-Application
.	O
</s>
<s>
Dynamically	O
determined	O
apartment	O
(	O
ThreadingModel	O
=	O
Both	O
)	O
In	O
the	O
Both	O
apartment	O
mode	O
,	O
the	O
server	O
auto-selects	O
STA	O
or	O
MTA	O
at	O
object	O
creation	O
to	O
match	O
the	O
apartment	O
type	O
of	O
the	O
calling	O
thread.Microsoft	O
MSDN	O
:	O
Understanding	O
and	O
Using	O
COM	O
Threading	O
Models	O
This	O
can	O
be	O
useful	O
to	O
avoid	O
marshaling	O
overhead	O
when	O
MTA	O
servers	O
are	O
accessed	O
by	O
a	O
STA	O
thread	B-Operating_System
.	O
</s>
<s>
Thread	B-Operating_System
Neutral	O
Apartment	O
(	O
NA	O
)	O
,	O
(	O
ThreadingModel	O
=	O
Neutral	O
)	O
A	O
special	O
apartment	O
without	O
any	O
assigned	O
threads	B-Operating_System
.	O
</s>
<s>
When	O
an	O
STA	O
or	O
MTA	O
thread	B-Operating_System
calls	O
an	O
NA	O
object	O
in	O
the	O
same	O
process	O
,	O
then	O
the	O
calling	O
thread	B-Operating_System
temporarily	O
leaves	O
its	O
apartment	O
and	O
executes	O
code	O
directly	O
in	O
the	O
NA	O
without	O
any	O
thread	B-Operating_System
switching.Codeguru	O
:	O
Understanding	O
COM	O
Apartments	O
Therefore	O
,	O
one	O
can	O
think	O
of	O
NA	O
as	O
an	O
optimization	O
for	O
efficient	O
interapartment	O
method	B-Language
calls	I-Language
.	O
</s>
<s>
Threads	B-Operating_System
and	O
objects	O
which	O
belong	O
to	O
the	O
same	O
apartment	O
follow	O
the	O
same	O
thread	B-Operating_System
access	O
rules	O
.	O
</s>
<s>
Method	B-Language
calls	I-Language
which	O
are	O
made	O
inside	O
the	O
same	O
apartment	O
are	O
therefore	O
performed	O
directly	O
without	O
any	O
assistance	O
from	O
COM	O
.	O
</s>
<s>
Method	B-Language
calls	I-Language
made	O
across	O
apartments	O
are	O
achieved	O
via	O
marshalling	B-Application
.	O
</s>
<s>
This	O
window	O
must	O
have	O
its	O
message	O
queue	B-Application
regularly	O
"	O
pumped	O
"	O
.	O
</s>
<s>
This	O
construct	O
is	O
known	O
as	O
a	O
"	O
message	B-General_Concept
pump	I-General_Concept
"	O
.	O
</s>
<s>
This	O
problem	O
is	O
complicated	O
by	O
some	O
Windows	O
APIs	B-Application
that	O
initialize	O
COM	O
as	O
part	O
of	O
their	O
implementation	O
,	O
which	O
causes	O
a	O
"	O
leak	O
"	O
of	O
implementation	O
details	O
.	O
</s>
<s>
Reference	B-General_Concept
counting	I-General_Concept
within	O
COM	O
may	O
cause	O
problems	O
if	O
two	O
or	O
more	O
objects	O
are	O
circularly	O
referenced	O
.	O
</s>
<s>
Objects	O
may	O
also	O
be	O
left	O
with	O
active	O
reference	B-General_Concept
counts	I-General_Concept
if	O
the	O
COM	O
"	O
event	O
sink	O
"	O
model	O
is	O
used	O
.	O
</s>
<s>
Since	O
the	O
object	O
that	O
fires	O
the	O
event	O
needs	O
a	O
reference	O
to	O
the	O
object	O
reacting	O
to	O
the	O
event	O
,	O
the	O
latter	O
's	O
reference	B-General_Concept
count	I-General_Concept
will	O
never	O
reach	O
zero	O
.	O
</s>
<s>
In	O
the	O
split	O
identity	O
technique	O
,	O
a	O
single	O
implementation	O
exposes	O
two	O
separate	O
COM	B-Application
objects	I-Application
(	O
also	O
known	O
as	O
identities	O
)	O
.	O
</s>
<s>
This	O
creates	O
a	O
weak	B-General_Concept
reference	I-General_Concept
between	O
the	O
COM	B-Application
objects	I-Application
,	O
preventing	O
a	O
reference	O
cycle	O
.	O
</s>
<s>
Because	O
in-process	O
COM	O
components	B-Architecture
are	O
implemented	O
in	O
DLL	O
files	O
and	O
registration	O
only	O
allows	O
for	O
a	O
single	O
version	O
per	O
CLSID	O
,	O
they	O
might	O
in	O
some	O
situations	O
be	O
subject	O
to	O
the	O
"	O
DLL	O
Hell	O
"	O
effect	O
.	O
</s>
<s>
Registration-free	O
COM	O
capability	O
eliminates	O
this	O
problem	O
for	O
in-process	O
components	B-Architecture
;	O
registration-free	O
COM	O
is	O
not	O
available	O
for	O
out-of-process	O
servers	O
.	O
</s>
