CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Sep 2004
    Posts
    65

    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
    Last edited by Ranthalion; February 11th, 2008 at 04:41 PM. Reason: Including .NET version

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured