Creating in-proc COM Objects in the right apartment


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Creating in-proc COM Objects in the right apartment

Hybrid View

  1. #1
    Join Date
    May 2009
    Location
    Cambridgeshire, UK
    Posts
    4

    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
    Posts
    401
    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 10:05 AM.

  3. #3
    Join Date
    May 2009
    Location
    Cambridgeshire, UK
    Posts
    4

    Smile

    Thanks :-)

Similar Threads

  1. Replies: 0
    Last Post: 08-26-2005, 12:35 PM
  2. Creating users from stored proc
    By Andrew Merisanu in forum Database
    Replies: 3
    Last Post: 03-05-2001, 04:29 PM
  3. Creating remote objects on win95/workstations
    By ranga raghunathan in forum Enterprise
    Replies: 1
    Last Post: 07-10-2000, 01:36 AM
  4. Creating remote objects on win95/workstations
    By ranga raghunathan in forum Enterprise
    Replies: 4
    Last Post: 06-07-2000, 08:11 AM
  5. creating arrays of objects (textboxes)
    By zoes in forum VB Classic
    Replies: 1
    Last Post: 05-20-2000, 02: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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

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