I’m trying to debug some quite complex C# code at the moment, and I’m in a situation in which I’d like to detect where a method is being called from. I could go through my code and add print statements before every invocation, but it seems to me that it should be possible to do something a bit smarter.
After a bit of poking around in Google, I found the Environment.StackTrace feature, which looks like it’d do exactly what I want - to put the current status of the stack in a string which I can print. Unfortunately, it doesn’t seem to work. The following code:
Console.WriteLine("StackTrace: '{0}'", Environment.StackTrace);
…just prints StackTrace: ‘’
I presume this is a Mono problem rather than a Unity problem, but I’m wondering if there’s either some way of making it work, or if anyone could suggest an alternative way of getting similar information.