CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2009
    Location
    UK
    Posts
    10

    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
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

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

    I don't remember, but you can put a TRACE statement with the threadID in it and test for it yourself.

  3. #3
    Join Date
    Jul 2001
    Location
    Netherlands
    Posts
    751

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

    As you long as you check the Free threaded marshaller box the generated code should make sure your object marshalls correctly.

  4. #4
    Join Date
    May 2009
    Location
    UK
    Posts
    10

    Smile Re: Creating in-proc COM Objects in the right apartment

    Thanks :-)

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
  •  





Click Here to Expand Forum to Full Width

Featured