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

Finding parameter values in an Exception

I am sure I am overlooking something simple, but here goes. In the
global.asax file I have some code in the Application_Error method that
reads information out of the current exception and emails it to me. I
want to see what the parameter values are for the method throwing the
exception. I am using reflection to get the parameter metadata, but
this does not do me much good.

Exception ex = Server.GetLastError().GetBaseException();

MethodInfo mi =
(MethodInfo)MethodInfo.GetMethodFromHandle(ex.Targ etSite.MethodHandle);

ParameterInfo[] parameters = mi.GetParameters();

Lets say the method throwing the exception has the following signature.
public void MyMethod(string foo, string bar)

The exception is thrown when the values are foo = "something" and bar =
"something else"

How do I find the values of foo and bar at runtime in Application_Error
method?

TIA,
Chris

Jul 8 '06 #1
2 2366
Hi Chris,

You must pass the parameter values to a strong-Typed Exception class that
can support them.

In other words, the StackTrace doesn't save those values and by the time
Application_Error is called the values will probably have already been
collected by the GC so you must design your program to create diagnostics
information on a need-to-know basis.

HTH

"chris" <ch***@cubed-c.comwrote in message
news:11**********************@35g2000cwc.googlegro ups.com...
>I am sure I am overlooking something simple, but here goes. In the
global.asax file I have some code in the Application_Error method that
reads information out of the current exception and emails it to me. I
want to see what the parameter values are for the method throwing the
exception. I am using reflection to get the parameter metadata, but
this does not do me much good.

Exception ex = Server.GetLastError().GetBaseException();

MethodInfo mi =
(MethodInfo)MethodInfo.GetMethodFromHandle(ex.Targ etSite.MethodHandle);

ParameterInfo[] parameters = mi.GetParameters();

Lets say the method throwing the exception has the following signature.
public void MyMethod(string foo, string bar)

The exception is thrown when the values are foo = "something" and bar =
"something else"

How do I find the values of foo and bar at runtime in Application_Error
method?

TIA,
Chris

Jul 8 '06 #2
Thank Dave, that is what I gathered as I did further research.

Chris

Jul 8 '06 #3

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

Similar topics

15
by: Twan Kennis | last post by:
Hi, I have a DB2 database on the IBM iSeries platform, on which I created several Stored Procedures with the SQLCODE as a return-parameter. These Stored Procedures are called from a Windows...
5
by: Andy G | last post by:
I am getting an error when I try to call my stored procedure. Exception adding account. Procedure 'stpCFSPH_CM_RGST_USER' expects parameter '@USER_DESCR', which was not supplied. I have a radio...
2
by: DazedAndConfused | last post by:
I converted a C# example of using dll crypt32 to VB .NET. The converted example fails when Encypting/Decypting. I found that if instead of defining a variable as and setting the values for...
2
by: MrDotNet | last post by:
Hi I want pass NameValueCollection as parameter in webmethod. I try it but that give me error. Here is Error. You must implement the Add(System.String) method on...
2
by: Steve Amey | last post by:
Hi all I would like to get the values of Parameters passed to a method from a centralized exception handling routine. At the moment, the exception is passed to the handler, and I can get the...
20
by: Joel Hedlund | last post by:
Hi all! I use python for writing terminal applications and I have been bothered by how hard it seems to be to determine the terminal size. What is the best way of doing this? At the end I've...
2
by: news.microsoft.com | last post by:
Hi all. If I wanted to write something so that, when an exception was thrown, and the stack unwound, the stack trace was captured with the values of the parameters (instead of just the parameter...
8
by: Alec MacLean | last post by:
Hi, I'm using the DAAB Ent Lib (Jan 2006) for .NET 2.0, with VS 2005 Pro. My project is a Web app project (using the WAP add in). Background: I'm creating a survey system for our company, for...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.