Exception fired during DLL unload in ATL com object 
Author Message
 Exception fired during DLL unload in ATL com object

my COM object works fine, except for the fact that if the client calls
a method that returns an ADO recordset, i get 'Exception fired during
DLL unload'.

what would be the right way to pass back ADO recordsets?

My COM method passes back the recordset as [out, retval], and within
that method, it calls another method from an object which gets the
recordset as a param.

STDMETHODIMP CMyInterface::MyMethod (BSTR bData, _Recordset**
ppRecordset)
{
   CMyClass x;
   _RecordsetPtr rs (__uuidof (adoRecordset));
   x.Foo (&rs);      // x.Foo will create the fields and populate
   *ppRecordset = rs.Detach ();

Quote:
}

CMyClass::Foo (_Recordset** prs)
{
   _RecordsetPtr pRs (__uuidof(adoRecordset))
   *prs = NULL;             // reset first;

   /*  create the fields here and populate
   .
   .
   .
   */
   *prs = pRs.Detach ();

Quote:
}

Sent via Deja.com
http://www.*-*-*.com/


Wed, 02 Jul 2003 04:23:24 GMT  
 Exception fired during DLL unload in ATL com object
I am not sure if this will work. But I remember that in some cases you'd need to
AddRef the recordset pointer since it's  a smart pointer. The AddRef is to make
sure that it does not get released automatically.

Good luck.

Peter

Quote:
-----Original Message-----

my COM object works fine, except for the fact that if the client calls
a method that returns an ADO recordset, i get 'Exception fired during
DLL unload'.

what would be the right way to pass back ADO recordsets?

My COM method passes back the recordset as [out, retval], and within
that method, it calls another method from an object which gets the
recordset as a param.

STDMETHODIMP CMyInterface::MyMethod (BSTR bData, _Recordset**
ppRecordset)
{
   CMyClass x;
   _RecordsetPtr rs (__uuidof (adoRecordset));
   x.Foo (&rs);      // x.Foo will create the fields and populate
   *ppRecordset = rs.Detach ();
}

CMyClass::Foo (_Recordset** prs)
{
   _RecordsetPtr pRs (__uuidof(adoRecordset))
   *prs = NULL;             // reset first;

   /*  create the fields here and populate
   .
   .
   .
   */
   *prs = pRs.Detach ();
}

Sent via Deja.com
http://www.deja.com/
.



Wed, 02 Jul 2003 12:42:09 GMT  
 Exception fired during DLL unload in ATL com object
- thanks for trying, but Addref did not work.
i think it is not being released automatically because after returning
from the method call, the client gets the recordset and is able to
display it in a data grid.

- i also noticed that if i comment out all the recordset stuff (*all
the stuff that creates fields and appends records*) and just do a Detach
() immediately, the Exception does not occur. does it have to do with
how i create the fields and append records to it?

- also, i dont call Update() since i am not connected to any database.
is that right? how about a connection object, do i need it since i
really dont connect to any DB. i just return a recordset because the
client wants the result in a recordset.

- this is how i do the append, then add records :
rs->PutCursorLocation (adUseClient);

// create 2 fields of the recordset.
rs->Fields->Append (_bstr_t("Name"), adVarChar, 100, FieldAttribu{*filter*}um
(adFldUpdatable + adFldIsNullable));

rs->Fields->Append (_bstr_t("Value"), adVarChar, 255, FieldAttribu{*filter*}um
(adFldUpdatable + adFldIsNullable));

rs->Open (vtMissing, vtMissing, adOpenStatic, adLockOptimistic,
adOptionUnspecified);

while (/*some condition*/)
{
   rs->AddNew ();
   rs->GetFields()->GetItem((_bstr_t) "Name")->PutValue (pNameValue-

Quote:
>m_szName.c_str());

   rs->GetFields()->GetItem((_bstr_t) "Value")->PutValue (pNameValue-
Quote:
>m_szValue.c_str());
}

*ppRecordset =3D rs.Detach ();   // ppRecordSet is the _Recordset **
                                 //[out] param and



Quote:
> I am not sure if this will work. But I remember that in some cases
you'd =
> need to=20
> AddRef the recordset pointer since it's  a smart pointer. The AddRef
is =
> to make=20
> sure that it does not get released automatically.=20

> Good luck.

> Peter

> -----Original Message-----
> my COM object works fine, except for the fact that if the client calls
> a method that returns an ADO recordset, i get 'Exception fired during
> DLL unload'.

> what would be the right way to pass back ADO recordsets?

> My COM method passes back the recordset as [out, retval], and within
> that method, it calls another method from an object which gets the
> recordset as a param.

> STDMETHODIMP CMyInterface::MyMethod (BSTR bData, _Recordset**
> ppRecordset)
> {
>    CMyClass x;
>    _RecordsetPtr rs (__uuidof (adoRecordset));
>    x.Foo (&rs);      // x.Foo will create the fields and populate
>    *ppRecordset = rs.Detach ();
> }

> CMyClass::Foo (_Recordset** prs)
> {
>    _RecordsetPtr pRs (__uuidof(adoRecordset))
>    *prs = NULL;             // reset first;

>    /*  create the fields here and populate
>    .
>    .
>    .
>    */
>    *prs =3D pRs.Detach ();
> }

> Sent via Deja.com
> http://www.*-*-*.com/
> .

Sent via Deja.com
http://www.*-*-*.com/


Wed, 02 Jul 2003 21:53:03 GMT  
 Exception fired during DLL unload in ATL com object

The pointer is freed after the function exits.



Mon, 07 Jul 2003 16:45:31 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. ATL COM object pointer and fire events

2. passing COM object pointers to another COM object in ATL

3. ATL COM DLL :: DllRegisterserver throw exception 0x80029c4a

4. ATL COM - Passing ATL COM classes through another ATL COM class in the same app

5. atl object not unloading

6. Use of MFC User DLL in ATL COM Object

7. using external DLL in ATL COM object

8. ATL COM object hangs on user32.dll MessageBoxA() call

9. ATL COM object hangs on user32.dll MessageBoxA() call

10. ATL: instantiating a COM object within its own implementation DLL

11. cegadgets.com ATL CE event firing

12. Callback Handling mechanisms in STA client when fired from MTA atl com server

 

 
Powered by phpBB® Forum Software