FIX: Multiple CreateObject May Cause GP Fault in VBOA300.DLL

Last reviewed: October 30, 1997
Article ID: Q113438
3.00 WINDOWS kbole kbbuglist

The information in this article applies to:

- Microsoft Visual Basic programming system for Windows, version 3.0

SYMPTOMS

A general protection (GP) fault may result when working with OLE objects in Visual Basic if you repeatedly create new OLE objects.

CAUSE

When OLE objects are created with Visual Basic and that OLE object is subsequently set to Nothing, a hidden instance of the OLE application is spawned and then orphaned. This uses up system resources and eventually either the machine will hang (stop responding to input) or a GP fault will occur in VBOA300.DLL at 0001:0D03.

WORKAROUND

When you create OLE objects. Be sure to close or quit the OLE object before setting the variable to Nothing. Please see the example at the end of this article.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem has been corrected in Visual Basic version 4.0.

MORE INFORMATION

Steps to Reproduce Problem

  1. Start a new project in Visual Basic. Form1 is created by default.

  2. Add a command button (Command1) to the form.

  3. Add the following code to the Command1_Click event:

       Sub Command1_Click ()
          Dim X As object
          Dim R As object
          Dim Iterations As Integer
    
          While True
             Iterations = Iterations + 1
             Debug.Print Iterations
             Set X = CreateObject("Excel.Sheet.5")
    
             ' Enter the following two lines as one, single line:
             Set R = X.Parent.Sheets(1).Range(X.Parent.Sheets(1).Cells(2, 2),
                X.Parent.Sheets(1).Cells(52, 2))
    
             Set R = Nothing
             Set X = Nothing
          Wend
       End Sub
    
    

  4. Run the program.

When this code is run, the program will eventually produce a GP fault. Closing the WorkBook will not circumvent this problem. You must quit the application to avoid the GP fault.

Example Workaround

The following code will not produce a GP fault:

   Sub Command1_Click ()
      Dim X As object
      Dim R As object
      Dim Iterations As Integer

      While True
         Iterations = Iterations + 1
         Debug.Print Iterations
         Set X = CreateObject("Excel.Sheet.5")

         ' Enter the following two lines as one, single line:
         Set R = X.Parent.Sheets(1).Range(X.Parent.Sheets(1).Cells(2, 2),
            X.Parent.Sheets(1).Cells(52, 2))

         ' The next line quits the application for an Excel object
         X.Application.Quit
         Set R = Nothing
         Set X = Nothing
      Wend
   End Sub


Additional reference words: buglist3.00 GPF EXCEL 5.00 WINWORD 6.00 VBASIC
3.00 fixlist4.00
KBCategory: kbole kbbuglist
KBSubCategory: IAPOLE
Keywords : kbbuglist kbole
Version : 3.00
Platform : WINDOWS
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.