473,413 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Info on unhandled exception during break mode, no exception variable?

When you have an unhandled exception in vb.net how do you view the
exception information in the debugger?

In C# the debugger creates a local variable that points to the
exception and you can view it in one of the windows (autos or locals,
don't remember which). That doesn't appear to be the case with
vb.net.

I also tried using the command window to inspect "Err" but that gave
nothing useful (always empty).

If I catch the exception then I have my own variable which has the
information, but that only applies to caught exceptions and I'd rather
not change my code to catch things lower down in the call stack just
to facilitate debugging.

Is there something I'm missing? A menu option? a window?

Thanks,

Sam

Nov 21 '05 #1
5 3265
Hi

Do you mean the $exception pseudovariable?

If so, it is unfortunate that VB.NET did not have the feature.

Based on the MSDN, we will know that that is for Visual C# only.

Note (Visual C# only) When an uncaught exception occurs, a pseudovariable
$exception is added to the Locals window. You can expand this
pseudovariable to see information on the exception.

Handling Exceptions
http://msdn.microsoft.com/library/de...us/vsdebug/htm
l/vctskHandlingExceptions.asp

A new pseudovariable $exception for retrieving information on C#
exceptions.

What's New in the Visual Studio .NET 2003 Debugger
http://msdn.microsoft.com/library/de...us/vsdebug/htm
l/vxgrfwhatsnewinvisualstudionet2003debugger.asp

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #2
"Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:m9********************************@4ax.com...
When you have an unhandled exception in vb.net how do you view
the exception information in the debugger?


If an Exception is unhandled whilst you're developing, will it not
continue to be so when you release the finished Product? And, if it
does happen "out there", your users are going to be seeing some pretty
/horrible/, Framework-generated error dialogs.

I'd prefer to avoid /unhandled/ Exceptions altogether, even in Forms
applications...

Sub Main
Try
Application.Run( New Form1 )

Catch ex As Exception
. . .
End Try
End Sub

Regards,
Phill W.
Nov 21 '05 #3
Phill,
Sub Main
Try
Application.Run( New Form1 )

Catch ex As Exception
. . .
End Try
End Sub Only catches exceptions that Form1's constructor throws.

To catch other unhandled exceptions you need to use a Global Exception
Handler.

Depending on the type of application you are creating, .NET has three
different global exception handlers.

For ASP.NET look at:
System.Web.HttpApplication.Error event
Normally placed in your Global.asax file.

For console applications look at:
System.AppDomain.UnhandledException event
Use AddHandler in your Sub Main.

For Windows Forms look at:
System.Windows.Forms.Application.ThreadException event
Use AddHandler in your Sub Main.

It can be beneficial to combine the above global handlers in your app, as
well as wrap your Sub Main in a try catch itself.

There is an article in the June 2004 MSDN Magazine that shows how to
implement the global exception handling in .NET that explains why & when you
use multiple of the above handlers...

http://msdn.microsoft.com/msdnmag/is...T/default.aspx

For example: In my Windows Forms apps I would have a handler attached to the
Application.ThreadException event, plus a Try/Catch in my Main. The
Try/Catch in Main only catches exceptions if the constructor of the MainForm
raises an exception, the Application.ThreadException handler will catch all
uncaught exceptions from any form/control event handlers.

Hope this helps
Jay
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
news:cp**********@yarrow.open.ac.uk... "Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:m9********************************@4ax.com...
When you have an unhandled exception in vb.net how do you view
the exception information in the debugger?


If an Exception is unhandled whilst you're developing, will it not
continue to be so when you release the finished Product? And, if it
does happen "out there", your users are going to be seeing some pretty
/horrible/, Framework-generated error dialogs.

I'd prefer to avoid /unhandled/ Exceptions altogether, even in Forms
applications...

Sub Main
Try
Application.Run( New Form1 )

Catch ex As Exception
. . .
End Try
End Sub

Regards,
Phill W.

Nov 21 '05 #4

The top level exception handler typically just displays a friendly
message and exits (or saves state if possible, or logs, or whatever).
Fine for production, not for development. I prefer to put these
handlers inside #IF conditionals so they aren't even in the debug code
base. In C#, this gives me an exception variable and breaks where the
exception first occurs. If I handle the exception at the top of the
application, then all errors will be caught there and the code will
break at the top. This will give me information about the error, but
not the state of the object that actually caused the error.

Really the "answer" as to whether there should be unhandled exceptions
in development code is not related to the original question--Does
VB.NET provide the same functionality as C# related to debugging
unhandled exceptions. Peter said No. That's unfortunate, but at
least can stop looking for an option.

Sam

On Fri, 10 Dec 2004 13:26:52 -0000, "Phill. W"
<P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote:
"Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:m9********************************@4ax.com.. .
When you have an unhandled exception in vb.net how do you view
the exception information in the debugger?


If an Exception is unhandled whilst you're developing, will it not
continue to be so when you release the finished Product? And, if it
does happen "out there", your users are going to be seeing some pretty
/horrible/, Framework-generated error dialogs.

I'd prefer to avoid /unhandled/ Exceptions altogether, even in Forms
applications...


Nov 21 '05 #5
Samuel,
Fine for production, not for development. I prefer to put these
handlers inside #IF conditionals so they aren't even in the debug code
base. #IF are not needed! you can use "Debug - Exceptions" in VS.NET to control if
exceptions (handled & unhandled) break into the debugger or get controlled
by your exception handlers.

By expanding the tree under "Exceptions" you can control the options for
individual exceptions.

By using the "Add..." button you can add your own custom exceptions to the
"Exceptions" tree.

For example if I have a Global Exception Handler I may change the "When the
exception is thrown" to "break into the debugger" when I want to "break
where the exception first occurs".

NOTE: "Debug - Exceptions" are useful for both Global Exception Handlers &
Try/Catch blocks in both VB.NET & C#.

Hope this helps
Jay
"Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:se********************************@4ax.com...
The top level exception handler typically just displays a friendly
message and exits (or saves state if possible, or logs, or whatever).
handlers inside #IF conditionals so they aren't even in the debug code
base. In C#, this gives me an exception variable and breaks where the
exception first occurs. If I handle the exception at the top of the
application, then all errors will be caught there and the code will
break at the top. This will give me information about the error, but
not the state of the object that actually caused the error.

Really the "answer" as to whether there should be unhandled exceptions
in development code is not related to the original question--Does
VB.NET provide the same functionality as C# related to debugging
unhandled exceptions. Peter said No. That's unfortunate, but at
least can stop looking for an option.

Sam

On Fri, 10 Dec 2004 13:26:52 -0000, "Phill. W"
<P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote:
"Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:m9********************************@4ax.com. ..
When you have an unhandled exception in vb.net how do you view
the exception information in the debugger?


If an Exception is unhandled whilst you're developing, will it not
continue to be so when you release the finished Product? And, if it
does happen "out there", your users are going to be seeing some pretty
/horrible/, Framework-generated error dialogs.

I'd prefer to avoid /unhandled/ Exceptions altogether, even in Forms
applications...

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jeff | last post by:
Hello, I have a Windows Forms application in which I've implemented custom exception handling for most of the UI-related methods. If an exception occurs, it is "caught" and passed on to a...
3
by: Kunkel | last post by:
i am using VS.NET 2003 and coding in VB.NET. some of my users recieving an unhandled exception in one of my programs. although these exceptions always occur during a certain process, they are...
5
by: terry | last post by:
Hi, Question: When using Framesets and Server.Transfer in the Application_Error event handler is there a mechanism to get the error page to display in the total view of the browser not just in...
0
by: Gene Hubert | last post by:
I occasionally get the "Unhandled Exception" window popping up when I'm running with Debug on. I can't tell why I get the "Unhandled Exception" window instead of it catching the error and giving...
0
by: Samuel R. Neff | last post by:
When you have an unhandled exception in vb.net how do you view the exception information in the debugger? In C# the debugger creates a local variable that points to the exception and you can...
2
by: Wangbo | last post by:
Hi, all I encounted a very strange problem in my App, in debug mode, when I exit my App, it often told me something like "Unhandled exception at ..., user breakpoint", press F5, it skiped this...
20
by: Tim Reynolds | last post by:
Team, I am developing a web service. In testing in on my enw PC, I am expecting to see exceptions thrown appear on my browser. Instead I am getting an HTTP 500 Internal Server Error page and I am...
6
by: Viktar Zhardzetski | last post by:
Hi everybody, let me start with a simple sample to replicate the problem: 1. Create a new Windows Application C# project with 2 forms - MainForm and FaultyForm; 2. In the faulty form...
5
by: Tim Zych | last post by:
What factor would allow an unhandled exception to occur in a compiled project, versus no error for the same action during development? In other words, I have a project that, in development when I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.