views:

49

answers:

1

Using the .NET CLR, is there a way to prevent a certain method to show up in the stack trace? Especially I just want to remove the last call from the stack trace before throwing an exception.

I'm just curious, unsafe calls and reflection hacks are valid solutions.

+3  A: 

If it's your Exception implementation, you can override StackTrace to return whatever you like. And the this constructor of the StackFrame class makes it easy to create a stack trace whilst skipping any number of methods.

Kent Boogaart