Console.WriteLine ("File name = {0}", frame.) GetFileName ());
Console.WriteLine ("Line no = {0}", frame. Getfilelinenumber ());
Console.WriteLine ("Function name = {0}", frame.) GetMethod ());
/*
The following text comes from a online forum:
I have tried using this and some success, but it does not seem to work
With using the release version of code.
Also, we are considering using a code obfuscator, and this would Also
Prevent things like function name from being valid when obtaining it at run
Time. I would prefer a compile time method if possible.
========================================================================
"StackTrace information would be most informative with the Debug build
Configurations. By default, the debug builds include debug symbols, while
Release builds does not. The debug symbols contain most of the file, method
Name, line number, and column information used in constructing StackFrame
and StackTrace objects. StackTrace might not the as many method calls as
Expected, due to code transformations that occur during optimization. "
If you are really want to still get full info in release builds (without
Obfuscation), then go to project/properties Select Configuration
Properties/build and set the following:
1.Optimize Code False
2.Generate Debugging Information True
Per the obfuscation bit and the point of it are to deny folks the opportunity
To reverse-engineer your code. The ability to get a good stack trace from
Obfuscated code would defeat the reasons for obfuscation
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.