473,790 Members | 2,561 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Err or 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.GetLastE rror().GetBaseE xception();

MethodInfo mi =
(MethodInfo)Met hodInfo.GetMeth odFromHandle(ex .TargetSite.Met hodHandle);

ParameterInfo[] parameters = mi.GetParameter s();

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_Err or
method?

TIA,
Chris

Jul 8 '06 #1
2 2419
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_Err or 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.goog legroups.com...
>I am sure I am overlooking something simple, but here goes. In the
global.asax file I have some code in the Application_Err or 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.GetLastE rror().GetBaseE xception();

MethodInfo mi =
(MethodInfo)Met hodInfo.GetMeth odFromHandle(ex .TargetSite.Met hodHandle);

ParameterInfo[] parameters = mi.GetParameter s();

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_Err or
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
7247
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 application (build in Visual Basic) using an ADO/OLE DB Provider on a IBM Client Access ODBC driver. On the Internet I found a whitepaper "SQL messages and codes" provided by IBM which describes a complete list of all SQLSTATEs, SQLCODEs and
5
1354
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 button list w/ two items, Student w/ a value of 2 and PrivUser w/ a value of 3. What I do on the click 'Submit' button is set all of the variables and pass them to my Admin class. Below is specifically what I define for the userRole (what I am...
2
1608
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 CRYPTPROTECT_PROMPTSTRUCT; I defined the variable as IntPtr and then set it to zero CryptProtectData/CryptUnrotectData return without error. The values between the C# and VB for CRYPTPROTECT_PROMPTSTRUCT are exact except for szPrompt C# passes null...
2
6856
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 System.Collections.Specialized.NameValueCollection because it inherits from ICollection. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in...
2
2861
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 stack and find out which methods are in it and what parameters those methods take, but I would really like to know the values of the parameters, something like below: HandleException(Exception Ex = MyCustomException) FillFromDataBase(Integer...
20
10868
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 included a code snippet from Chuck Blake 'ls' app in python. It seems to do the job just fine on my comp, but regrettably, I'm not sassy enough to wrap my head around the fine grain details on this one. How cross-platform is this? Is there a more...
2
6489
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 signature for method), is this possible without exception-wrapping the guts of each method? I can see how to get parameter values out of MethodInfo, but can't see how to do it without doing something like adding 7 lines to each method, taking...
8
2703
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 which invites will target selected personnel among our customers via email. Each email will provide a custom hyperlink for each respondent using a SQL generated GUID value in the querystring. The GUID will be checked for validity before the user...
275
12409
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
9666
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
10413
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
10200
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10145
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9986
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...
0
6769
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
5422
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
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3707
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.