AfxDaoInit() fails in OLE Automation object, but only in Release! 
Author Message
 AfxDaoInit() fails in OLE Automation object, but only in Release!

I wrote an Automation dll, that uses DAO and one of the first things I did
was
(of course) to open a database, the code was something like this :

BOOL OpenDatabase(LPCTSTR szFileName)
{
        if(!m_pDaoDb) m_pDaoDb = new CDaoDatabase;

        TRY
        {
                m_pDaoDb->Open(szFileName);
        }
        CATCH_ALL(e)
        {
                // handle the exception
                // and return FALSE;
                e->Delete();
                return FALSE;
        }
        END_CATCH_ALL

        return TRUE;

Quote:
}

It worked fine in debug mode, but the DAO engine fails to initialize in
Releas mode,
can anyone explain this to me?
PS. The docs say that OLE has probly not been initialized, or DAO not
properly installed,
Well this is an OLE Automation server, and the dispatch has been aquired,
so it's not
OLE, and I've tried reinstalling the DAO, but still Release fails, even
with no optimisations.

Thanks for reading this,
Tom



Tue, 06 Jul 1999 03:00:00 GMT  
 AfxDaoInit() fails in OLE Automation object, but only in Release!

Tomas,

You might not be initializing m_pDaoDb to NULL.  Debug builds
automatically set variables to zero, but release versions do not.
Without the variable being initialized it probably won't be NULL;
therefore, you skip creating a new CDaoDatabase and point to some random
area of memory.

Noah

Quote:

> I wrote an Automation dll, that uses DAO and one of the first things I did
> was
> (of course) to open a database, the code was something like this :

> BOOL OpenDatabase(LPCTSTR szFileName)
> {
>         if(!m_pDaoDb) m_pDaoDb = new CDaoDatabase;

>         TRY
>         {
>                 m_pDaoDb->Open(szFileName);
>         }
>         CATCH_ALL(e)
>         {
>                 // handle the exception
>                 // and return FALSE;
>                 e->Delete();
>                 return FALSE;
>         }
>         END_CATCH_ALL

>         return TRUE;
> }

> It worked fine in debug mode, but the DAO engine fails to initialize in
> Releas mode,
> can anyone explain this to me?
> PS. The docs say that OLE has probly not been initialized, or DAO not
> properly installed,
> Well this is an OLE Automation server, and the dispatch has been aquired,
> so it's not
> OLE, and I've tried reinstalling the DAO, but still Release fails, even
> with no optimisations.

> Thanks for reading this,
> Tom



Tue, 06 Jul 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. AfxDaoInit() fails in OLE Automation object, but only in Release!

2. Help: OLE Automation failed?

3. Saving and retrieving Ole-Automation objects from Dao and MFC using CLongBinary class

4. SQL 7 OLE Automation Object via Stored Procedure

5. OLE Automation Objects

6. Saving and retrieving Ole-Automation objects from Dao and MFC using CLongBinary class

7. Managing object lifetimes in OLE Automation

8. COM object failed in release build

9. Reading OLE structured storage documents, with OLE objects...

10. passing objects from VB as VARIANT to COM server object failing

11. passing objects from VB as VARIANT to COM server object failing

12. How to perform OLE Automation

 

 
Powered by phpBB® Forum Software