HOWTO: Enable more meaningful error messages...

S73310

Newcomer
Joined
Apr 1, 2003
Messages
1
Location
UK
Hi all,

i'm very new to .Net and still getting my bearings with things. One thing thats really annoying is that i find the error messages are now more cryptic then ever before, for example see below:

Can anyone suggest, is there any way to get more accurate or detailed error messages with Asp.Net (VB).

Excuse my ignorance.

Cheers

s73310

Oh, and any suggestions on the below error message would also be much appreciatted :
*grin*


Server Error in '/' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
edc.DepartmentsList.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\VSWebCache\edc\UserControls\Datalist.ascx.vb:39
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Page.ProcessRequestMain() +731




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
 
I dont think there is a way to get better messages.
But tell us your problem and how/when it happens, maybe well be able to help you.
 
I can tell you that the error occured in your Page_Load event.
Use a Try/Catch to handle your errors, when you catch an error send it to the browser in a Label or Response.Write.
 
You didn't initialize an instance of an object somewhere in your Page_Load event.

Visual Basic:
'Not initialized
Dim oConnection As SqlConnection

'Initialized
Dim oConnection As New SqlConnection()
 
The error message seems pretty clear to me. :confused:

Just to sort of repeat what the above has said, use a try catch block on code that can possibly throw an error. Look up in the object browser what exceptions they can throw, and deal with each exception individually and appropriately, that way you can throw your own meaningful errors based on the exception thrown.
 
Back
Top