Q271764: PRB: Application-defined or Object-defined Error in WebClass App
Article: Q271764
Product(s): Microsoft Visual Basic for Windows
Version(s): 6.0
Operating System(s):
Keyword(s): kberrmsg kbVBp600 kbWebClasses kbGrpDSASP kbDSupport
Last Modified: 25-APR-2001
-------------------------------------------------------------------------------
The information in this article applies to:
- Microsoft Visual Basic Professional Edition for Windows, version 6.0
- Microsoft Visual Basic Enterprise Edition for Windows, version 6.0
-------------------------------------------------------------------------------
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:
Q189539 INFO: VB 6.0 Readme Part 8: WebClass Designer Issues
Q269797 HOWTO: Create Error Handlers in Visual Basic COM Components
Additional query words: 800a9c68
======================================================================
Keywords : kberrmsg kbVBp600 kbWebClasses kbGrpDSASP kbDSupport
Technology : kbVBSearch kbAudDeveloper kbZNotKeyword6 kbZNotKeyword2 kbVB600Search kbVBA600 kbVB600
Version : :6.0
Issue type : kbprb
=============================================================================
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.
Copyright Microsoft Corporation 1986-2002.