Trace & debug


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Trace & debug

  1. #1
    Join Date
    Dec 2004
    Posts
    717

    Trace & debug

    Hi,
    What is the differences between Trace & debug?
    Thanks in adv:-)
    Best Regards,
    Michael Sync
    http://michaelsync.net

    The more you share,The more you get

  2. #2
    Join Date
    Nov 2004
    Location
    Huddinge, Sweden
    Posts
    283
    Essentially that the Debug calls are optimized away in release builds, while calls to Trace are not. This once bit me when I had function calls in the arguments to Debug.WriteLine, and these functions altered the state of the system. In release build these calls weren't performed, and it took me a while to understand why the app failed in release builds...

    Rune
    If you hit a brick wall, you didn't jump high enough!

  3. #3
    Join Date
    Dec 2004
    Posts
    717
    Sorry.Rune. I can't understand.
    Can you explain me more? Please. [with example.]:-)
    Thanks.
    Best Regards,
    Michael Sync
    http://michaelsync.net

    The more you share,The more you get

  4. #4
    Join Date
    Nov 2004
    Location
    Huddinge, Sweden
    Posts
    283
    OK:

    Code:
    using System;
    using System.Diagnostics;
    
    namespace slask
    {
      class Program
      {
        private static  int _x = 0;
        private static string Foo()
        {
          _x++;
          return "Foo called";
        }
    
        static void Main(string[] args)
        {
          System.Diagnostics.Debug.WriteLine("Calling Foo in debug call: " + Foo() + ", and the value of _x is: " + _x.ToString());
          System.Diagnostics.Trace.WriteLine("Calling Foo in trace call: " + Foo() + ", and the value of _x is: " + _x.ToString());
          System.Console.WriteLine("The value of _x is {0}", _x);
        }
      }
    }
    Run this in both release and debug builds, and see if you spot the difference in the output.

    There are more differences, but I'd reccomend MSDN for the specifics. It would be a long treatise to write.

    Rune
    If you hit a brick wall, you didn't jump high enough!

  5. #5
    Join Date
    Dec 2004
    Posts
    717
    Thank you so much.Rune Bivrin.
    I'll try to find in MSDN and I'll also try to understand your code.
    Thanks again.
    Best Regards,
    Michael Sync
    http://michaelsync.net

    The more you share,The more you get

  6. #6
    Join Date
    Nov 2004
    Location
    Huddinge, Sweden
    Posts
    283
    Start here:
    MSDN Trace Class

    Rune
    If you hit a brick wall, you didn't jump high enough!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center