Display lines number in Stack Trace for .NET assembly in Release mode

Go into the Properties window for the project where you want to see stack trace line numbers. Click on the Build “vertical tab”. Select “Release” configuration. Check the DEBUG constant parameter. Uncheck the “Optimize code” parameter to avoid the occasional trace issue with inlined code (this step is not essential). Press the Advanced… button and … Read more

How do I find the caller of a method using stacktrace or reflection?

StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace() According to the Javadocs: The last element of the array represents the bottom of the stack, which is the least recent method invocation in the sequence. A StackTraceElement has getClassName(), getFileName(), getLineNumber() and getMethodName(). You will have to experiment to determine which index you want (probably stackTraceElements[1] or [2]).