Reputation: 2387
When I first tried C# programming I was very glad to see that finally there's some progress in error reporting. Assertions, exceptions and inner exceptions where easy to debug in visual studio. Unfortunately this excitement wasn't long lived, now I'm noticing more and more limitations, such as buggy callstack-reporting in BeginInvoke, buggy line-number-reporting in released asp.net applications, absolutely no error information on computers without visual studio (debug builds of desktop applications), etc. So in the end C# error reporting is just as ass as C++ error reporting.
So, my question is, is there a way to force Debug.Assert to work in all builds, make it report correct line-numbers and callstack information, especially when not executing from visual studio, especially when not even having visual studio installed?
Upvotes: 0
Views: 563
Reputation: 1435
In Visual Studio C# and Visual Basic projects, by default, the "DEBUG" conditional compilation symbol is defined for debug builds, and the "TRACE" symbol is defined for both debug and release builds
If you would like to get Debug.Assert works you needto set DEBUG flags in you project. - Right-click on your project - Go to Build tab - There is " Define Debug constant" chaeck box - you just check to check box. (Do both on Release and debug mode of your project).
Or
You should build/complie your project as /define:DEBUG;TRACE.
Upvotes: 0
Reputation: 16141
Line numbers in callstacks do not depend on or require Visual Studio. They requires the PDB files created during the build process. If your EXEs and DLLs have their corresponding PDB files in the same folder, all stack traces (from exceptions/asserts) will contain line numbers.
Upvotes: 1