473,402 Members | 2,072 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,402 software developers and data experts.

C# Noob - Exception Handled but not available

Hello,

Im reasonably new to C#. Im catching an exception of type WebException as
below:

catch (WebException ex)
{
link.LinkState = (short)(LinkState.Stored);
Debug.WriteLine(ex.Message);
}

The first line in this catch block is hit and executes but the second is
just lpain ignored. When i opened the immediate window and tried a

?ex.Message
i get

?ex.Message
The name 'ex' does not exist in the current context

when i then pull up locals view and i see that the exception var has been
renamed to - $exception?

I dont understand whats going on here. Does this mean i cant log the
exception? I guess not if i cant even access it.

Thanks

Richard
Apr 12 '07 #1
2 2909
On 12 Apr, 08:42, "Richard Coltrane" <r...@spamsux.comwrote:
Hello,

Im reasonably new to C#. Im catching an exception of type WebException as
below:

catch (WebException ex)
{
link.LinkState = (short)(LinkState.Stored);
Debug.WriteLine(ex.Message);

}

The first line in this catch block is hit and executes but the second is
just lpain ignored. When i opened the immediate window and tried a

?ex.Message
i get

?ex.Message
The name 'ex' does not exist in the current context

when i then pull up locals view and i see that the exception var has been
renamed to - $exception?

I dont understand whats going on here. Does this mean i cant log the
exception? I guess not if i cant even access it.

Thanks

Richard
If you've stepped over the line you might be out of scope, just drag
the current line indicator back up onto the debug.print line and you
should be able to see ex again.

Apr 12 '07 #2
On Thu, 12 Apr 2007 19:42:40 +1200, "Richard Coltrane"
<rc@spamsux.comwrote:
>Hello,

Im reasonably new to C#. Im catching an exception of type WebException as
below:

catch (WebException ex)
{
link.LinkState = (short)(LinkState.Stored);
Debug.WriteLine(ex.Message);
}

The first line in this catch block is hit and executes but the second is
just lpain ignored.
Debug.WriteLine writes to the elements in the Debug.Listeners
collection. Unless you have explicitly added your destination of
choice you will not see any output. Quoting from the MS Help: "To
redirect output to the console window, add an instance of the
ConsoleTraceListener. To redirect output to a file or stream, add an
instance of the TextWriterTraceListener."

rossum

Apr 12 '07 #3

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

Similar topics

27
by: garyolsen | last post by:
In C++ what kind of unexpected conditions should be handled as exceptions? Besides dividing by 0, bad memory allocation, what're the most popular exceptions? When should not use exception,...
6
by: Ray Mitchell | last post by:
Hello, I have a VS 2003 application that gets the following error window: "An unhandled exception of type 'System.ArgumentNullException' occurred in mscorlib.dll" "Additional information: Value...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
5
by: Lucvdv | last post by:
Can someone explain why this code pops up a messagebox saying the ThreadAbortException wasn't handled? The first exception is reported only in the debug pane, as expected. The second (caused by...
2
by: Murthy | last post by:
Hi, After genarating the exe when i run the exe the following error is comming. Common Language Runtime Debugging Services Application has generated an exception that could not be handled....
5
by: Bry | last post by:
I've created a class that offers an enhanced way of handling fatal exceptions. The class allows the user to optionaly submit a http based anonymous error report to myself, and also records details...
132
by: Zorro | last post by:
The simplicity of stack unraveling of C++ is not without defective consequences. The following article points to C++ examples showing the defects. An engineer aware of defects can avoid...
3
by: Miro | last post by:
I cant seem to find an example on how to do something, ( vb2005.express ) i have a Try ListeningSerialPort.Open() TestText.Enabled = True Catch ex As Exception 'Debug.WriteLine(ex.Message)...
4
by: Miro | last post by:
Vb.2005 express I am having an issue where when in vb.2005 express and running it internally, I can catch the exception, but when I publish the project I get a crash - and a JIT error. This...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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...

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.