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

Home Posts Topics Members FAQ

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.pa ge.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 1192
AFAIK Exception.ToStr ing has this info. The stack trace could perhaps be
avialable separately...
Patrice

--

"Nirbho" <Ni****@discuss ions.microsoft. com> a écrit dans le message de
news:7D******** *************** ***********@mic rosoft.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.pa ge.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****@discuss ions.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.p age.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.Targe tSite. Exception.Targe tSite.Name is the name
of the method. Exception.Targe tSite.Declaring Type.FullName is the name of
the containing class.

OTOH, calling Exception.ToStr ing() 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.pa ge.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
2933
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 where there is no scripts allowed running (the software is from Opentext called Livelink)- therefore I need javascript to do the tasks listed below: 1. validate the form - this has been completed 2. pop up another window that will go ahead and...
1
2969
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 a DataGrid, and set the PrimaryKey of the DataTable to be the first cell in the grid (which is a UserID value). I then store the DataTable in a session object, from which it is retrieved for subsequent pages. All this seems to be working fine. ...
1
7508
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: http://www.codeproject.com/aspnet/WhitespaceFilter.asp I have also tried his updated version, which can be found (in a zip file) here:
5
1778
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
3872
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 have a mapping of .* to the aspnet_isapi.dll. And my web.config has an entry thusly: <add verb="*" path="*" type="HandlerClass, HandlerAssembly" /> And this is working just fine thus far. The handler gets all the requests and works like a...
0
3713
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) : base(message){} public FtpException(string message, Exception innerException) : base(message,innerException){}
4
2362
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 which I mean here. Just for a moment, let's just take one definition for one of the
36
1868
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, I used to be under the impression that Python methods are no different from Python functions. Naturally, I wondered why both of these needed to exist (I also later discovered the isroutine function). So I started to experiment at prompt. Here's...
1
1994
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 the myVar string. The myVar string is obtained in my show document function: myVar = filename; In my mail document function:
0
8617
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
9174
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
7751
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6534
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
5875
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
4629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.