What is the difference between Debug.Write and Trace.Write? When should each be used?

Q

What is the difference between Debug.Write and Trace.Write? When should each be used?

✍: Guest

A

Answer1:
The Debug.Write call won’t be compiled when the DEBUG symbol is not defined (when doing a release build). Trace.Write calls will be compiled. Debug.Write is for information you want only in debug builds, Trace.Write is for when you want it in release build as well. And in any case, you should use something like log4net because that is both faster and better

Answer2:
Debug.Write & Trace.write - both works in Debug mode, while in Release Mode,Trace.write only will work .Try changing the Active Config property of Solution in Property page nd find the difference. Debug.write is used while debuging a project and Trace.write is used in Released verion of Applications.

2014-02-24, 1822👍, 0💬