Debuging .Net Applications without attaching Debuggers for MS Office Add-Ins
If you are developing .net applications such as managed windows services, managed Add-Ins for MS Office or Interope application such Deskbar search etc.. and want to debug output without attching debugger or in production enviroment remotely you can use the DebugView for Windows v4.64.
Following is the step by step example of the same
1) Create a sample concole application in c#
2) Write following line of code
using System;
using System.Collections.Generic;
using
System.Text;
namespace
ExampleDebugView
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.
Trace.WriteLine("Sample Debug View Output");
System.Diagnostics.
Trace.WriteLine("Enters The Main Method");
Console.WriteLine("DebugViewer Outputs");
System.Diagnostics.
Trace.WriteLine("Exits The Main Method");
Console.ReadLine();
}
}
}
3) Write a app.config file with the following settings
<?
xml version="1.0" encoding="utf-8" ?>
<
configuration>
<
system.diagnostics>
<
switches>
<!--
This switch controls general messages. In order to
receive general trace messages change the value to the
appropriate level. "1" gives error messages, "2" gives errors
and warnings, "3" gives more detailed error information, and
"4" gives verbose trace information
-->
<
add name="TraceLevelSwitch" value="4" />
</
switches>
</
system.diagnostics>
</
configuration>
4) Run DebugViewer .exe and then exccute your application
5) You should see the trace output on your DebugViewer.exe grid.
This tool is very helpful in troubleshooting errors when developing Managed or Interop applications. There are other tools as well which can be used for debugging .net application or windows application at runtime such as Cordbg.exe (Managed Code only) and Windbg