Capture method parameters for error logging
Hi,
I am using VS2008 with .NET 3.5...
I am looking for a way to capture the parameters and values associated with them when an error occurs. I can find the parameter names and data types, but I can't seem to find a way to get the actual values of the parameters. Does anyone know of a way to capture a method's parameter values?
Here is an example of what I would like to be able to do, using GetMethodParameters to return a collection containing the values that were assigned to a and b...
Code:
private void foo(int a, int b)
{
try
{
//Do some stuff...
}
catch (Exception ex)
{
LogError(ex, GetMethodParameters());
}
}
Thanks,
Ranthalion