473,323 Members | 1,589 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,323 software developers and data experts.

Method that gets current location in code?

Hi,

I'm newish to C# .Net. I'm doing some error handling in my ASP.net pages.

When handling the error in the catch block, I want to pass through the
namespace of where the error occured.. something like
"application.page.method" - I could hardcode this for every ASP.net page, but
I'm sure there must be something in .Net that gives me this for free.

Does anyone know of something I could use?

Cheers!
Nov 19 '05 #1
3 1177
AFAIK Exception.ToString has this info. The stack trace could perhaps be
avialable separately...
Patrice

--

"Nirbho" <Ni****@discussions.microsoft.com> a écrit dans le message de
news:7D**********************************@microsof t.com...
Hi,

I'm newish to C# .Net. I'm doing some error handling in my ASP.net pages.

When handling the error in the catch block, I want to pass through the
namespace of where the error occured.. something like
"application.page.method" - I could hardcode this for every ASP.net page, but I'm sure there must be something in .Net that gives me this for free.

Does anyone know of something I could use?

Cheers!

Nov 19 '05 #2
When a program executes, each method is given a "stack frame" as an
area for temporary storage. Local variables and a return address to
the caller are often stored in the stack frame.

When a method calls a second method, a new stack frame is generated
for the call. When the second method returns that new stack frame can
be cleaned up - it's just temporary storage for one method call.

When there is an exception you can not only tell where you are, but
where you have been by looking at a 'stack trace'. A stack trace
examines the active stack frames on the thread to see how you arrived
at this point.

You can start digging into stack frames yourself by looking at the
StackTrace property of an exception.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 3 May 2005 07:00:14 -0700, Nirbho
<Ni****@discussions.microsoft.com> wrote:
Hi,

I'm newish to C# .Net. I'm doing some error handling in my ASP.net pages.

When handling the error in the catch block, I want to pass through the
namespace of where the error occured.. something like
"application.page.method" - I could hardcode this for every ASP.net page, but
I'm sure there must be something in .Net that gives me this for free.

Does anyone know of something I could use?

Cheers!


Nov 19 '05 #3
Look into the Exception.TargetSite. Exception.TargetSite.Name is the name
of the method. Exception.TargetSite.DeclaringType.FullName is the name of
the containing class.

OTOH, calling Exception.ToString() will print all this out for you (and more).
-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi,

I'm newish to C# .Net. I'm doing some error handling in my ASP.net
pages.

When handling the error in the catch block, I want to pass through the
namespace of where the error occured.. something like
"application.page.method" - I could hardcode this for every ASP.net
page, but I'm sure there must be something in .Net that gives me this
for free.

Does anyone know of something I could use?

Cheers!


Nov 19 '05 #4

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

Similar topics

2
by: Mike Button | last post by:
Hello all, I am really really desperate on what I should do, and I am asking for help from anyone in this newsgroup, here's the situation: I am creating a form that is being run on a server...
1
by: Mike | last post by:
I have an ASP.NET/VB app that updates values in a DataTable over the course of about 3 different pages. On the way out of the first of these pages, I explicitly build the DataTable from values in...
1
by: Phil Sandler | last post by:
Hello all, Thanks in advance for any help with this. I am trying to get sample code to run from Michael Russell's excellent article on removing whitespace:...
5
by: sk | last post by:
Hi, I'm trying to override the Render method of my Page class. Are there any standard guidelines for this? Thanks. Shardul
2
by: Seth | last post by:
Ok, here is my setup. I have a fully functioning HTTP Handler implemented. The handler is supposed to handle every single request that comes in to a particular virtual directory. Thus, in IIS, I...
0
by: ruju00 | last post by:
I am getting an error in Login() method of the following class FtpConnection public class FtpConnection { public class FtpException : Exception { public FtpException(string message) :...
4
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of...
36
by: danielx | last post by:
At first I was going to post the following: <!-- beginning of my original post --> I just discovered the inspect module, which contains the isfunction and ismethod functions. For some reason,...
1
by: JAG | last post by:
I am getting an error using the replace method in one of my functions. I am using the replace method in the mail document function in my frameset .hta to change forward slashes to back slashes in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.