I asked a similar question, although not entirely the same, here: Print stack trace information in C#.
What you can do is this:
var trace = new System.Diagnostics.StackTrace(exception);
which gives you a StackTrace object that gives you all the information you need. In my case it was about avoiding having to deal with localized exception text, but I'd imagine you can use the same approach for your needs.
Edit: I note that I have added a comment to the accepted answer to my question related to a "needFileInfo" parameter to the constructor. I see this constructor here: StackTrace(Exception e, bool fNeedFileInfo), I can't find the actual code in question right now but I would guess you need to pass true
to that argument. I guess experimentation is the key here.
In other words, I guess the code should be this:
var trace = new System.Diagnostics.StackTrace(exception, true);