Inproc Object Custom Interface in Apartment Model Client

Last reviewed: July 25, 1996
Article ID: Q137629
The information in this article applies to:
  • Microsoft 32 bit OLE libraries included with:

        - Microsoft Windows NT version 3.51
        - Microsoft Windows 95 version 4.0
    

SUMMARY

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

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 reference words: 4.00 CreateThread 32 bit
KBCategory: kbole kbprg
KBSubcategory: LeTwoArc


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 25, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.