Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is reflecting on the stack trace dangerous in a release build?

Tags:

c#

.net

clr

In C# consider the following statement:

string operation = new StackTrace(false).GetFrame(0).GetMethod().Name;

Is this a dangerous construction in a release build, where the frames may be compiled to native code?

like image 976
Jakob Bjerre Jensen Avatar asked Jan 16 '23 04:01

Jakob Bjerre Jensen


1 Answers

No, it is not dangerous per say, but you might not get all the information that you want from a release build that was built without debug symbols. Here's some information from MSDN:

StackTrace information will be most informative with Debug build configurations. By default, Debug builds include debug symbols, while Release builds do not. The debug symbols contain most of the file, method name, line number, and column information used in constructing StackFrame and StackTrace objects.

like image 114
Filip Ekberg Avatar answered Jan 31 '23 07:01

Filip Ekberg