PRB: Failing to Initialize OLE Generates Out of Memory ErrorLast reviewed: February 17, 1998Article ID: Q128086 |
The information in this article applies to:
SYMPTOMS
If the OLE .DLL files are not initialized with a call to AfxOleInit(), subsequent OLE calls will fail. For 32-bit MFC applications, debug output sent to a debugging window may show these errors:
Throwing exception of type COleException sCode = 0x8007000E E_OUTOFMEMORY -or- sCode = 0x80030008 STG_E_INSUFFICIENTMEMORYFor 16-bit MFC applications, debug output may show:
Throwing exception of type COleException sCode = 0x80000002 E_OUTOFMEMORY -or- sCode = 0x80030008 STG_E_INSUFFICIENTMEMORY RESOLUTIONAfxOleInit() calls OleInitialize(LPMALLOC), which sets the task memory allocator used by OLE. If this is not done, OLE cannot perform memory allocations and any OLE calls will fail. Placing a call to AfxOleInit() in the InitInstance() of an MFC application will fix this problem. The first few lines from the InitInstance() of HIERSVR (MFC OLE sample provided with Visual C++) below, shows the proper syntax for calling AfxOleInit().
Sample Code
/* Compile options needed: standard MFC project */BOOL CServerApp::InitInstance() { // OLE 2.0 initialization if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; }... function continues ....
STATUSThis behavior is by design. Keywords : MfcOLE Technology : kbole kbMfc Version : Winnet:1.5,1.51,1.52,2.0,2.1,4.0,5.0 Platform : NT WINDOWS Hardware : x86 Issue type : kbprb |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |