In general reflection is used to learn about a type without having to create an instance of or have a reference to one and once the desired information is gathered, it is possible to act on it should you have a reference to an instance... without this reference though there is no direct way to get the values.
The same goes for this case... the data you are using from TargetSite is the reflected data about the method where the exception came from including information about the parameter types... but not the values as references passed into the method no longer exist.
One option to get the values that were passed into the offending method would be to catch the exception there and either log the values or wrap them into a new exception whose InnerException property refers to what you just caught... and throw the whole thing back up the call stack to your normal logging code.
Would this work for you
|