Microsoft KB Archive/271764

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

Article ID: 271764

Article Last Modified on 4/25/2001

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



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 &quot;Application-defined or object-defined&quot; 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 &quot;Application-defined or object-defined error.&quot; 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 &quot;error in method WebClass_Start: &quot; & Err.Number & &quot; &quot; & Err.Description

Select case Err.Number Case 11 Response.Write &quot;Your custom error message ...&quot; Case Else Response.Write &quot;Your generic error message ...&quot; 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.



Steps to Reproduce Behavior
  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  Save the project, and compile the WebClass DLL. On a Web browser, browse to the WebClass.</ol>

<div class="references_section">