Contents tagged with DebugView
"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:
<%@ Application Language="C#" %>
void Application_Start(object sender, EventArgs e)
void Application_BeginRequest(object sender, EventArgs e)
void Application_EndRequest(object sender, EventArgs e)
void Session_Start(object sender, EventArgs e)
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).
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.