<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dotnet thoughts &#187; Debugging</title>
	<atom:link href="http://www.dotnetthoughts.net/tag/debugging/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dotnetthoughts.net</link>
	<description>a dotnet developer&#039;s technical blog</description>
	<lastBuildDate>Wed, 08 Feb 2012 03:18:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Debugging Windows Services</title>
		<link>http://www.dotnetthoughts.net/2009/06/18/debugging-windows-services/</link>
		<comments>http://www.dotnetthoughts.net/2009/06/18/debugging-windows-services/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 19:24:23 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.Net 3.0 / 3.5]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[Windows Forms]]></category>
		<category><![CDATA[Windows Service]]></category>

		<guid isPermaLink="false">http://anuraj.wordpress.com/?p=305</guid>
		<description><![CDATA[In the current project, I have to develop some windows services to sending out notification mails. The first challenge I faced is I can&#8217;t directly run and debug the Windows service. For that I need to install the service (using &#8230; <a href="http://www.dotnetthoughts.net/2009/06/18/debugging-windows-services/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In the current project, I have to develop some windows services to sending out notification mails.<br />
The first challenge I faced is I can&#8217;t directly run and debug the Windows service.<br />
For that I need to install the service (<em>using installutil –I ServiceName</em>) and attach the process to Visual studio, and then only I can debug it.</p>
<p>It works fine for me.</p>
<p>Then the next challenge was, debugging the code in the <em>onStart</em> event. Because once the service started, then only we can able to attach it to Visual Studio. So I put some code to write to text file, and/or event log. But I feel like it’s not a good method. After searching in the net I got a nice workaround.</p>
<pre class="brush: csharp; title: ; notranslate">
protected override void OnStart(string[] args)
{
System.Diagnostics.Debugger.Launch();
//Rest of the code
}
</pre>
<p>While starting the Service, it will display a dialog like this</p>
<div id="attachment_306" class="wp-caption alignnone" style="width: 410px"><a href="http://anuraj.files.wordpress.com/2009/07/dialog.png"><img src="http://anuraj.files.wordpress.com/2009/07/dialog.png" alt="Visual Studio Debug dialog" title="Visual Studio Debug dialog" width="400" height="432" class="size-full wp-image-306" /></a><p class="wp-caption-text">Visual Studio Debug dialog</p></div>
<p>After selecting Yes, Visual Studio will open up and you can start debugging. You can get more information from these links</p>
<ol>
<li><a href="http://blogs.msdn.com/yaleeyangmsblog/archive/2007/05/02/three-ways-debugging-net-windows-service.aspx" target="_blank">http://blogs.msdn.com/yaleeyangmsblog/archive/2007/05/02/three-ways-debugging-net-windows-service.aspx</a></li>
<li><a href="http://geekswithblogs.net/GertVerhoeven/archive/2007/11/28/117181.aspx" target="_blank">http://geekswithblogs.net/GertVerhoeven/archive/2007/11/28/117181.aspx</a></li>
<li><a href="http://msdn.microsoft.com/hi-in/magazine/cc301845(en-us).aspx" target="_blank">http://msdn.microsoft.com/hi-in/magazine/cc301845(en-us).aspx</a></li>
</ol>
<div class="betterrelated"><p><strong>Related content:</strong></p>
<ol><li> <a href="http://www.dotnetthoughts.net/2011/11/20/how-to-debug-windows-live-writer-plugins/" title="Permanent link to How to debug Windows Live Writer plugins">How to debug Windows Live Writer plugins</a>  </li>
<li> <a href="http://www.dotnetthoughts.net/2009/07/30/implementing-windows-authentication-in-asp-net-on-iis-7/" title="Permanent link to Implementing Windows authentication in ASP.NET on IIS 7">Implementing Windows authentication in ASP.NET on IIS 7</a>  </li>
<li> <a href="http://www.dotnetthoughts.net/2009/07/31/code-generation-using-t4-templates/" title="Permanent link to Code generation using T4 Templates">Code generation using T4 Templates</a>  </li>
<li> <a href="http://www.dotnetthoughts.net/2011/05/26/debugger-canvas/" title="Permanent link to Debugger Canvas">Debugger Canvas</a>  </li>
<li> <a href="http://www.dotnetthoughts.net/2010/12/08/wcf-test-client/" title="Permanent link to WCF Test Client">WCF Test Client</a>  </li>
</ol></div>]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2009/06/18/debugging-windows-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

