Click here to Skip to main content
15,881,092 members
Articles / Programming Languages / C++

Debugging a Deployed Site

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
7 Apr 2009CPOL1 min read 15.8K   12   2
"It works on my machine." How many times have we heard that?  Getting something to work on other machines, after deployment, can be the final challenge in a successful project.

"It works on my machine."

How many times have we heard that?  Getting something to work on other machines, after deployment, can be the final challenge in a successful project.  The worst case scenario is having to go to the problem machine (hopefully it isn't in the remote reaches of Siberia) installing the IDE, patches, source code, third party libraries, compiling and then debugging.  It's not a pleasant task.

An often overlooked but useful tool is:  System.Diagnostics.Debug.WriteLine(...)

Here are some sample lines in global.asax:

C#
<%@ Application Language="C#" %>
 
<script RunAt="server">
 
    void Application_Start(object sender, EventArgs e)
    {
        System.Diagnostics.Debug.WriteLine("****ApplicationStart");
    }
    void Application_BeginRequest(object sender, EventArgs e) 
    {
        System.Diagnostics.Debug.WriteLine("Application_BeginRequest");
    }
    void Application_EndRequest(object sender, EventArgs e)
    {
        System.Diagnostics.Debug.WriteLine("Application_EndRequest");
    }
    void Session_Start(object sender, EventArgs e)
    {
        System.Diagnostics.Debug.WriteLine("Session_Start");
    }

Here is what the outputs look like in Visual Studio: Debug->Windows->Output. I turned off the Module Load messages to keep the output cleaner. An interesting thing to note is that the first Application_BeginRequest triggers the Session_Start event. Clicking a button a few times generates the other Application_BeginRequest events.

   

So far so good, but how does this help debugging on a deployed machine? The answer is by using a free tool called DebugView from Sysinternals.  Microsoft has acquired Sysinternals so you can search Microsoft's web site to download it.

Here is the same output captured by DebugView. The extra lines are caused by a Sound Card device driver on the host machine (the developers may have made a mistake).

   

Notes:

  1. Depending on the operating system, you may need to turn on global capturing of events in DebugView:

    Capture->Capture Global Win32

  2. Debugging strings are turned off when compilation debug is false in web.config. To get the debug strings to work, debug must be "true"
    <compilation debug="true" strict="false" explicit="true"> 
  3. If you run the site in Visual Studio, you will not see the strings in DebugView.

I hope you find this information useful.

Steve Wellens

This article was originally posted at http://weblogs.asp.net/stevewellens/privaterss.aspx

License

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


Written By
EndWell Software, Inc.
United States United States
I am an independent contractor/consultant working in the Twin Cities area in Minnesota. I work in .Net, Asp.Net, C#, C++, XML, SQL, Windows Forms, HTML, CSS, etc., etc., etc.

Comments and Discussions

 
Generallog4net is a better solution to this problem Pin
HightechRider7-Apr-09 12:46
HightechRider7-Apr-09 12:46 
GeneralRe: log4net is a better solution to this problem [modified] Pin
Steve Wellens7-Apr-09 13:13
Steve Wellens7-Apr-09 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.