DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3
  1. #1
    Join Date
    May 2009
    Cambridgeshire, UK

    Question Creating in-proc COM Objects in the right apartment

    If a client wants to create an in-proc server COM object marked as FreeThreaded in the registry, does the client need to create this object on an MTA thread? What happens if it creates the object in an STA thread - is the object still created in the MTA and the interface pointer marshalled, or is the object created in the calling thread ie. STA?

    I have read 2 different contradicting things about this scenario. One scenario says that the calling thread is in charge of the apartment it wants to create the in-proc COM object in - the object is created in the calling thread's apartment. However, another source says that the in-proc object is always created in the apartment indicated in the registry and the interface pointer marshalled between interfaces.

    Can anyone clarify this for me?

  2. #2
    Join Date
    Dec 2007
    an in-proc server COM object with a CLSID marked as ThreadingModel=Free in the registry will always be instantiated in the MTA. a thread in an STA would have to access the object via a proxy (the interface pointer would be marshaled to the STA).

    unless there is a special reason (eg. the object implementation creates worker threads that will need access to the object), the specified registry entry should be ThreadingModel=Both. in this case, the object will be instantiated in the apartment of the client thread and the object can be directly accessed.

    see Essential COM by Don Box - chapter 5. http://books.google.com/books?id=kfR...over#PPA203,M1
    Last edited by vijayan; 05-13-2009 at 09:05 AM.

  3. #3
    Join Date
    May 2009
    Cambridgeshire, UK


    Thanks :-)

Similar Threads

  1. Replies: 0
    Last Post: 08-26-2005, 11:35 AM
  2. Creating users from stored proc
    By Andrew Merisanu in forum Database
    Replies: 3
    Last Post: 03-05-2001, 03:29 PM
  3. Creating remote objects on win95/workstations
    By ranga raghunathan in forum Enterprise
    Replies: 1
    Last Post: 07-10-2000, 12:36 AM
  4. Creating remote objects on win95/workstations
    By ranga raghunathan in forum Enterprise
    Replies: 4
    Last Post: 06-07-2000, 07:11 AM
  5. creating arrays of objects (textboxes)
    By zoes in forum VB Classic
    Replies: 1
    Last Post: 05-20-2000, 01:16 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.