PRB: Application-defined or Object-defined Error (800a9c68) in a WebClass Application (271764)



The information in this article applies to:

  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

This article was previously published under Q271764

SYMPTOMS

When you view a compiled WebClass (Internet Information Server application) in a Web browser, you may receive the following error message:
projectname error '800a9c68'
Application-defined or object-defined error
/projectname/pagename.ASP, line 13

CAUSE

This problem is caused by an error in the WebClass code that is not handled by any error handlers in the WebClass.

When you run the WebClass in debug mode in the Visual Basic Integrated Development Environment (IDE), the IDE traps the error and displays it in a message box. After you dismiss the message box, the debugger stops at the line of code that generates the error.

However, when you compile and browse the WebClass outside of the Visual Basic IDE, the WebClassRuntime traps the error and logs it in the Application log in the Event Viewer, along with a second event that indicates the "Application-defined or object-defined" error.

RESOLUTION

To resolve this problem, you can read the application log and extract the error message. To do this on Microsoft Windows NT 4.0, perform the following steps:
  1. From the Start menu, point to Programs, point to Administrative Tools, and then click Event Viewer.
  2. In the Event Viewer window, on the Log menu, click Application.
  3. To view the logs, double-click the entries in the list.
The first log is an error that is generated by the WebClassRuntime and contains the following text:
The WebClass runtime trapped the following error:

Source: WebClass1
Thread ID: 1256
Description: Application-defined or object-defined error
The second log is a warning from the VBRuntime and contains the actual error message:
The VB Application identified by the event source logged this Application
Project1:
ThreadID: 354,
Logged: MsgBox: ,Run-Time error '11':
Division by zero
NOTE: Microsoft Windows 2000 does not report the actual error in the event log. To find the actual error message, you must create your own error handling in your WebClass procedures. This is also recommended for WebClasses on Windows NT so that you can produce custom error messages for your customers instead of the generic "Application-defined or object-defined error." In addition, to make sure that you catch all errors, you should implement an error handler in all of your WebClass methods.

To implement error handling in WebClasses, use the following sample code:
  Private Sub WebClass_Start()
  On Error GoTo ErrorHandler
    ...
    Your code goes here
    ...
  ErrorHandler:
    app.logEvent "error in method WebClass_Start: " & Err.Number & " " & Err.Description

    Select case Err.Number 
      Case 11
        Response.Write "<B>Your custom error message ...</B>"
      Case Else
        Response.Write "<B>Your generic error message ...</B>"
  End Sub
				
The App.LogEvent method creates an event log in the application log of the Web server. The source is the name of your WebClass.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new WebClass application, and paste the following code into the WebClass_Start event.
    Private Sub WebClass_Start()
    Dim i As Integer
        
        i = 1 / 0
    
    End Sub
    					
  2. Save the project, and compile the WebClass DLL.
  3. On a Web browser, browse to the WebClass.

REFERENCES

For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:

189539 INFO: VB 6.0 Readme Part 8: WebClass Designer Issues

269797 HOWTO: Create Error Handlers in Visual Basic COM Components


Modification Type:MajorLast Reviewed:4/25/2001
Keywords:kbDSupport kberrmsg kbprb kbWebClasses KB271764