App Problems? No Visual Studio? Try DebugView

DebugView is a pretty neat application, and it can be a Godsend if you’re running into application problem.  So what is DebugView?  Here is the official description:

DebugView is an application that lets you monitor debug output on your local system, or any computer on the network that you can reach via TCP/IP. It is capable of displaying both kernel-mode and Win32 debug output, so you don't need a debugger to catch the debug output your applications or device drivers generate, nor do you need to modify your applications or drivers to use non-standard debug output APIs.

What does this mean for you, the developer?  You can add trace code to your application that can be read via DebugView.  This isn’t meant to be a replacement for an actual logging solution, but it can be helpful in cases where you need to output debug information and you don’t want to get in the way of the user.

Where Do I Get DebugView?

DebugView is free to download.  Click here to download DebugView.  Un-zip the file, and run the Dbgview.exe file.


Show me the code!

Let’s imagine a simple C# application:

class Program  
      static void Main(string[] args)       
            Debug.WriteLine("DebugView test is starting up...");

            for (int x = 0; x < 100; x++)           
                   Debug.WriteLineIf(x % 10 == 0, string.Format("{0}", x));           

            Debug.WriteLine("DebugView test is shutting down...");       

If we watch this in the Visual Studio output window, here’s what the results are:


Now, let’s run our application stand alone, but with DebugView running.


If you look at Time, this represents how long DebugView has been running.  What we’re interested in is the Debug Print column.  There are two important parts to the string in this column.  First is the number in the brackets.  In this case, [4336] is my process ID.  You can filter off this value, so you’re only looking at your application.  If you look about, there is another process writing into the stream.  Lots of Windows processes will write to the debug stream, so you’ll have to filter for your application to avoid the noise.

As a note, this only works in Debug mode.  If you’re building in Release mode, the Debug lines are not compiled into the application.

I hope you start using this little trick when you’re building your applications.  It can be a Godsend when someone is running into a problem, and you have no idea where it’s happening in the application.


comments powered by Disqus