<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0">
  <channel>
    <title>Stan's Blog - .NET</title>
    <link>http://stanbiron.com/</link>
    <description>Developping for the translation industry</description>
    <language>en-us</language>
    <copyright>Stanislas Biron</copyright>
    <lastBuildDate>Wed, 29 Sep 2010 15:41:59 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>stan@stanbiron.com</managingEditor>
    <webMaster>stan@stanbiron.com</webMaster>
    <item>
      <trackback:ping>http://stanbiron.com/Trackback.aspx?guid=7c851b37-e55e-4579-bf07-7fda6f50198f</trackback:ping>
      <pingback:server>http://stanbiron.com/pingback.aspx</pingback:server>
      <pingback:target>http://stanbiron.com/PermaLink,guid,7c851b37-e55e-4579-bf07-7fda6f50198f.aspx</pingback:target>
      <dc:creator>Stanislas Biron</dc:creator>
      <wfw:comment>http://stanbiron.com/CommentView,guid,7c851b37-e55e-4579-bf07-7fda6f50198f.aspx</wfw:comment>
      <wfw:commentRss>http://stanbiron.com/SyndicationService.asmx/GetEntryCommentsRss?guid=7c851b37-e55e-4579-bf07-7fda6f50198f</wfw:commentRss>
      <title>Update now available for the ASP.NET security flaw</title>
      <guid isPermaLink="false">http://stanbiron.com/PermaLink,guid,7c851b37-e55e-4579-bf07-7fda6f50198f.aspx</guid>
      <link>http://stanbiron.com/2010/09/29/UpdateNowAvailableForTheASPNETSecurityFlaw.aspx</link>
      <pubDate>Wed, 29 Sep 2010 15:41:59 GMT</pubDate>
      <description>&lt;p&gt;
This morning Microsoft released a &lt;a href="http://www.microsoft.com/technet/security/bulletin/ms10-070.mspx" target="_blank"&gt;security
update&lt;/a&gt; that addresses the &lt;a href="http://stanbiron.com/2010/09/15/InTheNewsAESEncryptionFlawMakesASPNETSitesVulnerableToAttacks.aspx" target="_blank"&gt;ASP.NET
Security Vulnerability&lt;/a&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;that I&amp;rsquo;ve blogged about
this past week.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
From &lt;a href="http://weblogs.asp.net/scottgu/archive/2010/09/28/asp-net-security-update-now-available.aspx"&gt;Scott
Guthrie&amp;rsquo;s blog post&lt;/a&gt;&amp;nbsp;we learn that the update should not require any
code or configuration change to your existing ASP.NET applications. Also, if&amp;nbsp;you
apply the update to a live web-server, there will be some period of time when the
web-server will be offline (although an OS reboot should not be required). You&amp;rsquo;ll
want to schedule and coordinate your updates appropriately.
&lt;/p&gt;
&lt;p&gt;
If you want to apply the update right now, you can go to the microsoft download center
and download it. The update will also be released in the next scheduled Windows Update
and Windows Server Update.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Other posts&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://stanbiron.com/2009/12/14/SomeTipsToEnhanceYourSQLServerSecurity.aspx"&gt;&lt;strong&gt;19
great tips to enhance your SQL Server security&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://stanbiron.com/2009/11/23/WhatIsLDAPInjection.aspx"&gt;&lt;strong&gt;Intro to
LDAP injection&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://stanbiron.com/2008/12/02/TheTSQLLoginPropertyFunctionInSQLServer2005.aspx"&gt;&lt;strong&gt;The
LoginProperty function in SQL Server 2005&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://stanbiron.com/2010/01/29/GoogleTranslatorHacked.aspx"&gt;&lt;strong&gt;Google
Translator Hacked&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://stanbiron.com/2009/12/22/SQLInjectionHumor.aspx"&gt;&lt;strong&gt;SQL Injection
joke&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://stanbiron.com/aggbug.ashx?id=7c851b37-e55e-4579-bf07-7fda6f50198f" /&gt;</description>
      <comments>http://stanbiron.com/CommentView,guid,7c851b37-e55e-4579-bf07-7fda6f50198f.aspx</comments>
      <category>.NET</category>
      <category>Security</category>
    </item>
    <item>
      <trackback:ping>http://stanbiron.com/Trackback.aspx?guid=dd37869b-4d9f-4efd-80a7-fa5dddb08925</trackback:ping>
      <pingback:server>http://stanbiron.com/pingback.aspx</pingback:server>
      <pingback:target>http://stanbiron.com/PermaLink,guid,dd37869b-4d9f-4efd-80a7-fa5dddb08925.aspx</pingback:target>
      <dc:creator>Stanislas Biron</dc:creator>
      <wfw:comment>http://stanbiron.com/CommentView,guid,dd37869b-4d9f-4efd-80a7-fa5dddb08925.aspx</wfw:comment>
      <wfw:commentRss>http://stanbiron.com/SyndicationService.asmx/GetEntryCommentsRss?guid=dd37869b-4d9f-4efd-80a7-fa5dddb08925</wfw:commentRss>
      <title>.NET String Format Syntax Cheat Sheet</title>
      <guid isPermaLink="false">http://stanbiron.com/PermaLink,guid,dd37869b-4d9f-4efd-80a7-fa5dddb08925.aspx</guid>
      <link>http://stanbiron.com/2010/09/22/NETStringFormatSyntaxCheatSheet.aspx</link>
      <pubDate>Wed, 22 Sep 2010 14:44:16 GMT</pubDate>
      <description>&lt;p&gt;
&lt;img border="0" hspace="8" alt="String-format-cheat-sheet" vspace="8" align="textBottom" src="http://stanbiron.com/content/binary/string_2Dformat_2Dcheat_2Dsheet.png" /&gt;
&lt;/p&gt;
&lt;p&gt;
I don&amp;rsquo;t understand why but it seems that I can never remember the .NET string
format syntax. 
&lt;/p&gt;
&lt;p&gt;
Then&amp;nbsp;I found this. A very nice two-pager cheat-sheet containing all you need
to know about the string format syntax.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://stanbiron.com/content/binary/dot_net_string_format_cheat_sheet.pdf"&gt;Download
it here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Other posts:&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://stanbiron.com/2007/10/10/HowToUseActiveDirectoryToAuthenticateUsers.aspx"&gt;&lt;strong&gt;How
to: Use Active Directory to authenticate users&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://stanbiron.com/2007/12/19/SortingStringsForRealPeopleAHumanfriendlyIComparer.aspx"&gt;&lt;strong&gt;Sorting
strings for real people - A human-friendly IComparer&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://stanbiron.com/2008/05/06/HowToSetNTFSPermissionsUsingC2005.aspx"&gt;&lt;strong&gt;How
to set NTFS permissions using C#&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://stanbiron.com/2008/12/17/HowToRestartAWindowsServiceUsingC.aspx"&gt;&lt;strong&gt;How
to restart a Windows service using C#&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://stanbiron.com/2010/02/03/HowToGetTheListOfObjectModificationsInSQLServer.aspx"&gt;&lt;strong&gt;How
to get the list of object modifications in SQL Server&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://stanbiron.com/aggbug.ashx?id=dd37869b-4d9f-4efd-80a7-fa5dddb08925" /&gt;</description>
      <comments>http://stanbiron.com/CommentView,guid,dd37869b-4d9f-4efd-80a7-fa5dddb08925.aspx</comments>
      <category>.NET</category>
    </item>
    <item>
      <trackback:ping>http://stanbiron.com/Trackback.aspx?guid=83879753-381b-470c-829f-65cdf60f1c35</trackback:ping>
      <pingback:server>http://stanbiron.com/pingback.aspx</pingback:server>
      <pingback:target>http://stanbiron.com/PermaLink,guid,83879753-381b-470c-829f-65cdf60f1c35.aspx</pingback:target>
      <dc:creator>Stanislas Biron</dc:creator>
      <wfw:comment>http://stanbiron.com/CommentView,guid,83879753-381b-470c-829f-65cdf60f1c35.aspx</wfw:comment>
      <wfw:commentRss>http://stanbiron.com/SyndicationService.asmx/GetEntryCommentsRss?guid=83879753-381b-470c-829f-65cdf60f1c35</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Seen on <a href="http://visualstudiomagazine.com/articles/2010/09/14/aspnet-security-hack.aspx">Visual
Studio Magazine</a></p>
        <p>
Two security researchers, Thai Duong and Juliano Rizzo, have discovered a bug in the
default encryption mechanism used to protect the cookies normally used to implement
Forms Authentication in ASP.NET. Using their tool (the <a href="http://netifera.com/research/" target="_blank">Padding
Oracle Exploit Tool</a> or POET), they can repeatedly modify an ASP.NET Forms Authentication
cookie encrypted using AES and, by examining the errors returned, determine the Machine
Key used to encrypt the cookie. The process is claimed to be 100 percent reliable
and takes between 30 and 50 minutes for any site. 
</p>
        <p>
        </p>
        <p>
Once the Machine Key is determined, attackers can create bogus forms authentication
cookies. If site designers have chosen the option to embed role information in the
security cookie, then attackers could arbitrarily assign themselves to administrator
roles. This exposure also affects other membership provider features, spoofing protection
on the ViewState, and encrypted information that might be stored in cookies or otherwise
be made available at the client.
</p>
        <p>
While the exposure is both wide and immediate, the fix is simple. The hack exploits
a bug in .NET's implementation of AES encryption. The solution is to switch to one
of the other encryption mechanisms -- to 3DES, for instance. Since encryption for
the membership and roles providers is handled by ASP.NET, no modification of existing
code should be required for Forms Authentication.
</p>
        <p>
The encryption method can be set in the web.config file for a site, in IIS 7 for a
Web server, or in the config file for .NET on a server in %SYSTEMROOT%\Microsoft.NET\Framework\version\CONFIG\.
On 64-bit systems, it must also be set in %SYSTEMROOT%\Microsoft.NET\Framework64\version\CONFIG\.
A typical entry would look like this:
</p>
        <pre class="codesnippet">    &lt;machineKey validationKey="AutoGenerate,IsolateApps"         
                           validation="3DES"                           
                           decryptionKey="AutoGenerate,IsolateApps"
                           decryption="3DES" /&gt;  
</pre>
        <p>
On a Web farm, this setting will have to be made on all the servers in the farm.
</p>
        <p>
These settings are also used to prevent spoofing (ViewState data is encoded but not
encrypted), so making this change will also switch the ViewState to using 3DES. Developers
who are using AES in their code to encrypt information made available at the client
should consider modifying their code to use a different encryption mechanism.
</p>
        <p>
 
</p>
        <p>
          <strong>Other Posts:</strong>
        </p>
        <p>
          <a href="news: Google instant makes searching for God harder">
            <strong>Google instant
makes searching for God harder</strong>
          </a>
        </p>
        <p>
          <a href="http://stanbiron.com/2010/07/06/TabnabbingANewKindOfPhishingAttack.aspx">
            <strong>Tabnabbing:
A New Kind Of Phishing Attack</strong>
          </a>
        </p>
        <p>
          <a href="http://stanbiron.com/2010/03/10/BigNewsInSecurity1024bitRSAEncryptionCracked.aspx">
            <strong>Big
news in security: 1024-bit RSA encryption cracked!</strong>
          </a>
        </p>
        <p>
          <a href="http://stanbiron.com/2009/12/14/SomeTipsToEnhanceYourSQLServerSecurity.aspx">
            <strong>Tips
to enhance your SQL Server security</strong>
          </a>
        </p>
        <p>
          <a href="http://stanbiron.com/2009/11/23/WhatIsLDAPInjection.aspx">
            <strong>What is
LDAP injection?</strong>
          </a>
        </p>
        <img width="0" height="0" src="http://stanbiron.com/aggbug.ashx?id=83879753-381b-470c-829f-65cdf60f1c35" />
      </body>
      <title>In The News: AES Encryption Flaw Makes ASP.NET Sites Vulnerable To Attacks</title>
      <guid isPermaLink="false">http://stanbiron.com/PermaLink,guid,83879753-381b-470c-829f-65cdf60f1c35.aspx</guid>
      <link>http://stanbiron.com/2010/09/15/InTheNewsAESEncryptionFlawMakesASPNETSitesVulnerableToAttacks.aspx</link>
      <pubDate>Wed, 15 Sep 2010 13:35:36 GMT</pubDate>
      <description>&lt;p&gt;
Seen on &lt;a href="http://visualstudiomagazine.com/articles/2010/09/14/aspnet-security-hack.aspx"&gt;Visual
Studio Magazine&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Two security researchers, Thai Duong and Juliano Rizzo, have discovered a bug in the
default encryption mechanism used to protect the cookies normally used to implement
Forms Authentication in ASP.NET. Using their tool (the &lt;a href="http://netifera.com/research/" target="_blank"&gt;Padding
Oracle Exploit Tool&lt;/a&gt; or POET), they can repeatedly modify an ASP.NET Forms Authentication
cookie encrypted using AES and, by examining the errors returned, determine the Machine
Key used to encrypt the cookie. The process is claimed to be 100 percent reliable
and takes between 30 and 50 minutes for any site. 
&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;
Once the Machine Key is determined, attackers can create bogus forms authentication
cookies. If site designers have chosen the option to embed role information in the
security cookie, then attackers could arbitrarily assign themselves to administrator
roles. This exposure also affects other membership provider features, spoofing protection
on the ViewState, and encrypted information that might be stored in cookies or otherwise
be made available at the client.
&lt;/p&gt;
&lt;p&gt;
While the exposure is both wide and immediate, the fix is simple. The hack exploits
a bug in .NET's implementation of AES encryption. The solution is to switch to one
of the other encryption mechanisms -- to 3DES, for instance. Since encryption for
the membership and roles providers is handled by ASP.NET, no modification of existing
code should be required for Forms Authentication.
&lt;/p&gt;
&lt;p&gt;
The encryption method can be set in the web.config file for a site, in IIS 7 for a
Web server, or in the config file for .NET on a server in %SYSTEMROOT%\Microsoft.NET\Framework\version\CONFIG\.
On 64-bit systems, it must also be set in %SYSTEMROOT%\Microsoft.NET\Framework64\version\CONFIG\.
A typical entry would look like this:
&lt;/p&gt;
&lt;pre class="codesnippet"&gt;    &amp;lt;machineKey validationKey="AutoGenerate,IsolateApps"         
                           validation="3DES"                           
                           decryptionKey="AutoGenerate,IsolateApps"
                           decryption="3DES" /&amp;gt;  
&lt;/pre&gt;
&lt;p&gt;
On a Web farm, this setting will have to be made on all the servers in the farm.
&lt;/p&gt;
&lt;p&gt;
These settings are also used to prevent spoofing (ViewState data is encoded but not
encrypted), so making this change will also switch the ViewState to using 3DES. Developers
who are using AES in their code to encrypt information made available at the client
should consider modifying their code to use a different encryption mechanism.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Other Posts:&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="news: Google instant makes searching for God harder"&gt;&lt;strong&gt;Google instant
makes searching for God harder&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://stanbiron.com/2010/07/06/TabnabbingANewKindOfPhishingAttack.aspx"&gt;&lt;strong&gt;Tabnabbing:
A New Kind Of Phishing Attack&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://stanbiron.com/2010/03/10/BigNewsInSecurity1024bitRSAEncryptionCracked.aspx"&gt;&lt;strong&gt;Big
news in security: 1024-bit RSA encryption cracked!&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://stanbiron.com/2009/12/14/SomeTipsToEnhanceYourSQLServerSecurity.aspx"&gt;&lt;strong&gt;Tips
to enhance your SQL Server security&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://stanbiron.com/2009/11/23/WhatIsLDAPInjection.aspx"&gt;&lt;strong&gt;What is
LDAP injection?&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://stanbiron.com/aggbug.ashx?id=83879753-381b-470c-829f-65cdf60f1c35" /&gt;</description>
      <comments>http://stanbiron.com/CommentView,guid,83879753-381b-470c-829f-65cdf60f1c35.aspx</comments>
      <category>.NET</category>
      <category>News</category>
      <category>Security</category>
    </item>
    <item>
      <trackback:ping>http://stanbiron.com/Trackback.aspx?guid=3e2cec8d-a0cb-461b-b23d-a7158352ef1e</trackback:ping>
      <pingback:server>http://stanbiron.com/pingback.aspx</pingback:server>
      <pingback:target>http://stanbiron.com/PermaLink,guid,3e2cec8d-a0cb-461b-b23d-a7158352ef1e.aspx</pingback:target>
      <dc:creator>Stanislas Biron</dc:creator>
      <wfw:comment>http://stanbiron.com/CommentView,guid,3e2cec8d-a0cb-461b-b23d-a7158352ef1e.aspx</wfw:comment>
      <wfw:commentRss>http://stanbiron.com/SyndicationService.asmx/GetEntryCommentsRss?guid=3e2cec8d-a0cb-461b-b23d-a7158352ef1e</wfw:commentRss>
      <title>How to put log4net configs outside of the application configuration file</title>
      <guid isPermaLink="false">http://stanbiron.com/PermaLink,guid,3e2cec8d-a0cb-461b-b23d-a7158352ef1e.aspx</guid>
      <link>http://stanbiron.com/2009/11/23/HowToPutLog4netConfigsOutsideOfTheApplicationConfigurationFile.aspx</link>
      <pubDate>Mon, 23 Nov 2009 15:21:14 GMT</pubDate>
      <description>&lt;p&gt;
I use &lt;a href="http://logging.apache.org/log4net/" target="_blank"&gt;log4net&lt;/a&gt; in&amp;nbsp;every&amp;nbsp;applications
I build that needs to have some sort of log.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Most of the examples on the log4net site puts the configuration right in the App.config/Web.config
file for the example application. Since they are simply example and not real-life
scenarios, that&amp;rsquo;s not necessarily the best way to do it.&amp;nbsp;For example, you
may have&amp;nbsp;a single log4net.config that you want&amp;nbsp;to use in several projects
or&amp;nbsp;you simply want to stick log4net.config somewhere else to make those config
files more readable.
&lt;/p&gt;
&lt;p&gt;
The magic bit that at least I can't easily find and always forget is:
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;If you add an appSettings key called "log4net.Config" you can put an app-relative
path to an external log4net.config file in there and everything will automatically
configure itself using that.&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
It looks like this:
&lt;/p&gt;
&lt;pre&gt;&amp;lt;?xml version="1.0"?&amp;gt;
&amp;lt;configuration&amp;gt;
  &amp;lt;appSettings&amp;gt;
    &amp;lt;add key="log4net.Config" value="log4net.config" /&amp;gt;
  &amp;lt;/appSettings&amp;gt;
&amp;lt;/configuration&amp;gt;&lt;/pre&gt;
&lt;p&gt;
That example puts the log4net.config file right in the root of the application. You
could specify "config/log4net.config" to put it in a "config" subfolder. You don't
even have to call the &lt;code&gt;XmlConfigurator.Configure&lt;/code&gt; method or mark your assembly
with an &lt;code&gt;XmlConfiguratorAttribute&lt;/code&gt; or anything. Some voodoo magic happens&amp;nbsp;in
the background and it just works.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Other posts :&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;a href="http://stanbiron.com/2009/06/10/HowToEnumerateTheDomainControllersInTheCurrentDomainInC.aspx"&gt;How
to enumerate the Domain Controllers in the current Domain in C#&lt;/a&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;a href="http://stanbiron.com/2009/03/20/HowToCreateUserAccountsInActiveDirectoryUsingC.aspx"&gt;How
to Create User Accounts in Active Directory using C#&lt;/a&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;a href="http://stanbiron.com/2008/12/17/HowToRestartAWindowsServiceUsingC.aspx"&gt;How
to restart a Windows service using C#&lt;/a&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://stanbiron.com/2008/05/06/HowToSetNTFSPermissionsUsingC2005.aspx"&gt;&lt;strong&gt;How
to set NTFS permissions using C# 2005&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://stanbiron.com/aggbug.ashx?id=3e2cec8d-a0cb-461b-b23d-a7158352ef1e" /&gt;</description>
      <comments>http://stanbiron.com/CommentView,guid,3e2cec8d-a0cb-461b-b23d-a7158352ef1e.aspx</comments>
      <category>.NET</category>
      <category>General</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://stanbiron.com/Trackback.aspx?guid=9d2aa6f1-c228-4c0b-8ccd-c5c0efdd82cc</trackback:ping>
      <pingback:server>http://stanbiron.com/pingback.aspx</pingback:server>
      <pingback:target>http://stanbiron.com/PermaLink,guid,9d2aa6f1-c228-4c0b-8ccd-c5c0efdd82cc.aspx</pingback:target>
      <dc:creator>Stanislas Biron</dc:creator>
      <wfw:comment>http://stanbiron.com/CommentView,guid,9d2aa6f1-c228-4c0b-8ccd-c5c0efdd82cc.aspx</wfw:comment>
      <wfw:commentRss>http://stanbiron.com/SyndicationService.asmx/GetEntryCommentsRss?guid=9d2aa6f1-c228-4c0b-8ccd-c5c0efdd82cc</wfw:commentRss>
      <title>Memory Leak in System.DirectoryServices.DirectorySearcher</title>
      <guid isPermaLink="false">http://stanbiron.com/PermaLink,guid,9d2aa6f1-c228-4c0b-8ccd-c5c0efdd82cc.aspx</guid>
      <link>http://stanbiron.com/2008/05/21/MemoryLeakInSystemDirectoryServicesDirectorySearcher.aspx</link>
      <pubDate>Wed, 21 May 2008 19:54:00 GMT</pubDate>
      <description>&lt;p&gt;
At my company, we have a windows service, built in C#, that makes automatic modifications
to Active Directory groups.&amp;nbsp;This process use the function call &amp;ldquo;FindAll()&amp;rdquo;
from the System.DirectoryServices.DirectorySearcher class.
&lt;/p&gt;
&lt;p&gt;
It seems that the SearchResultCollection returned by the FindAll method can&amp;rsquo;t
release it&amp;rsquo;s unmanaged resources by itself, so you need to call explicitly the
Dispose() method.
&lt;/p&gt;
&lt;p&gt;
From &lt;a href="http://msdn.microsoft.com/en-us/library/system.directoryservices.directorysearcher.findall.aspx" target="_blank"&gt;MSDN&lt;/a&gt;:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
Due to implementation restrictions, the &lt;a id="ctl00_rs1_mainContentContainer_ctl38" onclick="javascript:Track('ctl00_rs1_mainContentContainer_cpe1074783_c|ctl00_rs1_mainContentContainer_ctl38',this);" href="http://msdn.microsoft.com/en-us/library/system.directoryservices.searchresultcollection.aspx"&gt;SearchResultCollection&lt;/a&gt; class
cannot release all of its unmanaged resources when it is garbage collected. To prevent
a memory leak, you must call the &lt;a id="ctl00_rs1_mainContentContainer_ctl39" onclick="javascript:Track('ctl00_rs1_mainContentContainer_cpe1074783_c|ctl00_rs1_mainContentContainer_ctl39',this);" href="http://msdn.microsoft.com/en-us/library/system.directoryservices.searchresultcollection.dispose.aspx"&gt;Dispose&lt;/a&gt; method
when the &lt;a id="ctl00_rs1_mainContentContainer_ctl40" onclick="javascript:Track('ctl00_rs1_mainContentContainer_cpe1074783_c|ctl00_rs1_mainContentContainer_ctl40',this);" href="http://msdn.microsoft.com/en-us/library/system.directoryservices.searchresultcollection.aspx"&gt;SearchResultCollection&lt;/a&gt; object
is no longer needed.
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p dir="ltr"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://stanbiron.com/aggbug.ashx?id=9d2aa6f1-c228-4c0b-8ccd-c5c0efdd82cc" /&gt;</description>
      <comments>http://stanbiron.com/CommentView,guid,9d2aa6f1-c228-4c0b-8ccd-c5c0efdd82cc.aspx</comments>
      <category>.NET</category>
    </item>
    <item>
      <trackback:ping>http://stanbiron.com/Trackback.aspx?guid=c7d5f1a7-9300-4d3f-a6fa-b44fceb3d28c</trackback:ping>
      <pingback:server>http://stanbiron.com/pingback.aspx</pingback:server>
      <pingback:target>http://stanbiron.com/PermaLink,guid,c7d5f1a7-9300-4d3f-a6fa-b44fceb3d28c.aspx</pingback:target>
      <dc:creator>Stanislas Biron</dc:creator>
      <wfw:comment>http://stanbiron.com/CommentView,guid,c7d5f1a7-9300-4d3f-a6fa-b44fceb3d28c.aspx</wfw:comment>
      <wfw:commentRss>http://stanbiron.com/SyndicationService.asmx/GetEntryCommentsRss?guid=c7d5f1a7-9300-4d3f-a6fa-b44fceb3d28c</wfw:commentRss>
      <title>How to set NTFS permissions using C# 2005</title>
      <guid isPermaLink="false">http://stanbiron.com/PermaLink,guid,c7d5f1a7-9300-4d3f-a6fa-b44fceb3d28c.aspx</guid>
      <link>http://stanbiron.com/2008/05/06/HowToSetNTFSPermissionsUsingC2005.aspx</link>
      <pubDate>Tue, 06 May 2008 22:52:15 GMT</pubDate>
      <description>&lt;p&gt;
This code example sets the permission to create files and update them in a folder&amp;nbsp;for
a particular user but doesn&amp;rsquo;t propagate these permissions to the subfolders.
&lt;/p&gt;
&lt;div style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Consolas"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;using &lt;/span&gt;System.Security.AccessControl;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
System.IO.&lt;span style="COLOR: #2b91af"&gt;DirectoryInfo&lt;/span&gt; folderInfo = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; System.IO.&lt;span style="COLOR: #2b91af"&gt;DirectoryInfo&lt;/span&gt;(folder);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;DirectorySecurity&lt;/span&gt; folderSecurity = folderInfo.GetAccessControl();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;FileSystemAccessRule&lt;/span&gt; rule = 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;FileSystemAccessRule&lt;/span&gt;(
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR: #a31515"&gt;"Domain\\username"&lt;/span&gt;, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;FileSystemRights&lt;/span&gt;.ReadAndExecute
| 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;FileSystemRights&lt;/span&gt;.AppendData
| 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;FileSystemRights&lt;/span&gt;.CreateFiles
| 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;FileSystemRights&lt;/span&gt;.Write, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;InheritanceFlags&lt;/span&gt;.ObjectInherit, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;PropagationFlags&lt;/span&gt;.None, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;AccessControlType&lt;/span&gt;.Allow);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
folderSecurity.AddAccessRule(rule);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
folderInfo.SetAccessControl(folderSecurity);
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;img width="0" height="0" src="http://stanbiron.com/aggbug.ashx?id=c7d5f1a7-9300-4d3f-a6fa-b44fceb3d28c" /&gt;</description>
      <comments>http://stanbiron.com/CommentView,guid,c7d5f1a7-9300-4d3f-a6fa-b44fceb3d28c.aspx</comments>
      <category>.NET</category>
      <category>C#</category>
      <category>Code Snippet</category>
    </item>
    <item>
      <trackback:ping>http://stanbiron.com/Trackback.aspx?guid=94cff33d-8c4d-4117-8b3e-89104beffbb3</trackback:ping>
      <pingback:server>http://stanbiron.com/pingback.aspx</pingback:server>
      <pingback:target>http://stanbiron.com/PermaLink,guid,94cff33d-8c4d-4117-8b3e-89104beffbb3.aspx</pingback:target>
      <dc:creator>Stanislas Biron</dc:creator>
      <wfw:comment>http://stanbiron.com/CommentView,guid,94cff33d-8c4d-4117-8b3e-89104beffbb3.aspx</wfw:comment>
      <wfw:commentRss>http://stanbiron.com/SyndicationService.asmx/GetEntryCommentsRss?guid=94cff33d-8c4d-4117-8b3e-89104beffbb3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.codinghorror.com/blog/" target="_blank">Jeff Atwood</a> recently
posted on the topic of <a href="http://www.codinghorror.com/blog/archives/001018.html" target="_blank">sorting</a> strings
in a more natural order that the default string sorting gives us.  His main point
is, when we’re dealing with numbers, a simple alphabetic sorting doesn’t cut it.
</p>
        <p>
So. just for fun, here’s my little C# 2.0 Implementation of a more human-friendly
sorter.
</p>
        <p>
 
</p>
        <blockquote>
          <div style="background: white none repeat scroll 0%; font-weight: bold; font-size: 12pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: Consolas;">
            <p style="margin: 0px;">
              <font face="Courier New" size="2">
                <span style="color: blue;">public</span>
                <span style="color: blue;">class</span>
                <span style="color: rgb(43, 145, 175);">FriendlySorter</span>&lt;T&gt;
: <span style="color: rgb(43, 145, 175);">IComparer</span>&lt;T&gt;</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">{</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">    <span style="color: blue;">public</span><span style="color: blue;">int</span></font>
              <font color="#0000ff" face="Courier New" size="2">
              </font>
              <font face="Courier New" size="2">Compare(T
x, T y)</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">    {</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">        <span style="color: blue;">if</span> (x
== <span style="color: blue;">null</span> || y == <span style="color: blue;">null</span>) <span style="color: blue;">return</span> 0;</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">        <span style="color: blue;">if</span> (x.ToString()
== y.ToString()) <span style="color: blue;">return</span> 0;</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2"> </font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">        <span style="color: blue;">string</span>[]
left = <span style="color: rgb(43, 145, 175);">Regex</span>.Split(x.ToString(), <span style="color: rgb(163, 21, 21);">"([0-9]+)"</span>);</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">        <span style="color: blue;">string</span>[]
right = <span style="color: rgb(43, 145, 175);">Regex</span>.Split(y.ToString(), <span style="color: rgb(163, 21, 21);">"([0-9]+)"</span>);</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2"> </font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">        <span style="color: blue;">int</span></font>
              <font color="#0000ff" face="Courier New" size="2">
              </font>
              <font face="Courier New" size="2">index
= 0;</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2"> </font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">        <span style="color: blue;">while</span> (<span style="color: blue;">true</span>)</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">        {</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">            <span style="color: blue;">while</span> (left[index]
== right[index]) index++;</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2"> </font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">            <span style="color: blue;">if</span> (left.Length
== index &amp;&amp; right.Length == index) <span style="color: blue;">return</span> 0;</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">            <span style="color: blue;">if</span> (left.Length
&lt;= index) <span style="color: blue;">return</span> -1;</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">            <span style="color: blue;">if</span> (right.Length
&lt;= index) <span style="color: blue;">return</span> 1;</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2"> </font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">            <span style="color: blue;">try</span></font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">           
{</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">                <span style="color: blue;">return</span> (<span style="color: blue;">int</span>.Parse(left[index])
- <span style="color: blue;">int</span>.Parse(right[index]));</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">           
}</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">            <span style="color: blue;">catch</span></font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">           
{</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">                <span style="color: blue;">int</span> CompareResult
= <span style="color: rgb(43, 145, 175);">String</span>.Compare(left[index], right[index]);</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">                <span style="color: blue;">if</span> (CompareResult
!= 0) <span style="color: blue;">return</span> CompareResult;</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">           
}</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2"> </font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">           
index++;</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">        }</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">    }</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">}</font>
            </p>
          </div>
        </blockquote>
        <!--EndFragment-->
        <p>
 
</p>
        <p>
The following code :
</p>
        <blockquote>
          <div style="background: white none repeat scroll 0%; font-weight: bold; font-size: 12pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: Consolas;">
            <p style="margin: 0px;">
              <font face="Courier New" size="2">
                <span style="color: rgb(43, 145, 175);">List</span>&lt;<span style="color: blue;">string</span>&gt;
list = <span style="color: blue;">new</span><span style="color: rgb(43, 145, 175);">List</span>&lt;<span style="color: blue;">string</span>&gt;();</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2"> </font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">list.Add(<span style="color: rgb(163, 21, 21);">"Track
1 : abc"</span>);</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">list.Add(<span style="color: rgb(163, 21, 21);">"Track
2 : abc"</span>);</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">list.Add(<span style="color: rgb(163, 21, 21);">"Track
10 : abc"</span>);</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">list.Add(<span style="color: rgb(163, 21, 21);">"Track
5 : abc"</span>);</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">list.Add(<span style="color: rgb(163, 21, 21);">"Track
11 : abc"</span>);</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">list.Add(<span style="color: rgb(163, 21, 21);">"Track
22 : abc"</span>);</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">list.Add(<span style="color: rgb(163, 21, 21);">"Track
9 : abc"</span>);</font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2"> </font>
            </p>
            <p style="margin: 0px;">
              <font face="Courier New" size="2">list.Sort(<span style="color: blue;">new</span><span style="color: rgb(43, 145, 175);">FriendlySorter</span>&lt;<span style="color: blue;">string</span>&gt;());</font>
            </p>
          </div>
        </blockquote>
        <!--EndFragment-->
        <p>
 
</p>
        <p>
Will produce the results :
</p>
        <p>
          <img alt="Sshot-4" src="http://stanbiron.com/content/binary/sshot_2D4.png" border="0" />
        </p>
        <p>
For small sets the performance is Ok.  But when dealing with a larger amount
of data (1000+ items), the sorting performance drops a lot (I currently have 5 seconds
to sort 1000 random elements).  I will probably try to enhance it in the future
and update this post.
</p>
        <p>
Happy holidays !
</p>
        <div class="bjtags">Tags: <a rel="tag" href="http://technorati.com/tag/C#">C#</a></div>
        <img width="0" height="0" src="http://stanbiron.com/aggbug.ashx?id=94cff33d-8c4d-4117-8b3e-89104beffbb3" />
      </body>
      <title>Sorting strings for real people - A human-friendly IComparer</title>
      <guid isPermaLink="false">http://stanbiron.com/PermaLink,guid,94cff33d-8c4d-4117-8b3e-89104beffbb3.aspx</guid>
      <link>http://stanbiron.com/2007/12/19/SortingStringsForRealPeopleAHumanfriendlyIComparer.aspx</link>
      <pubDate>Wed, 19 Dec 2007 23:42:12 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://www.codinghorror.com/blog/" target="_blank"&gt;Jeff Atwood&lt;/a&gt; recently
posted on the topic of &lt;a href="http://www.codinghorror.com/blog/archives/001018.html" target="_blank"&gt;sorting&lt;/a&gt; strings
in a more natural order that the default string sorting gives us.&amp;nbsp; His main point
is, when we’re dealing with numbers, a simple alphabetic sorting doesn’t cut it.
&lt;/p&gt;
&lt;p&gt;
So. just for fun, here’s my little C# 2.0 Implementation of a more human-friendly
sorter.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;div style="background: white none repeat scroll 0%; font-weight: bold; font-size: 12pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: Consolas;"&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;FriendlySorter&lt;/span&gt;&amp;lt;T&amp;gt;
: &lt;span style="color: rgb(43, 145, 175);"&gt;IComparer&lt;/span&gt;&amp;lt;T&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;{&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt;&lt;/font&gt;&lt;font color="#0000ff" face="Courier New" size="2"&gt; &lt;/font&gt;&lt;font face="Courier New" size="2"&gt;Compare(T
x, T y)&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (x
== &lt;span style="color: blue;"&gt;null&lt;/span&gt; || y == &lt;span style="color: blue;"&gt;null&lt;/span&gt;) &lt;span style="color: blue;"&gt;return&lt;/span&gt; 0;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (x.ToString()
== y.ToString()) &lt;span style="color: blue;"&gt;return&lt;/span&gt; 0;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;string&lt;/span&gt;[]
left = &lt;span style="color: rgb(43, 145, 175);"&gt;Regex&lt;/span&gt;.Split(x.ToString(), &lt;span style="color: rgb(163, 21, 21);"&gt;"([0-9]+)"&lt;/span&gt;);&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;string&lt;/span&gt;[]
right = &lt;span style="color: rgb(43, 145, 175);"&gt;Regex&lt;/span&gt;.Split(y.ToString(), &lt;span style="color: rgb(163, 21, 21);"&gt;"([0-9]+)"&lt;/span&gt;);&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;int&lt;/span&gt;&lt;/font&gt;&lt;font color="#0000ff" face="Courier New" size="2"&gt; &lt;/font&gt;&lt;font face="Courier New" size="2"&gt;index
= 0;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;while&lt;/span&gt; (&lt;span style="color: blue;"&gt;true&lt;/span&gt;)&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;while&lt;/span&gt; (left[index]
== right[index]) index++;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (left.Length
== index &amp;amp;&amp;amp; right.Length == index) &lt;span style="color: blue;"&gt;return&lt;/span&gt; 0;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (left.Length
&amp;lt;= index) &lt;span style="color: blue;"&gt;return&lt;/span&gt; -1;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (right.Length
&amp;lt;= index) &lt;span style="color: blue;"&gt;return&lt;/span&gt; 1;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;try&lt;/span&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; (&lt;span style="color: blue;"&gt;int&lt;/span&gt;.Parse(left[index])
- &lt;span style="color: blue;"&gt;int&lt;/span&gt;.Parse(right[index]));&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;catch&lt;/span&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;int&lt;/span&gt; CompareResult
= &lt;span style="color: rgb(43, 145, 175);"&gt;String&lt;/span&gt;.Compare(left[index], right[index]);&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (CompareResult
!= 0) &lt;span style="color: blue;"&gt;return&lt;/span&gt; CompareResult;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
index++;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;}&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;!--EndFragment--&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
The following code :
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;div style="background: white none repeat scroll 0%; font-weight: bold; font-size: 12pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: Consolas;"&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&amp;gt;
list = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&amp;gt;();&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;list.Add(&lt;span style="color: rgb(163, 21, 21);"&gt;"Track
1 : abc"&lt;/span&gt;);&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;list.Add(&lt;span style="color: rgb(163, 21, 21);"&gt;"Track
2 : abc"&lt;/span&gt;);&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;list.Add(&lt;span style="color: rgb(163, 21, 21);"&gt;"Track
10 : abc"&lt;/span&gt;);&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;list.Add(&lt;span style="color: rgb(163, 21, 21);"&gt;"Track
5 : abc"&lt;/span&gt;);&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;list.Add(&lt;span style="color: rgb(163, 21, 21);"&gt;"Track
11 : abc"&lt;/span&gt;);&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;list.Add(&lt;span style="color: rgb(163, 21, 21);"&gt;"Track
22 : abc"&lt;/span&gt;);&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;list.Add(&lt;span style="color: rgb(163, 21, 21);"&gt;"Track
9 : abc"&lt;/span&gt;);&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;font face="Courier New" size="2"&gt;list.Sort(&lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;FriendlySorter&lt;/span&gt;&amp;lt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&amp;gt;());&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;!--EndFragment--&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Will produce the results :
&lt;/p&gt;
&lt;p&gt;
&lt;img alt="Sshot-4" src="http://stanbiron.com/content/binary/sshot_2D4.png" border="0"&gt;
&lt;/p&gt;
&lt;p&gt;
For small sets the performance is Ok.&amp;nbsp; But when dealing with a larger amount
of data (1000+ items), the sorting performance drops a lot (I currently have 5 seconds
to sort 1000 random elements).&amp;nbsp; I will probably try to enhance it in the future
and update this post.
&lt;/p&gt;
&lt;p&gt;
Happy holidays !
&lt;/p&gt;
&lt;div class="bjtags"&gt;Tags: &lt;a rel="tag" href="http://technorati.com/tag/C#"&gt;C#&lt;/a&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://stanbiron.com/aggbug.ashx?id=94cff33d-8c4d-4117-8b3e-89104beffbb3" /&gt;</description>
      <comments>http://stanbiron.com/CommentView,guid,94cff33d-8c4d-4117-8b3e-89104beffbb3.aspx</comments>
      <category>.NET</category>
      <category>C#</category>
      <category>Code Snippet</category>
    </item>
    <item>
      <trackback:ping>http://stanbiron.com/Trackback.aspx?guid=3e9502a4-678b-40b1-8801-71344e27e235</trackback:ping>
      <pingback:server>http://stanbiron.com/pingback.aspx</pingback:server>
      <pingback:target>http://stanbiron.com/PermaLink,guid,3e9502a4-678b-40b1-8801-71344e27e235.aspx</pingback:target>
      <dc:creator>Stanislas Biron</dc:creator>
      <wfw:comment>http://stanbiron.com/CommentView,guid,3e9502a4-678b-40b1-8801-71344e27e235.aspx</wfw:comment>
      <wfw:commentRss>http://stanbiron.com/SyndicationService.asmx/GetEntryCommentsRss?guid=3e9502a4-678b-40b1-8801-71344e27e235</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
It’s simply amazing! <a href="http://weblogs.asp.net/scottgu/" target="_blank">Scott
Guthrie</a> announced today that the .NET framework source code is going to be
released later this year.  He says it will be released at the same time that
Visual Studio 2008 and the 3.5 Framework are going to be released.  This means
that you will be able to drill down <em><strong>inside</strong></em> the framework
when debugging your applications in Visual Studio 2008.
</p>
        <p>
This is a bold move from Microsoft’s part by any standards.  I think the motivation
behind this release is two-fold:
</p>
        <p>
1. This seems to be part of a larger company-wide politic to show to developers
that Microsoft <em>genuinely</em> care about them.
</p>
        <p>
2. They also need to work with the flow.  More and more, tools like Lutz Roeder’s <a href="http://www.aisto.com/roeder/dotnet/" target="_blank">.NET
Reflector</a> (a utility and Visual Studio plugin to decompile and visualize .NET
assemblies) are becoming popular and the Framework is, for all intent and purposes,
already opened and ripped apart.  I look at classes of the framework myself using
this tool from time to time.
</p>
        <p>
All that being said, this is really great news and I can’t wait to play with this
and see the internals of the framework “in action”.
</p>
        <p>
          <a href="http://weblogs.asp.net/scottgu/archive/2007/10/03/releasing-the-source-code-for-the-net-framework-libraries.aspx" target="_blank">Click
here to view the full article from Scott.</a>
        </p>
        <p>
If you don’t know who Scott Guthrie is..  Well he’s the team leader for :
</p>
        <ul>
          <li>
IIS</li>
          <li>
ASP.NET</li>
          <li>
The AJAX Toolkit</li>
          <li>
The CLR</li>
          <li>
The Compact Framework</li>
          <li>
Windows Forms</li>
          <li>
Commerce Server</li>
          <li>
Visual Web Developer 2005</li>
          <li>
Visual Studio Tools for WPF</li>
        </ul>
        <p>
In others words, if you love your job as a programmer using Microsoft’s technologies,
it’s because of this guy.
</p>
        <div class="bjtags">Tags: <a rel="tag" href="http://technorati.com/tag/.NET">.NET</a>, <a rel="tag" href="http://technorati.com/tag/News">News</a></div>
        <img width="0" height="0" src="http://stanbiron.com/aggbug.ashx?id=3e9502a4-678b-40b1-8801-71344e27e235" />
      </body>
      <title>In the news today: The .NET Framework 3.5 source code is going to be released!</title>
      <guid isPermaLink="false">http://stanbiron.com/PermaLink,guid,3e9502a4-678b-40b1-8801-71344e27e235.aspx</guid>
      <link>http://stanbiron.com/2007/10/03/InTheNewsTodayTheNETFramework35SourceCodeIsGoingToBeReleased.aspx</link>
      <pubDate>Wed, 03 Oct 2007 19:37:44 GMT</pubDate>
      <description>&lt;p&gt;
It’s simply amazing! &lt;a href="http://weblogs.asp.net/scottgu/" target="_blank"&gt;Scott
Guthrie&lt;/a&gt; announced today that the .NET framework source code&amp;nbsp;is going to&amp;nbsp;be
released later this year.&amp;nbsp; He says it will be released at the same time that
Visual Studio 2008 and the 3.5 Framework are going to be released.&amp;nbsp; This means
that you will be able to drill down &lt;em&gt;&lt;strong&gt;inside&lt;/strong&gt;&lt;/em&gt; the framework
when debugging your applications in Visual Studio 2008.
&lt;/p&gt;
&lt;p&gt;
This is a bold move from Microsoft’s part by any standards.&amp;nbsp; I think the motivation
behind this release is two-fold:
&lt;/p&gt;
&lt;p&gt;
1. This seems to be part of a larger company-wide politic to show to&amp;nbsp;developers
that Microsoft &lt;em&gt;genuinely&lt;/em&gt; care about them.
&lt;/p&gt;
&lt;p&gt;
2. They also need to work with the flow.&amp;nbsp; More and more, tools like Lutz Roeder’s &lt;a href="http://www.aisto.com/roeder/dotnet/" target="_blank"&gt;.NET
Reflector&lt;/a&gt; (a utility and Visual Studio plugin to decompile and visualize .NET
assemblies) are becoming popular and the Framework is, for all intent and purposes,
already opened and ripped apart.&amp;nbsp; I look at classes of the framework myself using
this tool from time to time.
&lt;/p&gt;
&lt;p&gt;
All that being said, this is really great news and I can’t wait to play with this
and see the internals of the framework “in action”.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://weblogs.asp.net/scottgu/archive/2007/10/03/releasing-the-source-code-for-the-net-framework-libraries.aspx" target="_blank"&gt;Click
here to view the full article from Scott.&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
If you don’t know who Scott Guthrie is..&amp;nbsp; Well he’s the team leader for :
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
IIS&lt;/li&gt;
&lt;li&gt;
ASP.NET&lt;/li&gt;
&lt;li&gt;
The AJAX Toolkit&lt;/li&gt;
&lt;li&gt;
The CLR&lt;/li&gt;
&lt;li&gt;
The Compact Framework&lt;/li&gt;
&lt;li&gt;
Windows Forms&lt;/li&gt;
&lt;li&gt;
Commerce Server&lt;/li&gt;
&lt;li&gt;
Visual Web Developer 2005&lt;/li&gt;
&lt;li&gt;
Visual Studio Tools for WPF&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
In others words, if you love your job as a programmer using Microsoft’s technologies,
it’s because of this guy.
&lt;/p&gt;
&lt;div class="bjtags"&gt;Tags: &lt;a rel="tag" href="http://technorati.com/tag/.NET"&gt;.NET&lt;/a&gt;, &lt;a rel="tag" href="http://technorati.com/tag/News"&gt;News&lt;/a&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://stanbiron.com/aggbug.ashx?id=3e9502a4-678b-40b1-8801-71344e27e235" /&gt;</description>
      <comments>http://stanbiron.com/CommentView,guid,3e9502a4-678b-40b1-8801-71344e27e235.aspx</comments>
      <category>General</category>
      <category>.NET</category>
      <category>News</category>
    </item>
  </channel>
</rss>