473,699 Members | 2,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3302
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/vctskHandlingEx ceptions.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/vxgrfwhatsnewin visualstudionet 2003debugger.as p

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****@newsgro up.nospam> wrote in message
news:m9******** *************** *********@4ax.c om...
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.Http Application.Err or event
Normally placed in your Global.asax file.

For console applications look at:
System.AppDomai n.UnhandledExce ption event
Use AddHandler in your Sub Main.

For Windows Forms look at:
System.Windows. Forms.Applicati on.ThreadExcept ion 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.Thr eadException 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.Thr eadException 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****@newsgro up.nospam> wrote in message
news:m9******** *************** *********@4ax.c om...
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****@newsgro up.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****@newsgro up.nospam> wrote in message
news:se******** *************** *********@4ax.c om...
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****@newsgro up.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
652
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 standard exception handler that will format and display the error information and give the user a chance to copy, print, e-mail, etc. I have a problem in that I would like the exceptions to -not- be handled during debug mode. In other words, during...
3
1654
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 totally random as to if and when they occur. if have not been able to reproduce these errors on my machine nor can anyone else here in the IT dept. i have try catch blocks around every event, sub, and function involved in the process (even in the...
5
2270
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 the offending frame? Overview: I have an application in which I am using framesets. When an Unhandled exception occurs I try to handle it
0
897
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 me a chance to break and look at the code where the error occured. Can anyone shed some light on this? Thanks, Gene H.
0
250
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 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).
2
279
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 problem. But if I run it without debug, everything is OK, Can anyone help me? Thanks! bo
20
4478
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 not seeing my exception details. The web.config file being used has the setting <customErrors mode="Off"/>. This should allow me to see the detailed exception info. On a different computer - same code - same web config - the exception details...
6
1667
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 override the OnLoad method to throw an exception: public partial class FaultyForm : Form ...
5
2094
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 test it, runs no problem. When I compile and release the dll, the user gets an unhandled exception. It doesn't halt the code, it just shows an error dialog...click continue and it continues. Is there some setting I must set so that I can see...
0
8706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8633
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8902
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6552
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5891
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4392
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2366
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.