Click here to Skip to main content
15,168,105 members
Articles / Mobile Apps
Posted 21 Sep 2005


43 bookmarked

A simple solution to see the inside of your code

Rate me:
Please Sign up or sign in to vote.
4.69/5 (13 votes)
25 May 2006CPOL2 min read
A simple solution to see the inside of your code.


Have you ever wanted to see what happens inside of your code? This project catches in real time every trace message from your application, centralizes them, and shows them on your screen in a friendly way.

The package contains five projects:

  • Tracer is a pipe server, and it receives all the trace messages and shows them on the interface.
  • EsiListener is a custom listener and also the pipe client. It sends all the trace messages to the server.
  • CPPEsiListener a C++ DLL used to send messages to MyTracer.
  • Client is a C# demo application. It can be your application.
  • CPPClient is a C++ demo application.

How it looks

Image 1


  • It is very easy to add or remove without changing your code.
  • Works with every application which respects standard tracing mode.
  • Works with different applications at the same time.
  • Locates the trace messages inside your application.
  • Traces objects and display all their properties and values.

How to use it

  • The Listener can be added from the source code:
    Trace.Listeners.Add( new Esi.Diagnostics.Listener() );
  • The Listener can be added from your application Config file like shown below:
              <add name="myListener" 
                 type="Esi.Diagnostics.Listener, esiListener"/>    
  • For tracing, just use the standard tracing:
    Trace.WriteLine( " Hello world :) " ); 
    Trace.Write( "Hello again :P" );
  • If you want MyTracer to recognize your message as an error, information, or warning, use the convention described below:
    • error -> message has to start with [E],
    • warning -> message has to start with [W],
    • information -> message has to start with [I],
    • service -> message has to start with [S] (reserved for MyTracer application),
    • unknown messages -> any other messages.
    Trace.Write( "[E]Uuuups error :( " );
  • An interesting option is that you can trace object values with one call:
    Point p1 = new Point( 5, 5);
    Trace.WriteLine( p1 );
  • If you don't want to copy esiListener.dll in every application directory, you can insert esiListener.dll in the global assembly cache.
    gacutil -i esiListener.dll
  • For C++, copy the EsiListenerCPP.dll near the application. Add in the application project, Diagnostics.h and cpp (Set option: Do not use the precompiled header for the Diagnostic.cpp file). Before starting tracing, call:

    For trace, call:

    Trace::WriteLine("Trace from C++");

    Convention for erorr[E], warning[W], and information[I] works here.


  • Inter-Process Communication in .NET Using Named Pipes, Part 1, by Ivan L.
  • TraceListeners and Reflection, by Jerry Dennany.


I have updated this article especially for ninjacross :). That's all, and thank you for your attention.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
Romania Romania
No Biography provided

Comments and Discussions

QuestionNice work! However... Pin
ke4vtw13-May-08 8:21
Memberke4vtw13-May-08 8:21 
AnswerRe: Nice work! However... Pin
Maze14-May-08 11:30
MemberMaze14-May-08 11:30 
GeneralNot thread safe Pin
NinjaCross29-Sep-05 13:25
MemberNinjaCross29-Sep-05 13:25 
GeneralRe: Not thread safe Pin
Maze20-Oct-05 5:45
MemberMaze20-Oct-05 5:45 
You are right I will fix it as soon as possible. Thank you for you feedback and link.


who dares wins!
GeneralRe: Not thread safe Pin
NinjaCross16-May-06 4:18
MemberNinjaCross16-May-06 4:18 
JokeRe: Not thread safe Pin
Maze25-May-06 12:00
MemberMaze25-May-06 12:00 
GeneralRe: Not thread safe Pin
NinjaCross25-May-06 13:13
MemberNinjaCross25-May-06 13:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.