Re: COM activation models
From: Igor Tandetnik (itandetnik_at_mvps.org)
Date: 12/20/04
- Next message: Igor Tandetnik: "Re: CAtlREMatchContext and special characters"
- Previous message: Andrew Jarvis: "DCOM launch problem"
- In reply to: Headache: "COM activation models"
- Next in thread: Headache: "Re: COM activation models"
- Reply: Headache: "Re: COM activation models"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 20 Dec 2004 10:31:05 -0500
"Headache" <rquirk@tandbergtv.com> wrote in message
news:ae149124.0412200136.658930d7@posting.google.com
> I have a freee threaded out-of-process (.exe) server which exposes one
> COM object that is CComMultiThread model.
This is mostly beside the point. How do you initialize COM on the thread
that calls CoRegisterClassObject - STA or MTA?
> When a client accesses the
> server's COM object using CoCreateInstance I see no evidence of the
> server's main thread running.
I'm not sure I understand. Are your saying WinMain is not entered when
the server starts?
> I've read 'Essential COM' by Don Box and
> the section 'Activation and the SCM' says the following:
>
> When calling CoRegisterClassObject, the COM library holds a reference
> to the class object provided as the second parameter and associates
> the class object with its CLSID in an internally maintained table.
> Depending on the activation flags used in the call, the COM library
> may also notify the local SCM that the CALLER'S PROCESS IS NOW THE
> SERVER PROCESS FOR THE DESIGNATED CLASS.
>
> I'm guessing this is why I don't see the server's main thread
> ATLTRACE?
What ATLTRACE? Where do you expect to see ATLTRACE? Can you elaborate?
> Apparently at odds with this statement (IMHO) is a satement later
> which says:
>
> Server processes can register class objects for more than one class.
> If the class objects are registered to run in the MTA of the process,
> this means that incoming activation requests may be serviced as soon
> as the first call to CoRegisterClassObject completes. In any MTA-based
> servers this can cause problems .. so REG_CLS_SUSPENDED was introduced
> with a call to CoResumeClassObjects.
Why do you feel this statement contradicts the first one?
> Now, the server code has the following ON THE PRIMARY THREAD
>
> #if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED)
> hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
> REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED);
> _ASSERTE(SUCCEEDED(hRes));
> hRes = CoResumeClassObjects();
> ATLTRACE("Main thread CoResumeClassObjects");
> #else
>
> Would I expect to have to see this code execute (ie. the main thread)
> for each activation request or is it only necessary to do it once
> using /regserver for the SCM?
Class objects are usually registered once, when the server starts.
Whether or not this is what you would expect is beside the point.
> The whole reason for this is I need to create a particular
> multi-threaded COM singleton on the main thread.
If your singleton is tread-affine (that is, it cares which thread it is
created on), then MTA is a wrong choice for you in the first place.
> Running the server standalone the class
> factory's overridden CreateInstance is entered.
Who calls it, if there's no client?
> However, running it
> from a CoCreateInstance in a client does not even seem to get the
> server's main thread up and running let alone enter my ClassFactory's
> CoCreateInstance!
Are you saying your server does not even start? Then all the other
questions are moot. There's something wrong with registry entries for
your server. Get it to run in the first place, then worry about
everything else.
> Can I cause the server's main thread to run by effectively changing
> the activation flags used in CoRegisterClassObject or ...
If your main thread does not run, who's going to call
CoRegisterClassObject? This question does not make any sense to me.
> Is there any way I can force COM MTA object activation onto the main
> thread given the observation that the server's main thread does not
> appear to run?
Does not make sense to me either.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
- Next message: Igor Tandetnik: "Re: CAtlREMatchContext and special characters"
- Previous message: Andrew Jarvis: "DCOM launch problem"
- In reply to: Headache: "COM activation models"
- Next in thread: Headache: "Re: COM activation models"
- Reply: Headache: "Re: COM activation models"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|