<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Steve Wellens  : Deployment</title><link>http://weblogs.asp.net/stevewellens/archive/tags/Deployment/default.aspx</link><description>Tags: Deployment</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Debugging a Deployed Site</title><link>http://weblogs.asp.net/stevewellens/archive/2009/02/01/debugging-a-deployed-site.aspx</link><pubDate>Sun, 01 Feb 2009 13:57:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6703693</guid><dc:creator>SGWellens</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/stevewellens/rsscomments.aspx?PostID=6703693</wfw:commentRss><comments>http://weblogs.asp.net/stevewellens/archive/2009/02/01/debugging-a-deployed-site.aspx#comments</comments><description>&lt;P&gt;"It works on &lt;EM&gt;my&lt;/EM&gt; machine." &lt;/P&gt;
&lt;P&gt;How many times have we heard that?&amp;nbsp; Getting something to work on other machines, after deployment, can be the final challenge in a successful project.&amp;nbsp; 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&amp;nbsp;and then debugging.&amp;nbsp; It's not a pleasant task. &lt;/P&gt;
&lt;P&gt;An often overlooked but useful tool is: &amp;nbsp;System.Diagnostics.Debug.WriteLine(...) &lt;/P&gt;
&lt;P&gt;Here are some sample lines in global.asax: &lt;/P&gt;
&lt;DIV style="FONT-FAMILY: Courier New; BACKGROUND: white; COLOR: black; FONT-SIZE: 10pt"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="BACKGROUND: #ffee62"&gt;&amp;lt;%&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;@&lt;/SPAN&gt; &lt;SPAN style="COLOR: #a31515"&gt;Application&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;Language&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="C#"&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND: #ffee62"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;script&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;RunAt&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="server"&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Application_Start(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;EventArgs&lt;/SPAN&gt; e)&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.Diagnostics.&lt;SPAN style="COLOR: #2b91af"&gt;Debug&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"****ApplicationStart"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Application_BeginRequest(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;EventArgs&lt;/SPAN&gt; e) &lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.Diagnostics.&lt;SPAN style="COLOR: #2b91af"&gt;Debug&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Application_BeginRequest"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Application_EndRequest(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;EventArgs&lt;/SPAN&gt; e)&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.Diagnostics.&lt;SPAN style="COLOR: #2b91af"&gt;Debug&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Application_EndRequest"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Session_Start(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;EventArgs&lt;/SPAN&gt; e)&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.Diagnostics.&lt;SPAN style="COLOR: #2b91af"&gt;Debug&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Session_Start"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;Here is what the outputs look like in Visual Studio: Debug-&amp;gt;Windows-&amp;gt;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. &lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;IMG style="WIDTH: 332px; HEIGHT: 279px" src="http://weblogs.asp.net/blogs/SteveWellens/Post1/IDE_Output.jpg" width=332 height=279 mce_src="http://weblogs.asp.net/blogs/SteveWellens/Post1/IDE_Output.jpg"&gt;&lt;/P&gt;
&lt;P&gt;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.&amp;nbsp; Microsoft has acquired Sysinternals so you can search Microsoft's web site to download it. &lt;/P&gt;
&lt;P&gt;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). &lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;IMG style="WIDTH: 466px; HEIGHT: 297px" src="http://weblogs.asp.net/blogs/SteveWellens/Post1/DebugView_Output.jpg" width=466 height=297 mce_src="http://weblogs.asp.net/blogs/SteveWellens/Post1/DebugView_Output.jpg"&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Notes: &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;1)&amp;nbsp; Depending on the operating system, you may need to turn on global capturing of events in DebugView: &lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Capture-&amp;gt;Capture Global Win32 &lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;2)&amp;nbsp; Debugging strings are turned off when compilation debug is false in&lt;STRONG&gt; web.config.&lt;/STRONG&gt; To get the debug strings to work, debug must be "true" &lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;compilation&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;debug&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;strict&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;explicit&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;3)&amp;nbsp; If you run the&amp;nbsp;site in Visual Studio, you will not see the strings in DebugView.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope you find this information useful. &lt;/P&gt;
&lt;P&gt;Steve Wellens&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: #e0e0e0; FONT-SIZE: 10pt"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6703693" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/stevewellens/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/stevewellens/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/stevewellens/archive/tags/DebugView/default.aspx">DebugView</category><category domain="http://weblogs.asp.net/stevewellens/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://weblogs.asp.net/stevewellens/archive/tags/Deployment/default.aspx">Deployment</category></item></channel></rss>