Using CComPtr<>::CoCreateInstance 
Author Message
 Using CComPtr<>::CoCreateInstance

Hello!

I have an ATL coclass having an aggregated object. I hold the pointer to
aggregated interface in CComPtr data member. I create aggregated object in
FinalConstruct() method by calling CComPtr.CoCreateInstance(). But when I
destroy my coclass I get an "Access Violation" error in CComPtr::Release()
method.

I create an instance of my aggregated object this way:

m_pTestObj.CoCreateInstance(CLSID_TestObj, NULL, CLSCTX_ALL);

Can somebody suggest me any solution for this problem?

Thanks in advance.
Oleg Malkov.



Wed, 21 May 2003 03:00:00 GMT  
 Using CComPtr<>::CoCreateInstance
The object created this way is not aggregated. Aggregation is a well-defined
term. The tell-tale of aggregation is your passing your object's IUnknown
(so-called outer unknown) as a parameter of CoCreateInstance (whereas you
pass NULL).

Try calling m_pTestObj.Release (NOTE: not m_pTestObj->Release()) in your
object's FinalRelease. If this does not help, your object or the object you
create mismanage reference counts somewhere.
--
With best wishes,
    Igor Tandetnik


Quote:
> Hello!

> I have an ATL coclass having an aggregated object. I hold the pointer to
> aggregated interface in CComPtr data member. I create aggregated object in
> FinalConstruct() method by calling CComPtr.CoCreateInstance(). But when I
> destroy my coclass I get an "Access Violation" error in CComPtr::Release()
> method.

> I create an instance of my aggregated object this way:

> m_pTestObj.CoCreateInstance(CLSID_TestObj, NULL, CLSCTX_ALL);

> Can somebody suggest me any solution for this problem?

> Thanks in advance.
> Oleg Malkov.



Thu, 22 May 2003 03:00:00 GMT  
 Using CComPtr<>::CoCreateInstance
Thank you, Igor!

Sorry for mistakes in COM terminology, I've meant containment (I'm not sure
for english terms).
It was my error: I've call CoUninitialize() before of my objects was
destroyed. When I've corrected it, it's began to work fine.

Thanks.
Oleg Malkov.


Quote:
> The object created this way is not aggregated. Aggregation is a
well-defined
> term. The tell-tale of aggregation is your passing your object's IUnknown
> (so-called outer unknown) as a parameter of CoCreateInstance (whereas you
> pass NULL).

> Try calling m_pTestObj.Release (NOTE: not m_pTestObj->Release()) in your
> object's FinalRelease. If this does not help, your object or the object
you
> create mismanage reference counts somewhere.
> --
> With best wishes,
>     Igor Tandetnik



Fri, 23 May 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. <<<<<<<Parsing help, please>>>>>>>>

2. File Format conversion, ascii freeform -->.csv <-->.wk1<-->dbf<-->?HELP

3. <<<>>>Need C code advice with functions and sorting.<<<>>>

4. <><><>HELP<><><> PCMCIA Motorola Montana 33.6

5. CComPtr->Release() or CComPtr.Release()

6. >>>Windows Service<<<

7. Copy policy for CAdapt<CComPtr<T>>

8. Buggy optimization for speed? CComPtr<>, CComQIPtr<>

9. Buggy optimization for speed? CComPtr<>, CComQIPtr<>

10. proposal: <basic.h>, <pascal.h>, <fortran.h>, <cobol.h>

11. <<<< C Grammar for yacc needed >>>>

12. - - - = = =<><> W e b - U S A <><>= = = - - -

 

 
Powered by phpBB® Forum Software