-
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?
-
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.
-
Similar Threads
-
By segedunum in forum .NET
Replies: 0
Last Post: 08-26-2005, 11:35 AM
-
By Andrew Merisanu in forum Database
Replies: 3
Last Post: 03-05-2001, 04:29 PM
-
By ranga raghunathan in forum Enterprise
Replies: 1
Last Post: 07-10-2000, 12:36 AM
-
By ranga raghunathan in forum Enterprise
Replies: 4
Last Post: 06-07-2000, 07:11 AM
-
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
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|