Microsoft KB Archive/137629

= Inproc Object Custom Interface in Apartment Model Client =

Article ID: 137629

Article Last Modified on 3/16/2005

-

APPLIES TO

 Microsoft 32-bit OLE libraries, when used with:  Microsoft Windows NT 3.51 Service Pack 5

 Microsoft Windows NT 4.0

 Microsoft Windows 95

 Microsoft Windows 2000 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q137629

<div class="summary_section">

SUMMARY
Single threaded inproc objects (not marked with a ThreadingModel value), must provide marshaling code for any custom interfaces that they may implement.

<div class="moreinformation_section">

MORE INFORMATION
An OLE inproc object that is not marked with the ThreadingModel value in the system registry is considered single threaded.

When an apartment model threaded client creates instances of this inproc object in its different threads, OLE cannot load the objects into those threads. This is because the object is single threaded and is not designed for multithreaded access by a client. Instead, OLE will instantiate the object in the main apartment (thread) of the client. (The main apartment is the thread that first called Co/OleIntialize.) The object will be marshaled to the other threads of the client that require use of it. This marshaling requires the inproc object to provide marshaling code for any custom interfaces it may implement. (The MIDL compiler can be used to generate marshaling code.)

If this inproc object doesn't provide marshaling code for its custom interfaces, it can be used only by single threaded clients or by clients that use the object only from the main apartment.

An object that is marked ThreadingModel=Apartment or ThreadingModel=Both is apartment model-aware. When an apartment model threaded client creates instances of this inproc object in its different threads, each instance will be instantiated in the respective apartments. Consequently the object need not provide marshaling code for any custom interfaces that it may implement.

Additional query words: 4.00 CreateThread 32 bit

Keywords: kbinprocsvr KB137629

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.