
throwing exception from COM object's constructor
Quote:
> No, that's not the case, although the way the cross-referencing in the
> documentation is set up does lead you to think that. The root
> implementation is located in CComObjectRootBase, which is the base
> class of CComObjectRootEx. The documentation for CComObjectRootEx does
> include FinalConstruct, although it only discusses using it for
> creating aggregates.
Thanks - you're right. I tried it, and the overridden FinalConstruct method
does indeed get called. In that method, I only have one line of code:
HRESULT MyObj::FinalConstruct()
{
return Error("my error msg");
Quote:
}
On the VB client, when I try to create MyObj, I get an error, and
Err.Description returns "Automation Error" and not "my error msg" as I was
expecting.
Also, I put a breakpoint in MyObj::MyObj() which has no source code in it,
and a breakpoint in the FinalConstruct method shown above. I was expecting
each of these breakpoints to only be hit once each, but both these
breakpoints were hit 4 times each even though the VB client only has one
line of code that reads like:
set pObj = new MyObj
Any thoughts on what I may be doing wrong and how I can pass an
exception/error string to the VB client during the construction of a COM
object?
Thanks again for your time.
Cheers,
Arvind.