<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>VS2008 / .NET 3.5</title>
        <link>http://geekswithblogs.net/SoftwareDoneRight/category/7416.aspx</link>
        <description>Issues related to Visual Studio 2008 and .NET 3.5 (Orcas)</description>
        <language>en-US</language>
        <copyright>ChrisD</copyright>
        <managingEditor>chris@wtfsolutions.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>QuickTip:  Attach the VS Debugger to IIS&amp;rsquo;s Worker Process in a single keystroke</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2009/10/30/quicktip--attach-the-vs-debugger-to-iisrsquos-worker-process.aspx</link>
            <description>&lt;p&gt;I’ve been spending a lot of time lately debugging through some web-hosted applications.  Some of these applications are hosted by Visual Studio’s own internal web server (Cassini), and others are hosted by my local instance of IIS. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;Web projects hosted locally get automatic attached to the VS debugger when you press F5.  Projects hosted under IIS do not.  In order to debug IIS hosted projects, you must attach the Visual Studio debugger to the IIS worker process (aspnet_wp.exe or w3wp.exe) manually.  &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;Traditionally, you attach by selecting &lt;strong&gt;Attach To Process&lt;/strong&gt; from the &lt;strong&gt;Debug&lt;/strong&gt; menu, scrolling the list of processes until you find the worker process and then clicking “Attach”.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;Thanks to this handy macro I found by &lt;a href="http://snipplr.com/users/HologramX/"&gt;HologramX&lt;/a&gt; at &lt;a href="http://snipplr.com"&gt;snipplr.com&lt;/a&gt;, I’m able to attach with a single keystroke:&lt;/p&gt; &lt;p&gt;To add this macro to your environment,  &lt;strong&gt;Tools&lt;/strong&gt; &amp;gt; &lt;strong&gt;Macro IDE&lt;/strong&gt; &amp;gt; Add new item to MyMacros &amp;gt; Select Module, Name 'AttachToWebServer' &amp;gt; Copy/paste code.&lt;/p&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 85.36%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; height: 285px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;Imports&lt;/span&gt; System&lt;br /&gt;&lt;span style="color: #0000ff"&gt;Imports&lt;/span&gt; EnvDTE80&lt;br /&gt;&lt;span style="color: #0000ff"&gt;Imports&lt;/span&gt; System.Diagnostics&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Module&lt;/span&gt; AttachToWebServer&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; AttachToWebServer()&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; AspNetWp &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt; = &lt;span style="color: #006080"&gt;"aspnet_wp.exe"&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; W3WP &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt; = &lt;span style="color: #006080"&gt;"w3wp.exe"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; (AttachToProcess(AspNetWp)) &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; AttachToProcess(W3WP) &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;                System.Windows.Forms.MessageBox.Show(&lt;span style="color: #0000ff"&gt;String&lt;/span&gt;.Format(&lt;span style="color: #006080"&gt;"Process {0} or {1} Cannot Be Found"&lt;/span&gt;, AspNetWp, W3WP), &lt;span style="color: #006080"&gt;"Attach To Web Server Macro"&lt;/span&gt;)&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; AttachToProcess(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; ProcessName &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; Processes &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; EnvDTE.Processes = DTE.Debugger.LocalProcesses&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; Process &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; EnvDTE.Process&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; ProcessFound &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;False&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;For&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Each&lt;/span&gt; Process &lt;span style="color: #0000ff"&gt;In&lt;/span&gt; Processes&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; (Process.Name.Substring(Process.Name.LastIndexOf(&lt;span style="color: #006080"&gt;"\"&lt;/span&gt;) + 1) = ProcessName) &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;                Process.Attach()&lt;br /&gt;                ProcessFound = &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        AttachToProcess = ProcessFound&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Module&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre class="csharpcode"&gt; &lt;/pre&gt;
&lt;p&gt;To set as a keyboard shortcut go to &lt;strong&gt;Tools&lt;/strong&gt; &amp;gt; &lt;strong&gt;Options&lt;/strong&gt; &amp;gt; &lt;strong&gt;Keyboard&lt;/strong&gt;, and search for the name of the macro (AttachToWebServer) and then assign a keyboard shortcut.&lt;/p&gt;
&lt;p&gt;IIS-Attached Debugging is now one keystroke away.&lt;/p&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
]]&gt;&lt;/style&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=135866"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=135866" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/135866.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2009/10/30/quicktip--attach-the-vs-debugger-to-iisrsquos-worker-process.aspx</guid>
            <pubDate>Fri, 30 Oct 2009 13:45:11 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/135866.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2009/10/30/quicktip--attach-the-vs-debugger-to-iisrsquos-worker-process.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/135866.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/135866.aspx</trackback:ping>
        </item>
        <item>
            <title>QuickTip:  Did You Know??? Auto-Adding Dictionary entries</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2009/10/19/quicktip--did-you-know-auto-adding-dictionary-entries.aspx</link>
            <description>&lt;p&gt;When adding an item to a dictionary, I always thought you had to use the &lt;strong&gt;Add()&lt;/strong&gt; method, like this:&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; key = &lt;span style="color: #006080"&gt;"MyKey"&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; &lt;span style="color: #0000ff"&gt;value&lt;/span&gt; = 20;&lt;br /&gt;var myDictionary = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&amp;gt;();&lt;br /&gt;myDictionary.Add(key, &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;);          &lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Apparently, you can directly reference it in the collection, and if the key doesn’t exist, its auto-added to the collection&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; key = &lt;span style="color: #006080"&gt;"MyKey"&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; &lt;span style="color: #0000ff"&gt;value&lt;/span&gt; = 20;&lt;br /&gt;var myDictionary = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&amp;gt;();&lt;br /&gt;myDictionary[key] = &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;most likely you already knew this.  I did not.  Its the little things I guess.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=135542"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=135542" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/135542.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2009/10/19/quicktip--did-you-know-auto-adding-dictionary-entries.aspx</guid>
            <pubDate>Mon, 19 Oct 2009 09:21:52 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/135542.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2009/10/19/quicktip--did-you-know-auto-adding-dictionary-entries.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/135542.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/135542.aspx</trackback:ping>
        </item>
        <item>
            <title>Exception &amp;amp; Fault Handling in WCF</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2009/07/09/exception-amp-fault-handling-in-wcf.aspx</link>
            <description>&lt;p&gt;I am considering writing a policy based error handler for WCF.  The Error handler would be registered with the service host, and would automatically log all exceptions.    WCF Services would “opt-in”/register for this error handler by a custom attribute.&lt;/p&gt;  &lt;p&gt;Deciding how to handle the unhandled exceptions is the policy part.  The policy could state which exception types to convert to handled WCF faults, which exception types to map to different fault/exception types, which exceptions to obfuscate and which ones to allow to return to the caller (faulting the service channel).&lt;/p&gt;  &lt;p&gt;I’m thinking the policy would be handled via configuration, so the rules could be changed without requiring code drops. &lt;/p&gt;  &lt;p&gt;The policy-driven approach is similar to the enterprise library exception handling approach, but I think I could deliver 90% of the functionality with sufficiently less effort than is required by the entlib approach.&lt;/p&gt;  &lt;p&gt;Would anyone find value in this approach and solution?&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=133372"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=133372" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/133372.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2009/07/09/exception-amp-fault-handling-in-wcf.aspx</guid>
            <pubDate>Thu, 09 Jul 2009 08:12:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/133372.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2009/07/09/exception-amp-fault-handling-in-wcf.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/133372.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/133372.aspx</trackback:ping>
        </item>
        <item>
            <title>QuickTip - Flatten strings to a comma delimited list</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/12/23/quicktip---flatten-strings-to-a-comma-delimited-list.aspx</link>
            <description>&lt;p&gt;Ever need to convert a List of strings in a comma delimited list?  In the past I'd write a foreach loop. Something like:&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public static string &lt;/span&gt;FlattenStringList(&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;&amp;gt; items)
     {
         &lt;span style="color: #2b91af"&gt;StringBuilder &lt;/span&gt;str = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;StringBuilder&lt;/span&gt;();
         &lt;span style="color: blue"&gt;bool &lt;/span&gt;firstOne = &lt;span style="color: blue"&gt;false&lt;/span&gt;;
         &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(&lt;span style="color: blue"&gt;string &lt;/span&gt;item &lt;span style="color: blue"&gt;in &lt;/span&gt;items)
         {
             &lt;span style="color: blue"&gt;if &lt;/span&gt;(!firstOne)
                 str.Append(&lt;span style="color: #a31515"&gt;","&lt;/span&gt;);
             &lt;span style="color: blue"&gt;else
                 &lt;/span&gt;firstOne = &lt;span style="color: blue"&gt;false&lt;/span&gt;;
             str.Append(item);
         }
         &lt;span style="color: blue"&gt;return &lt;/span&gt;str.ToString();
         
     }&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, thanks to String.Join and  Linq, I can compress it to a single expression:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt;.Join(&lt;span style="color: #a31515"&gt;","&lt;/span&gt;, items.ToArray());&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Also useful when the source is IEnumerable&amp;lt;T&amp;gt;, and I want a property of T flattened, consider a list of people, to get a comma delimited list of all the first names is a simple matter of:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;firstNames = &lt;span style="color: blue"&gt;string&lt;/span&gt;.Join(&lt;span style="color: #a31515"&gt;","&lt;/span&gt;, (&lt;span style="color: blue"&gt;from &lt;/span&gt;person &lt;span style="color: blue"&gt;in &lt;/span&gt;people &lt;span style="color: blue"&gt;select &lt;/span&gt;person.FirstName).ToArray());

    &lt;br /&gt;    &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you need it a quote qualified, comma delimited list of first names:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;firstNames = &lt;span style="color: blue"&gt;string&lt;/span&gt;.Join(&lt;span style="color: #a31515"&gt;","&lt;/span&gt;, (&lt;span style="color: blue"&gt;from &lt;/span&gt;person &lt;span style="color: blue"&gt;in &lt;/span&gt;people &lt;span style="color: blue"&gt;select &lt;/span&gt;&lt;span style="color: #a31515"&gt;"\""&lt;/span&gt;+person.FirstName+&lt;span style="color: #a31515"&gt;"\""&lt;/span&gt;).ToArray());&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128121"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128121" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/128121.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/12/23/quicktip---flatten-strings-to-a-comma-delimited-list.aspx</guid>
            <pubDate>Tue, 23 Dec 2008 07:03:25 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/128121.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/12/23/quicktip---flatten-strings-to-a-comma-delimited-list.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/128121.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/128121.aspx</trackback:ping>
        </item>
        <item>
            <title>Iterating Static Fields / Properties</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/07/09/iterating-static-fields--properties.aspx</link>
            <description>&lt;p&gt;Often during development I end up with "Constants" classes, classes of constant or static values that I want design time Visual Studio intellisense support for, and run-time domain checking. &lt;/p&gt;  &lt;p&gt;Consider the following class:&lt;/p&gt;  &lt;p&gt;&lt;span style="color: blue"&gt;public static class&lt;/span&gt;&lt;span style="color: #2b91af"&gt;Constants     &lt;br /&gt;  &lt;/span&gt;{    &lt;br /&gt;       &lt;span style="color: blue"&gt;public static class&lt;/span&gt;&lt;span style="color: #2b91af"&gt;ClaimTypes     &lt;br /&gt;      &lt;/span&gt;{    &lt;br /&gt;           &lt;span style="color: blue"&gt;internal static string&lt;/span&gt;ClaimTypeNameSpace = &lt;span style="color: #a31515"&gt;"http://schemas.wtfsolutions.com/2008/07/claims/profile/"&lt;/span&gt;;    &lt;br /&gt;           &lt;span style="color: blue"&gt;public static string&lt;/span&gt;FirstName = ClaimTypeNameSpace + &lt;span style="color: #a31515"&gt;"firstname"&lt;/span&gt;;    &lt;br /&gt;           &lt;span style="color: blue"&gt;public static string&lt;/span&gt;LastName = ClaimTypeNameSpace + &lt;span style="color: #a31515"&gt;"lastname"&lt;/span&gt;;    &lt;br /&gt;           &lt;span style="color: blue"&gt;public static string&lt;/span&gt;DateOfBirth = ClaimTypeNameSpace + &lt;span style="color: #a31515"&gt;"dateofbirth"&lt;/span&gt;;    &lt;br /&gt;           &lt;span style="color: blue"&gt;public static string&lt;/span&gt;FavoriteColor = ClaimTypeNameSpace + &lt;span style="color: #a31515"&gt;"favoritecolor"&lt;/span&gt;;    &lt;br /&gt;       }    &lt;br /&gt;    &lt;br /&gt;   }&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;This class is handy at design time.  When I type "&lt;strong&gt;Constants.ClaimTypes."&lt;/strong&gt; up pops an intellisense list of the valid claim types for my application. &lt;/p&gt;  &lt;p&gt;The problem with this list is that you can't iterate through it at runtime, ensuring the value of a variable is in the valid ClaimType domain of values.  Ideally I'd like to be able to do this: &lt;font color="#ff0000"&gt;** THIS DOES NOT WORK ***&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;span style="color: blue"&gt;private bool &lt;/span&gt;validateClaimType(&lt;span style="color: blue"&gt;string &lt;/span&gt;claimType)      &lt;br /&gt;{      &lt;br /&gt;    &lt;span style="color: blue"&gt;return &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Constants&lt;/span&gt;.&lt;span style="color: #2b91af"&gt;ClaimTypes&lt;/span&gt;.Contains(claimType);      &lt;br /&gt;}      &lt;br /&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Fortunately, we can use reflection to build a runtime dictionary of the field name and field values&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, &lt;span style="color: blue"&gt;string&lt;/span&gt;&amp;gt; staticFieldsToList(&lt;span style="color: #2b91af"&gt;Type &lt;/span&gt;targetType)
{
    &lt;span style="color: blue"&gt;var &lt;/span&gt;list = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, &lt;span style="color: blue"&gt;string&lt;/span&gt;&amp;gt;(&lt;span style="color: #2b91af"&gt;StringComparer&lt;/span&gt;.OrdinalIgnoreCase);
    &lt;span style="color: blue"&gt;var &lt;/span&gt;fields = targetType.GetFields(BindingFlags.Public | BindingFlags.Static);
    &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;field &lt;span style="color: blue"&gt;in &lt;/span&gt;fields)
        list.Add(field.Name, field.GetValue(&lt;span style="color: blue"&gt;null&lt;/span&gt;) &lt;span style="color: blue"&gt;as string&lt;/span&gt;);
    &lt;span style="color: blue"&gt;return &lt;/span&gt;list;
}&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;and validate our claim type as follows: &lt;font color="#ff0000"&gt;** THIS WORKS **&lt;/font&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private bool &lt;/span&gt;validateClaimType(&lt;span style="color: blue"&gt;string &lt;/span&gt;claimType)
{
    &lt;span style="color: blue"&gt;return &lt;/span&gt;staticFieldsToList(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Constants&lt;/span&gt;.&lt;span style="color: #2b91af"&gt;ClaimTypes&lt;/span&gt;)).ContainsValue(claimType);
}&lt;/pre&gt;

  &lt;p&gt;In my real application I store the dictionary to a static field to avoid multiple reflection-based calls, but for the purposes of demonstrating functionality, the above code reflects the static class each call. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt; The best of both worlds, design-time IDE support and run-time domain validation.  &lt;/p&gt;

&lt;p&gt;I love it when a plan comes together.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=123702"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=123702" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/123702.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/07/09/iterating-static-fields--properties.aspx</guid>
            <pubDate>Thu, 10 Jul 2008 03:27:50 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/123702.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/07/09/iterating-static-fields--properties.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/123702.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/123702.aspx</trackback:ping>
        </item>
        <item>
            <title>Clean Up WCF Clients : The Right Way</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/05/23/clean-up-wcf-clients--the-right-way.aspx</link>
            <description>&lt;p&gt;As I've done more and more WCF work recently, I've noticed an intermittent problem running my unit tests. &lt;/p&gt; &lt;p&gt;The host seemingly hangs for no obvious reason.  Eventually the connection times out and produces the following in the service log:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;font color="#ff0000"&gt;System.ServiceModel.CommunicationObjectAbortedException, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Stopping the host and client and re-running the test allows it to pass without issue.  &lt;/p&gt; &lt;p&gt;The problem is related to the way I managed my WCF channels and client proxies.  In my code I make use of the ChannelFactory&amp;lt;T&amp;gt; object to create my wcf channels dynamically from my configuration information, like the following:&lt;/p&gt; &lt;p&gt; &lt;/p&gt;&lt;pre class="csharpcode"&gt;       &lt;span class="preproc"&gt;#region&lt;/span&gt; IdentityService Proxy
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; IIdentityService _identitySvc;
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; IIdentityService identitySvc
        {
            get
            {
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (_identitySvc == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
                {
                    var factory = &lt;span class="kwrd"&gt;new&lt;/span&gt; ChannelFactory&amp;lt;IIdentityService&amp;gt;(&lt;span class="str"&gt;"IdentityService"&lt;/span&gt;);
                    _identitySvc = factory.CreateChannel();
                }
                &lt;span class="kwrd"&gt;return&lt;/span&gt; _identitySvc;
            }

        }
        &lt;span class="preproc"&gt;#endregion&lt;/span&gt;&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&lt;span class="preproc"&gt;&lt;/span&gt; &lt;/pre&gt;
&lt;p&gt;The client proxy produced implements the typed interface "IIdentityService" in the above example.  It natively supports no operations for channel management and cleanup.  However, failing to clean up the client proxy may cause channel timeouts and resource blocking on the server. So channel cleanup is important, but if its not implemented in the client proxy, how do you manage it?&lt;/p&gt;
&lt;p&gt;The secret lies in the casting.  The transparent proxy produced implements a number of useful interfaces.  For our purposes we care about IDisposable and IClientChannel. When we're done with the proxy,  we must close the channel and dispose of it.  I've seen some examples like this:&lt;/p&gt;
&lt;blockquote&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; (IClientChannel client = (IClientChannel)channelFactory.CreateChannel())
{
    IIdentityService proxy = (IIdentityService)client;
}&lt;/pre&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;This is Bad.&lt;/font&gt;&lt;/strong&gt;  Yes, you are disposing of the channel resource, but you haven't closed the wcf channel, you've only disposed of your handle to it.  You must explicitly call close then dispose on the proxy like so:&lt;/p&gt;&lt;pre class="csharpcode"&gt;
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (_identitySvc != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
             {
                 ((IClientChannel)_identitySvc).Close();
                 ((IDisposable)_identitySvc).Dispose();
                 _identitySvc = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
             }&lt;/pre&gt;&lt;pre class="csharpcode"&gt; &lt;/pre&gt;
&lt;p&gt;Optionally, since IClientChannel implements IDisposable, you could call ((IClientChannel) proxy).Dispose().  If you prefer, and your design allows, you can still use the using statement, just be sure to add try/catch blocks and call the close() method on the casted proxy before the closing brace. I tend to have static references to my proxy classes so I have to explicitly call close() and dispose() when I complete my WCF operation.&lt;/p&gt;
&lt;p&gt;Now that I'm properly cleaning up my proxies, my WCF services run all my tests without hanging.&lt;/p&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
]]&gt;&lt;/style&gt;

&lt;style type="text/css"&gt;&lt;![CDATA[csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
]]&gt;&lt;/style&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=122354"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=122354" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/122354.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/05/23/clean-up-wcf-clients--the-right-way.aspx</guid>
            <pubDate>Fri, 23 May 2008 22:12:25 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/122354.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/05/23/clean-up-wcf-clients--the-right-way.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/122354.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/122354.aspx</trackback:ping>
        </item>
        <item>
            <title>Developing Windows Services</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/05/10/developing-windows-services.aspx</link>
            <description>&lt;p&gt;I've been developing and debugging a windows service for my current project. Working with a Windows service is very much like working with a console app, with the startup and shutdown logic separated into the servicebase's start and stop methods. &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;u&gt;Debugging a Windows Service&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;Unlike a console app, however Visual studio can't run a windows service and automatically attach the debugger (no Run-with-Debugger (F5) support).  Not to fear, its easily enough to attach the debugger to the windows service.  In my case, my service was starting and stopping right away, with no opportunity to attach the visual studio debugger to the running service.  Instead I added this handy dandy line of code to the constructor of the service class:&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;pre class="code"&gt;            &lt;span style="color: blue"&gt;#if &lt;/span&gt;DEBUG
             Debugger.Launch(); 
            &lt;span style="color: blue"&gt;#endif 
&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;when the service starts, Windows prompts you to attach a debugger. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/SoftwareDoneRight/WindowsLiveWriter/DevelopingWindowsServices_A343/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="image" src="http://geekswithblogs.net/images/geekswithblogs_net/SoftwareDoneRight/WindowsLiveWriter/DevelopingWindowsServices_A343/image_thumb.png" width="226" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Select the debugger of choice and step through your windows service. &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;u&gt;Removing and Reinstalling a Windows Service&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;I ran into a problem attempting to uninstall  and reinstall my windows service.  I was able to delete the service fine, but when I attempted to reinstall the windows service I received a "The Specified Service has been marked for deletion" exception.&lt;/p&gt;

&lt;p&gt;Microsoft recommends rebooting to solve this problem; a solution that is not very conducive to a development cycle.  Fortunately I stumbled upon a easier solution. &lt;/p&gt;

&lt;p&gt;It seems that when the windows service list is visible (Start-&amp;gt;Control Panel-&amp;gt;Administrative -&amp;gt; Services), the list of windows services is cached and locked resulting in the "The Specified Service has been marked for deletion" exception.  The fix, &lt;strong&gt;close the services dialog.&lt;/strong&gt;  With the dialog closed, I was able to re-install the windows service without issue. &lt;/p&gt;

&lt;p&gt;I've switched my process to starting and stopping the service using Net Start/ Net Stop batch files.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=122039"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=122039" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/122039.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/05/10/developing-windows-services.aspx</guid>
            <pubDate>Sat, 10 May 2008 16:48:56 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/122039.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/05/10/developing-windows-services.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/122039.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/122039.aspx</trackback:ping>
        </item>
        <item>
            <title>QuickTip: Case Insensitive Dictionaries</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/04/30/quicktip-case-insensitive-dictionaries.aspx</link>
            <description>&lt;p&gt;I've often thought about making my own implementation of a Dictionary&amp;lt;K,V&amp;gt; where the key values are case insensitive.&lt;/p&gt;  &lt;p&gt;Its been one of those things on my ever-growing to-do list. I usually end up casting the key values to all uppercase and try to encapsulate all my calls the the dictionary with my own logic that performs the case conversion.  A case insensitive dictionary would avoid all that nastiness. &lt;/p&gt;  &lt;p&gt;Sometimes it's helpful to read the tooltip overloads. As I coded a new dictionary instance today, I stumbled upon the &lt;/p&gt;  &lt;p&gt;&lt;font color="#000080"&gt;Dictionary&amp;lt;(Of &amp;lt;(TKey, TValue&amp;gt;)&amp;gt;) Constructor (IEqualityComparer&amp;lt;(Of &amp;lt;(TKey&amp;gt;)&amp;gt;))&lt;/font&gt; overload.   &lt;/p&gt;  &lt;p&gt;Apparently I can pass my own equality comparer into the constructor which tells the dictionary how to compare key values.   Could it really be that easy?&lt;/p&gt;  &lt;p&gt;Yep, it exactly that easy.  To make my dictionary&amp;lt;string,string&amp;gt; use case insensitive keys, declare the dictionary as follows:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#000080"&gt;Dictionary&amp;lt;string, string&amp;gt; argList = new Dictionary&amp;lt;string, string&amp;gt;(StringComparer.CurrentCultureIgnoreCase);&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Now  args["Test"] and args["TEST"] return the same item from my dictionary.&lt;/p&gt;  &lt;p&gt;I love it when I can mark things done on my to-do list without actually having to do any work. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121790"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121790" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/121790.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/04/30/quicktip-case-insensitive-dictionaries.aspx</guid>
            <pubDate>Wed, 30 Apr 2008 20:28:01 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/121790.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/04/30/quicktip-case-insensitive-dictionaries.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/121790.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/121790.aspx</trackback:ping>
        </item>
        <item>
            <title>QuickTip: Debugging VBS Files with CScript.exe and Visual Studio</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/04/14/quicktip-debugging-vbs-files-with-cscript.exe-and-visual-studio.aspx</link>
            <description>&lt;p&gt;This is another one of those "Posted here for &lt;strong&gt;MY&lt;/strong&gt; convenience" tips.&lt;/p&gt;  &lt;p&gt;You can use the Visual Studio Debugger to debug a .vbs (vbscript) file executed with cScript.exe by using the //X flag at the command line.   &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;To debug MyTest.vbs &lt;/p&gt;    &lt;p&gt;&lt;font color="#000080"&gt;cscript.exe MyTest.vbs //X&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;The //X will set a breakpoint and invoke the "select a debugger"  dialog where you can choose Visual Studio and step into your vbs code.  I haven't found a way to directly edit from the debugger however, so I end up having to debug, break execution, fix my bug and restart the vbs script file again to see my changes. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121228"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121228" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/121228.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/04/14/quicktip-debugging-vbs-files-with-cscript.exe-and-visual-studio.aspx</guid>
            <pubDate>Mon, 14 Apr 2008 16:26:15 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/121228.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/04/14/quicktip-debugging-vbs-files-with-cscript.exe-and-visual-studio.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/121228.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/121228.aspx</trackback:ping>
        </item>
        <item>
            <title>QuickTip: Performing work on a new thread using anonymous delegates</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/04/07/quicktip-performing-work-on-a-new-thread-using-anonymous-delegates.aspx</link>
            <description>&lt;p&gt;I know this is available other places on the web, but I'm posting it here because I often have to search for it.  This tip is more for my benefit than others :)&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;class&lt;/span&gt; Program
{
   &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main()
   {
      Thread t = &lt;span class="kwrd"&gt;new&lt;/span&gt; Thread(&lt;span class="kwrd"&gt;delegate&lt;/span&gt;() { 
         SayName(&lt;span class="str"&gt;"Lou"&lt;/span&gt;,&lt;span class="str"&gt;"Costello"&lt;/span&gt;);
         });
      t.Start();
   }

   &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SayName(&lt;span class="kwrd"&gt;string&lt;/span&gt; firstName, &lt;span class="kwrd"&gt;string&lt;/span&gt; lastName)
  {
        Console.WriteLine(firstName + &lt;span class="str"&gt;" "&lt;/span&gt; + lastName);
  }
}&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121108"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121108" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/121108.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/04/07/quicktip-performing-work-on-a-new-thread-using-anonymous-delegates.aspx</guid>
            <pubDate>Tue, 08 Apr 2008 01:39:33 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/121108.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2008/04/07/quicktip-performing-work-on-a-new-thread-using-anonymous-delegates.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/121108.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/121108.aspx</trackback:ping>
        </item>
    </channel>
</rss>