<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>What Was I Thinking?</title>
        <link>http://geekswithblogs.net/SoftwareDoneRight/Default.aspx</link>
        <description>Follies &amp; Foils of .NET Development</description>
        <language>en-US</language>
        <copyright>ChrisD</copyright>
        <managingEditor>chris@wtfsolutions.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <image>
            <title>What Was I Thinking?</title>
            <url>http://geekswithblogs.net/images/RSS2Image.gif</url>
            <link>http://geekswithblogs.net/SoftwareDoneRight/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>Enabling Sql Server Broker Service Hangs</title>
            <category>SQL</category>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2012/01/28/enabling-sql-server-broker-service-hangs.aspx</link>
            <description>&lt;p&gt;If your connection hangs while attempting to start sql server broker service, its likely caused by the system trying to gain exclusive access to your database.   Some people recommend stopping and restarting the sql server instance.  I find that a little heavy-handed, like swatting a fly with a sledge hammer.  Instead switch the database into single user mode, enable the broker service, and restore the database to multi-user mode. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;1) Set the database to single user mode:&lt;/p&gt; &lt;p&gt;ALTER DATABASE [DBNAME] SET SINGLE_USER WITH ROLLBACK IMMEDIATE&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;2) Enable Broker Service on the database &lt;/p&gt; &lt;p&gt;ALTER DATABASE [DBNAME] SET ENABLE_BROKER;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;3)Restore the database to multi-user mode&lt;/p&gt; &lt;p&gt;ALTER DATABASE [DBNAME] SET MULTI_USER&lt;/p&gt; &lt;p&gt;Of course you’ll need proper permissions, but enabling the service this way prevents interruption to any other databases running on your server.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;Also make sure Broker Service is enabled:&lt;/p&gt;&lt;pre&gt;SELECT is_broker_enabled FROM sys.databases WHERE name = ‘DBNAME’;It should return 1 if its enabled.&lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt;&lt;pre&gt;-- Enable Service Broker:
ALTER DATABASE [DBNAME] SET ENABLE_BROKER;

-- Disable Service Broker:
ALTER DATABASE [DBNAME] SET DISABLE_BROKER;&lt;/pre&gt; &lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/148512.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2012/01/28/enabling-sql-server-broker-service-hangs.aspx</guid>
            <pubDate>Sat, 28 Jan 2012 21:53:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/148512.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2012/01/28/enabling-sql-server-broker-service-hangs.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/148512.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/148512.aspx</trackback:ping>
        </item>
        <item>
            <title>Google&amp;rsquo;s Public DNS Servers</title>
            <category>General Geekiness</category>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/10/26/googlersquos-public-dns-servers.aspx</link>
            <description>&lt;p&gt;Tired of ISP DNS service errors?  switch to use Google’s.  They are FAST and ALWAYS available. &lt;/p&gt;  &lt;p&gt;Primary: 8.8.8.8&lt;/p&gt;  &lt;p&gt;Secondary: 8.8.4.4&lt;/p&gt; &lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/147460.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/10/26/googlersquos-public-dns-servers.aspx</guid>
            <pubDate>Wed, 26 Oct 2011 19:48:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/147460.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/10/26/googlersquos-public-dns-servers.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/147460.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/147460.aspx</trackback:ping>
        </item>
        <item>
            <title>Performing Case-Insensitive joins using EXCEPT operator in LINQ</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/10/26/performing-case--insensitive-joins-using-except-operator-in-linq.aspx</link>
            <description>&lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt; var daysOfWeek = &lt;span class="kwrd"&gt;new&lt;/span&gt;[] { &lt;span class="str"&gt;"Sunday"&lt;/span&gt;, &lt;span class="str"&gt;"Monday"&lt;/span&gt;, &lt;span class="str"&gt;"Tuesday"&lt;/span&gt;, &lt;span class="str"&gt;"Wednesday"&lt;/span&gt;, &lt;span class="str"&gt;"Thursday"&lt;/span&gt;, &lt;span class="str"&gt;"Friday"&lt;/span&gt;, &lt;span class="str"&gt;"Saturday"&lt;/span&gt; };&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt; var workDays = daysOfWeek.Except( &lt;span class="kwrd"&gt;new&lt;/span&gt; []{ &lt;span class="str"&gt;"SUNDAY"&lt;/span&gt;, &lt;span class="str"&gt;"SaTURdaY"&lt;/span&gt;}); &lt;span class="rem"&gt;// Performs a case sensitive search and yields Sunday,Monday - Saturday. &lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;workDays = daysOfWeek.Except(&lt;span class="kwrd"&gt;new&lt;/span&gt;[] { &lt;span class="str"&gt;"SUNDAY"&lt;/span&gt;, &lt;span class="str"&gt;"SaTURdaY"&lt;/span&gt; },StringComparer.OrdinalIgnoreCase); &lt;span class="rem"&gt;// Performs a case insensitive search and yields Monday-Friday&lt;/span&gt;&lt;/pre&gt;
&lt;/div&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;/p&gt;

&lt;p&gt;The except operator takes a comparer that tells it how to evaluate the two lists.  Nice one!&lt;/p&gt; &lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/147455.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/10/26/performing-case--insensitive-joins-using-except-operator-in-linq.aspx</guid>
            <pubDate>Wed, 26 Oct 2011 06:20:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/147455.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/10/26/performing-case--insensitive-joins-using-except-operator-in-linq.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/147455.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/147455.aspx</trackback:ping>
        </item>
        <item>
            <title>How can I include my derived class type name in the serialized JSON?</title>
            <category>Visual Studio</category>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/06/30/how-can-i-include-my-derived-class-type-name-in.aspx</link>
            <description>&lt;p&gt;Sometimes working with the js Serializer is easy, sometimes its not.   When I attempt to serialize an object that is derived from a base, the serializer decided whether or not to include the type name. &lt;/p&gt;  &lt;p&gt;When its present, the type name is represented by a ___type attribute in the serialized json like this:&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;&lt;code&gt;{"d":{"__type":"Commerce.Integration.Surfaces.OrderCreationRequest"&lt;/code&gt;&lt;code&gt;,"RepId":0}}&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt; The missing type name is a problem if I intend to ship the object back into a web method that needs to deserialize the object.   Without the Type name, serialization will fail and result in a ugly web exception.&lt;/p&gt;

&lt;p&gt;The solution, which feels more like a work-around, is to explicitly tell the serializer to ALWAYS generate the type name for each derived type.  You make this declaration by adding a [GenerateScriptType())] attribute for each derived type to the top of the web page declaration.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;For example, assuming I had 3 derivations of OrderCreationRequest; PersonalOrderCreationRequest, CompanyOrderCreationRequest, InternalOrderCreationRequestion, the code-behind for my web page would be decorated as follows:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;    [GenerateScriptType(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(PersonalOrderCreationRequest))]
    [GenerateScriptType(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(CompanyOrderCreationRequest))]
    [GenerateScriptType(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(InternalOrderCreationRequest))]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; OrderMethods : Page
{
...
}&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;With the type names generated in the serialized JSON, the serializer can successfully deserialize instances of any of these types passed into a web method.&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;Hope this helps you as much as it did me. &lt;/pre&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;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/146043.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/06/30/how-can-i-include-my-derived-class-type-name-in.aspx</guid>
            <pubDate>Fri, 01 Jul 2011 01:35:34 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/146043.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/06/30/how-can-i-include-my-derived-class-type-name-in.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/146043.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/146043.aspx</trackback:ping>
        </item>
        <item>
            <title>QuickTip: Determine if Type implements IEnumerable&amp;lt;T&amp;gt;</title>
            <category>Visual Studio</category>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/04/28/quicktip--determine-if-type-implements-ienumerablelttgt.aspx</link>
            <description>&lt;p&gt;I was working on a project that required a determination if the type was an IEnumerable collection of some type.  &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;Using a bit of reflection and the handy-dandy GetGenericTypeDefinition method, I arrive at this:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a993c637-4913-4637-88b4-a087f572e36c" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; IsIEnumerableOfT(&lt;span style="color:#2b91af"&gt;Type&lt;/span&gt; type)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;      {&lt;/li&gt; &lt;li&gt;          &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; type.GetInterfaces().Any(t =&amp;gt; t.IsGenericType &amp;amp;&amp;amp; t.GetGenericTypeDefinition() == &lt;span style="color:#0000ff"&gt;typeof&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;&amp;gt;)) ;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;      }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Happy Coding!&lt;/p&gt; &lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/145068.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/04/28/quicktip--determine-if-type-implements-ienumerablelttgt.aspx</guid>
            <pubDate>Thu, 28 Apr 2011 13:26:23 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/145068.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/04/28/quicktip--determine-if-type-implements-ienumerablelttgt.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/145068.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/145068.aspx</trackback:ping>
        </item>
        <item>
            <title>Reorder Your Accounts in Thunderbird</title>
            <category>General Geekiness</category>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/04/20/reorder-your-accounts-in-thunderbird.aspx</link>
            <description>&lt;p&gt;Ever wanted to re-order your Thunderbird accounts?&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;You can either modify the prefs.js manually &lt;/p&gt;  &lt;p&gt;1. Exit Thunderbird if its running.&lt;/p&gt;  &lt;p&gt;2. Locate your prefs.js file (default location is c:\users\[your account]AppData\Thunderbird\Profiles&lt;/p&gt;  &lt;p&gt;3. create a backup , just in case. &lt;/p&gt;  &lt;p&gt;4. Open the prefs.js in any text editor and look for: user_pref("mail.accountmanager.accounts", "account1,account2,account3,account4…"); line&lt;/p&gt;  &lt;p&gt;5. Change the order of the accounts manually&lt;/p&gt;  &lt;p&gt;6. Restart Thunderbird&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;OR &lt;/p&gt;  &lt;p&gt;1. Download and install the FolderPane add-on.&lt;/p&gt;  &lt;p&gt;2. From Thunderbird, select Tools-&amp;gt;Add ons –&amp;gt; Folderpane and reorder the accounts using the “Move Up” and “Move Down” buttons. &lt;/p&gt;  &lt;p&gt;3. Close and restart Thunderbird. &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;The choice is yours.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/144974.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/04/20/reorder-your-accounts-in-thunderbird.aspx</guid>
            <pubDate>Wed, 20 Apr 2011 16:57:28 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/144974.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/04/20/reorder-your-accounts-in-thunderbird.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/144974.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/144974.aspx</trackback:ping>
        </item>
        <item>
            <title>QuickTip:  Selecting Children from a Parent Item in Linq</title>
            <category>Visual Studio</category>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/03/29/quicktip--selecting-children-from-a-parent-item-in-linq.aspx</link>
            <description>&lt;p&gt;I’m posting this here because I keep forgetting the syntax, and thought others might benefit as well.&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;Given :&lt;/p&gt;  &lt;p&gt;public class ParentItem&lt;/p&gt;  &lt;p&gt;{&lt;/p&gt;  &lt;p&gt;   IEnumerable&amp;lt;ChildItem&amp;gt; Children&lt;/p&gt;  &lt;p&gt;}&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;Selecting all the childitem instances from an IEnumerable&amp;lt;ParentItem&amp;gt;:&lt;/p&gt;  &lt;p&gt;var allChildren = ParentItems.SelectMany(parent=&amp;gt;parent.Children);&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;Selecting matching childItem instances from an IEnumerable&amp;lt;ParentItem&amp;gt;:&lt;/p&gt;  &lt;p&gt;var selectedChildren = ParentItems.SelectMany(parent=&amp;gt;parent.Children).Where(child=&amp;gt;&amp;lt;boolean expression for filtering children&amp;gt;)&lt;/p&gt; &lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/144573.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/03/29/quicktip--selecting-children-from-a-parent-item-in-linq.aspx</guid>
            <pubDate>Tue, 29 Mar 2011 20:47:27 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/144573.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/03/29/quicktip--selecting-children-from-a-parent-item-in-linq.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/144573.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/144573.aspx</trackback:ping>
        </item>
        <item>
            <title>Words of Wisdom</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/03/19/words-of-wisdom.aspx</link>
            <description>&lt;p&gt;Culture beats Strategy every time.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/144438.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/03/19/words-of-wisdom.aspx</guid>
            <pubDate>Sat, 19 Mar 2011 15:59:25 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/144438.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/03/19/words-of-wisdom.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/144438.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/144438.aspx</trackback:ping>
        </item>
        <item>
            <title>How to set x509 Certificate private key access rights for AppPoolIdentity</title>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/03/15/how-to-set-x509-certificate-private-key-access-rights-for.aspx</link>
            <description>&lt;p&gt;If your website uses the AppPoolIdentity and requires access to the private key of an x509Certficate, you’ll need to grant the read permissions to the iis application pool.&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;To grant permissions to the AppPoolIdentity:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Run Certificates.MMC (or Start-&amp;gt;run-&amp;gt;mmc.exe, Add Certificate Snap-In for LocalMachine)&lt;/li&gt;    &lt;li&gt;Select the certificate (Personal node on the certificate tree) , right click and Manage Permissions.&lt;/li&gt;    &lt;li&gt;Add a new user to the permissions list. &lt;/li&gt;    &lt;li&gt;Enter "IIS AppPool\&lt;strong&gt;AppPoolName&lt;/strong&gt;" on the local machine". Replace "&lt;em&gt;&lt;strong&gt;AppPoolName&lt;/strong&gt;&lt;/em&gt;" with the name of your application pool.&lt;/li&gt; &lt;/ol&gt; &lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/144378.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/03/15/how-to-set-x509-certificate-private-key-access-rights-for.aspx</guid>
            <pubDate>Tue, 15 Mar 2011 17:09:28 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/144378.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/03/15/how-to-set-x509-certificate-private-key-access-rights-for.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/144378.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/144378.aspx</trackback:ping>
        </item>
        <item>
            <title>Fixing LINQ Error: Sequence contains no elements</title>
            <category>Visual Studio</category>
            <link>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/02/15/fixing-linq-error-sequence-contains-no-elements.aspx</link>
            <description>&lt;p&gt;I’ve read some posts regarding this error when using the First() or Single() command.   They suggest using FirstOrDefault() or SingleorDefault() instead.&lt;/p&gt;  &lt;p&gt;But I recently encountered it when using a Sum() command in conjunction with a Where():&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7bac7082-2f36-4e70-858c-1f671356cb7c" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; effectiveFloor = policies.Where(p =&amp;gt; p.PricingStrategy == &lt;span style="color:#2b91af"&gt;PricingStrategy&lt;/span&gt;.EstablishFloor).Max(p =&amp;gt; p.Amount);&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;When the Where() function eliminated all the items in the policies collection, the Sum() command threw the “Sequence contains no elements” exception. &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;Inserting the DefaultIfEmpty() command between the Where() and Sum(), prevents this error:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0989abc7-d021-436a-a7db-9ab98d83ce2e" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; effectiveFloor = policies.Where(p =&amp;gt; p.PricingStrategy == &lt;span style="color:#2b91af"&gt;PricingStrategy&lt;/span&gt;.EstablishFloor).DefaultIfEmpty().Max(p =&amp;gt; p.Amount);&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;but now throws a Null Reference exception!&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Fix:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Using a combination of DefaultIfEmpty() and a null check in the Sum() command solves this problem entirely:&lt;/p&gt;    &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2b02ef6f-1e8d-4064-b162-ae1d52356494" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; effectiveFloor = policies.Where(p =&amp;gt; p.PricingStrategy == &lt;span style="color:#2b91af"&gt;PricingStrategy&lt;/span&gt;.EstablishFloor).DefaultIfEmpty().Max(p =&amp;gt;  p==&lt;span style="color:#0000ff"&gt;null&lt;/span&gt;?0 :p.Amount);&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;img src="http://geekswithblogs.net/SoftwareDoneRight/aggbug/143946.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>ChrisD</dc:creator>
            <guid>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/02/15/fixing-linq-error-sequence-contains-no-elements.aspx</guid>
            <pubDate>Tue, 15 Feb 2011 14:59:05 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/SoftwareDoneRight/comments/143946.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/SoftwareDoneRight/archive/2011/02/15/fixing-linq-error-sequence-contains-no-elements.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/SoftwareDoneRight/comments/commentRss/143946.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/SoftwareDoneRight/services/trackbacks/143946.aspx</trackback:ping>
        </item>
    </channel>
</rss>
