<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://devlicio.us/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Scott Seely</title><subtitle type="html" /><id>http://devlicio.us/blogs/scott_seely/atom.aspx</id><link rel="alternate" type="text/html" href="http://devlicio.us/blogs/scott_seely/default.aspx" /><link rel="self" type="application/atom+xml" href="http://devlicio.us/blogs/scott_seely/atom.aspx" /><generator uri="http://communityserver.org" version="4.1.31106.3070">Community Server</generator><updated>2009-08-23T11:05:00Z</updated><entry><title>Review of RedGate .NET Reflector Pro</title><link rel="alternate" type="text/html" href="/blogs/scott_seely/archive/2010/03/16/review-of-redgate-net-reflector-pro.aspx" /><id>/blogs/scott_seely/archive/2010/03/16/review-of-redgate-net-reflector-pro.aspx</id><published>2010-03-17T00:38:00Z</published><updated>2010-03-17T00:38:00Z</updated><content type="html">&lt;p&gt;&lt;i&gt;Disclaimer: RedGate is a sponsor of &lt;a href="http://devlicio.us/"&gt;devlicio.us&lt;/a&gt; and offered a copy of the product and a ThinkGeek gift certificate as an incentive to review their product. This review is the work of the author and was not approved by anyone other than the author. There, now you know the kind of taint this review has. Please keep reading anyhow. OK? Good!&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.red-gate.com/products/reflector/"&gt;.NET Reflector&lt;/a&gt; is part of any respectable .NET developer&amp;rsquo;s tool belt. When you want to figure out how something works, why your code breaks when interacting with some library, you view the assembly through .NET Reflector&amp;rsquo;s lens. The latest version, 6.1.0.11, will display the IL in an assembly as IL, Managed C++, VB.NET, C#, &lt;a href="http://en.wikipedia.org/wiki/Delphi_programming_language"&gt;Delphi&lt;/a&gt;, or &lt;a href="http://en.wikipedia.org/wiki/Oxygene_(programming_language)"&gt;Oxygene&lt;/a&gt;. The latest version has been updated to support .NET 4 and allows you to jump into .NET Reflector from Visual Studio. I was disappointed to see that the &amp;ldquo;Open in .NET Reflector&amp;rdquo; menu option is only available from the Object Explorer. I would have expected to see this option by right-clicking on the assembly from the References list in the Solution Explorer, but no. Given that other tools (&lt;a href="http://www.testdriven.net/"&gt;TestDriven.NET&lt;/a&gt; in particular) &lt;em&gt;&lt;strong&gt;do&lt;/strong&gt;&lt;/em&gt; add this functionality (they actually add &amp;ldquo;Open in .NET Reflector&amp;rdquo; from the Solution Explorer!) RedGate needs to address this usability issue. &lt;/p&gt;
&lt;p&gt;Otherwise, the free version of .NET Reflector hasn&amp;rsquo;t changed. It is still a great tool. &lt;/p&gt;
&lt;p&gt;So, what about this new, Pro version? First, it costs $195 US. What do you get for that price? You get the ability to generate source code and &lt;a href="http://en.wikipedia.org/wiki/Program_database"&gt;PDB&lt;/a&gt;s so that you can step through the assemblies you use in the languages you know. If you are debugging Microsoft provided assemblies, you can already step through assemblies using the actual source (typically C#) through the Enable .NET Framework Source Stepping option from the Options dialog (in VS 2008/2010, access this dialog from Tools&amp;mdash;&amp;gt;Options menu.)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/image_5F00_54AD2EDA.png"&gt;&lt;img height="294" width="504" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/image_5F00_thumb_5F00_00A9E032.png" alt="image" border="0" title="image" style="border-right-width:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In the past, Microsoft wasn&amp;rsquo;t always good about keeping their symbol servers and source code servers up to date. Not every group put their code into the repository right away, so service packs and other patches might cause you to lose the ability to step through code. If you use components from other vendors, this option does you no good at all. RedGate is betting that a number of you want to be able to step through all .NET assemblies in VB.NET or C#. At a high level, RedGate generates the source code for an entire assembly and dumps it onto disk. It also writes out a PDB that tells Visual Studio how to map the assembly code to the generated code. &lt;/p&gt;
&lt;p&gt;To long time users of .NET Reflector, the code generation piece may sound like old hat. It is. Back in May of 2004, &lt;a href="http://www.denisbauer.com/NETTools/FileDisassembler.aspx"&gt;Denis Bauer released a .NET Reflector plug-in&lt;/a&gt; that dumps the assembly information as code files (the plug-in was last updated for .NET Reflector v5). If you want a full project file for the dumped files, you used &lt;a href="http://jasonbock.net/JB/Default.aspx"&gt;Jason Bock&lt;/a&gt;&amp;rsquo;s &lt;a href="http://www.codeplex.com/FileGenReflector"&gt;FileGenerator&lt;/a&gt; plugin. Unfortunately, neither of these allow you to step through code, and that&amp;rsquo;s what many of us need. .NET Reflector Pro adds that functionality.&lt;/p&gt;
&lt;p&gt;The overall experience is seamless. Upon running .NET Reflector, the .NET Reflector top level menu is added to Visual Studio 2008/2010. From here, you can either decompile an assembly in your project, Explore Decompiled Assemblies, or Debug an Executable. &lt;/p&gt;
&lt;p&gt;Explore Decompiled Assemblies just pops open the Object Explorer in Visual Studio. I would have expected the list to be reduced to the list of assemblies I had already decompiled, but that isn&amp;rsquo;t what happened. Debug an Executable is a bit confusing too&amp;mdash;it just fires up the executable and attached the debugger. If you have decompiled the assemblies of interest already, you can step through that code. Otherwise, this feature seems to be a bit of a waste. When PDB information does not exist, I would have expected the UI to say something like &amp;ldquo;.NET Reflector has not created debugging information for the selected executable. Would you like to generate source code and PDBs now?&amp;rdquo; I should then be able to select the assemblies I want to debug using this new functionality. &lt;/p&gt;
&lt;p&gt;All that said, the tool does redeem itself. When selecting .NET Reflector&amp;mdash;&amp;gt;Choose Assemblies to Debug, the tool gets things right. This is the only feature in the Pro version that seems to have been completely thought out. At this stage, you are presented with the following dialog:&lt;/p&gt;
&lt;p align="center"&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/image_5F00_70AA75A0.png"&gt;&lt;img height="427" width="587" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/image_5F00_thumb_5F00_198564DD.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p align="left"&gt;You can generate the source in C# v2.0/3.0 or Visual Basic 8.0/9.0. You then select the assemblies you would like to be able to step through and press OK. A little while later (time completely dependent on the size of the assembly), you are ready to do source level debugging. In the I tested out, this worked as advertised. I was able to step into System.dll, System.Web.dll, and other assemblies I regularly use. So, for .NET 4.0, clearly a win. F11 works fine, you can set breakpoints etc. For .NET 4.0 developers, this will be very helpful debugging those nasty issues where you need to figure out why your code is causing .NET and other libraries to die.&lt;/p&gt;
&lt;p align="left"&gt;So, how about Silverlight? I had .NET Reflector generate the source/debug information for System.Windows. Then, I set a breakpoint in the constructor for my Silverlight MainPage.xaml.cs. I was able to step out to MS.Internal.CoreInvokeHandler.InvokeEventHandler. &lt;/p&gt;
&lt;p align="left"&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/image_5F00_1C6AA3C3.png"&gt;&lt;img height="381" width="504" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/image_5F00_thumb_5F00_55ADDE2D.png" alt="image" border="0" title="image" style="border-right-width:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p align="left"&gt;I tried doing the same thing with the just released Windows Phone SDK. In this case, I was unable to get the application to rebuild correctly and work. After instructing .NET Reflector to generate the information for System.Windows for a Windows Phone Application, I saw this dialog:&lt;/p&gt;
&lt;p align="center"&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/image_5F00_03F73E0E.png"&gt;&lt;img height="344" width="304" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/image_5F00_thumb_5F00_04BF7E2B.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;After generating the assemblies, Reflector pointed the references in the solution to the new assemblies. Upon debugging, I saw this message (followed by several more for the other updated assemblies):&lt;/p&gt;
&lt;p&gt;--------------------------- &lt;br /&gt;.NET Reflector &lt;br /&gt;--------------------------- &lt;br /&gt;The loaded assembly &amp;quot;System.Windows&amp;quot; is not the one .NET Reflector expected. &lt;/p&gt;
&lt;p&gt;Expected version: &amp;quot;c:\temp\regen\System.Windows.dll&amp;quot; &lt;/p&gt;
&lt;p&gt;Loaded version: &amp;quot;System.Windows.dll&amp;quot; &lt;/p&gt;
&lt;p&gt;If the correct assembly is not loaded, debugging may not work. &lt;br /&gt;--------------------------- &lt;br /&gt;OK&amp;nbsp;&amp;nbsp; &lt;br /&gt;---------------------------&lt;/p&gt;
&lt;p&gt;If you are doing any Windows Phone development, the tool does not work for you. I imagine that this shortcoming will be addressed in the coming months&amp;mdash;the SDK was only recently released. &lt;/p&gt;
&lt;h4&gt;Other things I noticed&lt;/h4&gt;
&lt;p&gt;The source code gets dropped into an AppData folder. For example, the code for MS.Internal.CoreInvokeHandler is at:&lt;/p&gt;
&lt;p&gt;C:\Users\Scott Seely\AppData\Local\Red Gate\.NET Reflector 6\Cache\V4\x86\CS\V35\c46bf0b4-91fb-4aa9-8732-63fe4e8d7afc\MS\Internal\CoreInvokeHandler.cs&lt;/p&gt;
&lt;p&gt;Looking in the v35 directory, we see that a PDB is dumped out:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/image_5F00_20A08D56.png"&gt;&lt;img height="198" width="504" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/image_5F00_thumb_5F00_42C8730F.png" alt="image" border="0" title="image" style="border-right-width:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto;" /&gt;&lt;/a&gt;The assemblyLoc file corresponding to the System.Windows.PDB file has the following contents:&lt;/p&gt;
&lt;p&gt;c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.Windows.dll&lt;/p&gt;
&lt;p&gt;For an assembly in the GAC, System.Windows.Forms, the assemblyLoc file points to it&amp;rsquo;s GAC location:&lt;/p&gt;
&lt;p&gt;C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll&lt;/p&gt;
&lt;p&gt;which appears to say that the symbols are generated from that particular reference assembly. The GUID named folder contains source code.&amp;nbsp; &lt;/p&gt;
&lt;h4&gt;Summary&lt;/h4&gt;
&lt;p&gt;Having access to source and single stepping helps me troubleshoot problems faster because I can see why the underlying code doesn&amp;rsquo;t like what I&amp;rsquo;m doing when consuming the class libraries. Like most developer tools, this one has its value in the time savings you will get by getting you to the &lt;em&gt;why&lt;/em&gt; of a bug in less time. I like the tool because it doesn&amp;rsquo;t change how I do my day job. It gives me access to more code so I can poke down the debug path even further without pulling out Reflector to grok why my code isn&amp;rsquo;t behaving as expected. And, I can easily make stepping into other people&amp;rsquo;s code part of my daily workflow. &lt;/p&gt;
&lt;p&gt;Overall, I like the enhancements and am looking forward to using .NET Reflector Pro. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=56120" width="1" height="1"&gt;</content><author><name>sseely</name><uri>http://devlicio.us/members/sseely/default.aspx</uri></author></entry><entry><title>Versioning REST Services</title><link rel="alternate" type="text/html" href="/blogs/scott_seely/archive/2010/03/13/versioning-rest-services.aspx" /><id>/blogs/scott_seely/archive/2010/03/13/versioning-rest-services.aspx</id><published>2010-03-13T19:01:00Z</published><updated>2010-03-13T19:01:00Z</updated><content type="html">&lt;p&gt;I&amp;rsquo;ve always been intrigued by the versioning problem. The versioning problem works like this: you build an API (Application Programming Interface) to get some work done. That API is successful and consumers ask for enhancements to the API. At this point, you have a problem: how do you support everyone who uses the current API while adding enhancements? If you have been down this road, you know that you have to solve the problem early&amp;mdash;before success. &lt;/p&gt;
&lt;p&gt;The way you handle versioning varies. With compiled code and libraries, you send out a new DLL/Assembly/JAR file and tell folks to convert existing code when they have a chance. With Web services, including SOAP, REST, and just HTTP accessible ones, you have other issues. You typically want a single code base to consume the old and updated messages. Given that many of us are now writing REST services, I talked to InformIT about the need for an article explaining how to version these JSON/XML speaking endpoints. That article is now live and available for your reading at &lt;a href="http://www.informit.com/articles/article.aspx?p=1566460" title="http://www.informit.com/articles/article.aspx?p=1566460"&gt;http://www.informit.com/articles/article.aspx?p=1566460&lt;/a&gt;. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=55926" width="1" height="1"&gt;</content><author><name>sseely</name><uri>http://devlicio.us/members/sseely/default.aspx</uri></author></entry><entry><title>I’m such a friggin idiot—Day of Mobile has that Jay Freeman!</title><link rel="alternate" type="text/html" href="/blogs/scott_seely/archive/2010/02/26/i-m-such-a-friggin-idiot-day-of-mobile-has-that-jay-freeman.aspx" /><id>/blogs/scott_seely/archive/2010/02/26/i-m-such-a-friggin-idiot-day-of-mobile-has-that-jay-freeman.aspx</id><published>2010-02-27T01:17:00Z</published><updated>2010-02-27T01:17:00Z</updated><content type="html">&lt;p&gt;I&amp;rsquo;m hosting a conference in Chicago called &lt;a href="http://www.dayofmobile.com"&gt;Day of Mobile&lt;/a&gt;. At the end of the day, we are having a big time keynote from &lt;a href="http://www.saurik.com/"&gt;Jay Freeman&lt;/a&gt;. These days, he&amp;rsquo;s a rock star in the iPhone universe. For some reason, and I&amp;rsquo;m a complete moron for not realizing this until a few minutes ago, he is the same guy who brought the .NET world this little tool: &lt;a href="http://legacy.saurik.com/net/exemplar/"&gt;Anakrino&lt;/a&gt;. If you are scratching your head and wondering why that would impress me, it&amp;rsquo;s because I&amp;rsquo;m getting older and I&amp;rsquo;ve used every .NET tool in the world. Anakrino was a mainstay at Microsoft to decompile .NET assemblies to read in C# and VB.NET. It was easier to use than grabbing the source code. &lt;span style="text-decoration:line-through;"&gt;Eventually, the tool found a home at RedGate and is now called .NET Reflector.&lt;/span&gt; &lt;em&gt;[edit: Apparently,&amp;nbsp;my memory is poor at times too. As a commenter so kindly pointed out, Lutz Roeder wrote Reflector, at one time a competitor of Anakrino.]&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So, in the last few minutes, I&amp;rsquo;ve gone from realizing that we had a really awesome iPhone ninja speaking at the conference to realizing that we had one of those legendary brainiac developers at the conference. And, while I didn&amp;rsquo;t want to pimp the conference at devlicio.us, I now feel I should because he&amp;rsquo;s such a part of all of our everyday lives as .NET developers. I mean, the guy who single handedly wrote Anakrino&lt;span style="text-decoration:line-through;"&gt;/.NET Reflector&lt;/span&gt;. Holy friggin&amp;rsquo; crap! &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=55568" width="1" height="1"&gt;</content><author><name>sseely</name><uri>http://devlicio.us/members/sseely/default.aspx</uri></author></entry><entry><title>Visual Studio 2010 Beta--&gt;RC install and ASP.NET</title><link rel="alternate" type="text/html" href="/blogs/scott_seely/archive/2010/02/10/visual-studio-2010-beta-gt-rc-install-and-asp-net.aspx" /><id>/blogs/scott_seely/archive/2010/02/10/visual-studio-2010-beta-gt-rc-install-and-asp-net.aspx</id><published>2010-02-10T14:31:00Z</published><updated>2010-02-10T14:31:00Z</updated><content type="html">&lt;p&gt;I installed the VS 2010 RC last night, after uninstalling the VS 2010 Beta. If you see that ASP.NET isn&amp;rsquo;t coming up/working on your machine, you may need to remap the ASP.NET handlers into IIS. To do that, go to the Microsoft.NET 4.0 folder on your machine (typically C:\Windows\Microsoft.NET\Framework64\v4.0.30128 on a 64-bit Windows install, C:\Windows\Microsoft.NET\Framework\v4.0.30128 on a 32-bit install). Once in that folder, run the following:&lt;/p&gt;
&lt;p&gt;aspnet_regiis.exe&amp;nbsp;&amp;ndash;i&lt;/p&gt;
&lt;p&gt;After doing this, your ASP.NET applications should start running again. This is the same trick that worked on earlier versions of .NET, but it&amp;rsquo;s been a while since we had a .NET upgrade. I thought this might help out a few of you out there. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=55336" width="1" height="1"&gt;</content><author><name>sseely</name><uri>http://devlicio.us/members/sseely/default.aspx</uri></author></entry><entry><title>DataContract, Partial Types and Generated Code</title><link rel="alternate" type="text/html" href="/blogs/scott_seely/archive/2010/02/09/datacontract-partial-types-and-generated-code.aspx" /><id>/blogs/scott_seely/archive/2010/02/09/datacontract-partial-types-and-generated-code.aspx</id><published>2010-02-09T19:31:00Z</published><updated>2010-02-09T19:31:00Z</updated><content type="html">&lt;p&gt;The other day, a friend had an issue with a &lt;strong&gt;DataContract&lt;/strong&gt;. He had an Entity Model that used &lt;strong&gt;DataContract&lt;/strong&gt; serialization. The code, stripped down to its essence, had something like this:&lt;/p&gt;
&lt;pre class="code"&gt;[DataContract]
&lt;span style="color:blue;"&gt;public partial class &lt;/span&gt;SomeClass
{
    [DataMember]
    &lt;span style="color:blue;"&gt;public int &lt;/span&gt;MyInt { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;set&lt;/span&gt;; }
}
&lt;/pre&gt;
&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And this was all well and good. When transmitting &lt;strong&gt;SomeClass&lt;/strong&gt; over the wire, the fields on the entity model were transmitted. Now, my friend is really smart, and he knew that his version of serialization had implicit serialization. So, when adding new fields, he relied on implicit field serialization by augmenting &lt;strong&gt;SomeClass&lt;/strong&gt; in a separate file as:&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;public partial class &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;SomeClass
&lt;/span&gt;{
    &lt;span style="color:blue;"&gt;public string &lt;/span&gt;MyString { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;set&lt;/span&gt;; }
}
&lt;/pre&gt;
&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Lo and behold, the field MyString didn&amp;rsquo;t appear on the wire. Why was this? This is because partial classes are a compiler trick that hides itself at the assembly level. The assembly indicated that SomeClass is a type that has the following C# implementation:&lt;/p&gt;
&lt;pre class="code"&gt;[&lt;span style="color:#2b91af;"&gt;DataContract&lt;/span&gt;]
&lt;span style="color:blue;"&gt;public partial class &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;SomeClass
&lt;/span&gt;{
    [&lt;span style="color:#2b91af;"&gt;DataMember&lt;/span&gt;]
    &lt;span style="color:blue;"&gt;public int &lt;/span&gt;MyInt { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;set&lt;/span&gt;; }

    &lt;span style="color:blue;"&gt;public string &lt;/span&gt;MyString { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;set&lt;/span&gt;; }
}
&lt;/pre&gt;
&lt;pre class="code"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;p&gt;This shows that &lt;strong&gt;MyString &lt;/strong&gt;is not part of the data contract, so the field doesn&amp;rsquo;t get serialized. At the assembly level, no one knows that you separated the implementation across two files. &lt;/p&gt;
&lt;p&gt;So, next time you are wondering why part of your object isn&amp;rsquo;t being serialized, see if you made any declarations about serialization on the type. If you did, you have turned off the automatic &amp;ldquo;magic&amp;rdquo; parts of serialization. Sometimes, wizards will make those decisions for you. One way to recognize that the work was done for you: look to see if the generated type has &lt;strong&gt;[DataContract]&lt;/strong&gt; on the partial class you are augmenting.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=55328" width="1" height="1"&gt;</content><author><name>sseely</name><uri>http://devlicio.us/members/sseely/default.aspx</uri></author></entry><entry><title>Incorporating Video into a Silverlight 4 Application</title><link rel="alternate" type="text/html" href="/blogs/scott_seely/archive/2010/01/25/incorporating-video-into-a-silverlight-4-application.aspx" /><id>/blogs/scott_seely/archive/2010/01/25/incorporating-video-into-a-silverlight-4-application.aspx</id><published>2010-01-25T12:00:00Z</published><updated>2010-01-25T12:00:00Z</updated><content type="html">&lt;p&gt;



&lt;/p&gt;
&lt;p&gt;Over the past week, I spent some time with Silverlight 4. I&amp;rsquo;m really impressed by how easy it is to incorporate video into an application. This post shows how to capture video from the camera and display the video on the screen. The post also handles grabbing single frames of video. You might use this type of arrangement to allow users to upload images, hold impromptu web casts, and to do video conferencing.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve uploaded a barebones application that turns on video capture and displays the video (viewable &lt;a href="http://www.scottseely.com/blog/10-01-24/Incorporating_Video_into_a_Silverlight_4_Application.aspx"&gt;here&lt;/a&gt;) &lt;/p&gt;
&lt;p&gt;To understand how this works, you need to be familiar with the following objects:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;CaptureSource&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;CaptureDeviceConfiguration&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;VideoBrush&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The &lt;b&gt;CaptureSource&lt;/b&gt; type encapsulates the methods needed to interact with audio and video devices. &lt;/p&gt;
&lt;p&gt;&lt;b&gt;CaptureDeviceConfiguration&lt;/b&gt; acts as gatekeeper to the webcam and microphone. &lt;b&gt;CaptureDeviceConfiguration&lt;/b&gt; knows how to ask the user for permission to use the webcam or microphone. It also remembers what the user said about using the webcam or microphone during the current session. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;VideoBrush &lt;/strong&gt;knows how to paint using a video as the source.&lt;/p&gt;
&lt;p&gt;In order to interact with the camera, you need to know whether the user gave you permission and if not, you have to ask for permission. Once you have permission, you just need to capture video from the default camera, create the brush, and start capturing the video. &lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;private &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;CaptureSource &lt;/span&gt;_captureSource = &lt;span style="color:blue;"&gt;null&lt;/span&gt;;
&lt;span style="color:blue;"&gt;private void &lt;/span&gt;btnStartCapture_Click(&lt;span style="color:blue;"&gt;object &lt;/span&gt;sender, &lt;span style="color:#2b91af;"&gt;RoutedEventArgs &lt;/span&gt;e)
{
    &lt;span style="color:blue;"&gt;if &lt;/span&gt;(_captureSource != &lt;span style="color:blue;"&gt;null &lt;/span&gt;&amp;amp;&amp;amp; &lt;/pre&gt;
&lt;pre class="code"&gt;        _captureSource.State == &lt;span style="color:#2b91af;"&gt;CaptureState&lt;/span&gt;.Started)
    {
        &lt;span style="color:blue;"&gt;return&lt;/span&gt;;
    }
    &lt;span style="color:blue;"&gt;if&lt;/span&gt;(!&lt;span style="color:#2b91af;"&gt;CaptureDeviceConfiguration&lt;/span&gt;.AllowedDeviceAccess)
    {
        &lt;span style="color:blue;"&gt;if&lt;/span&gt;(!&lt;span style="color:#2b91af;"&gt;CaptureDeviceConfiguration&lt;/span&gt;.RequestDeviceAccess())
        {
            &lt;span style="color:blue;"&gt;return&lt;/span&gt;;
        }
    }

    _captureSource = &lt;span style="color:blue;"&gt;new &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;CaptureSource
       &lt;/span&gt;{
         VideoCaptureDevice = &lt;/pre&gt;
&lt;pre class="code"&gt;           &lt;span style="color:#2b91af;"&gt;CaptureDeviceConfiguration&lt;/span&gt;.GetDefaultVideoCaptureDevice()
       };
    &lt;span style="color:blue;"&gt;var &lt;/span&gt;brush = &lt;span style="color:blue;"&gt;new &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;VideoBrush&lt;/span&gt;();
    brush.SetSource(_captureSource);
    _captureSource.Start();
    rectVideo.Fill = brush;
}&lt;/pre&gt;
&lt;p&gt;Later on, when the user wants to capture the current video as an image, you just do something like this to put the current frame into an image control:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;private void &lt;/span&gt;btnGrabImage_Click(&lt;span style="color:blue;"&gt;object &lt;/span&gt;sender, &lt;span style="color:#2b91af;"&gt;RoutedEventArgs &lt;/span&gt;e)
{
    &lt;span style="color:blue;"&gt;if&lt;/span&gt;(_captureSource == &lt;span style="color:blue;"&gt;null &lt;/span&gt;|| _captureSource.State != &lt;span style="color:#2b91af;"&gt;CaptureState&lt;/span&gt;.Started)
    {
        &lt;span style="color:blue;"&gt;return&lt;/span&gt;;
    }
    _captureSource.AsyncCaptureImage(
        image =&amp;gt; imgCapture.Source = image
        );
}&lt;/pre&gt;
&lt;p&gt;As someone who spent way too much time in the C++/MFC era writing code to capture video from devices, I am incredibly impressed with the brevity of the code. I think the SL4 team did an awesome job here. Way to go! &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can grab the sample project &lt;a href="http://www.scottseely.com/downloads/WebCam/DimeCast.WebCam.zip"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=55124" width="1" height="1"&gt;</content><author><name>sseely</name><uri>http://devlicio.us/members/sseely/default.aspx</uri></author></entry><entry><title>The Sieve of Eratosthenes and F#</title><link rel="alternate" type="text/html" href="/blogs/scott_seely/archive/2009/12/18/the-sieve-of-eratosthenes-and-f.aspx" /><id>/blogs/scott_seely/archive/2009/12/18/the-sieve-of-eratosthenes-and-f.aspx</id><published>2009-12-19T03:42:00Z</published><updated>2009-12-19T03:42:00Z</updated><content type="html">&lt;p&gt;There is a problem on the Euler project, &lt;a href="http://www.projecteuler.net"&gt;www.projecteuler.net&lt;/a&gt;, which asks to find the sum of all values under a given number. Problems on the Euler project have a range of solutions, where at least one solution has a runtime of under 1 minute. A popular, time efficient algorithm that finds all primes in a given range is the &lt;a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes" target="_blank"&gt;Sieve of Eratosthenes&lt;/a&gt;. The basic algorithm is:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Create an array that contains all values from 2 up to the final maximum value &lt;/li&gt;    &lt;li&gt;Starting at 2, For each value in the array, mark all items that have indices of the current value that are multiples and NOT equivalent to the current index as 0 (eg. index mod [current value] == 0). &lt;/li&gt;    &lt;li&gt;March forward until you hit a non-zero value in the array, then mark all multiples as 0. &lt;/li&gt;    &lt;li&gt;Halt condition: stop when you cross the midpoint of the array (anything remaining that is non-zero is a prime since you already all multiples of 2). &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;In practice, this gives successive iterations of an array from 2 .. 10 as:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;[2, 3, 4, 5, 6, 7, 8, 9, 10] &lt;/li&gt;    &lt;li&gt;[2, 3, 0, 5, 0, 7, 0, 9, 0] &lt;/li&gt;    &lt;li&gt;[2, 3, 0, 5, 0, 7, 0, 0, 0] &lt;/li&gt;    &lt;li&gt;At this point, we reach 5, which is greater than the length of the array (9) divided by 2 (4.5). Any non-zero values in the array are prime. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;In C#, one possible implementation is:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;private static long &lt;/span&gt;SieveOfErastosthenes(&lt;span style="color:blue;"&gt;long &lt;/span&gt;maxvalue)
{
    &lt;span style="color:blue;"&gt;long&lt;/span&gt;[] values = &lt;span style="color:blue;"&gt;new long&lt;/span&gt;[maxvalue];
    &lt;span style="color:green;"&gt;// Populate the list
    &lt;/span&gt;&lt;span style="color:blue;"&gt;for &lt;/span&gt;(&lt;span style="color:blue;"&gt;long &lt;/span&gt;i = &lt;span style="color:brown;"&gt;0&lt;/span&gt;; i &amp;lt; values.LongLength; ++i)
    {
        values[i] = i;
    }
    values[&lt;span style="color:brown;"&gt;0&lt;/span&gt;] = &lt;span style="color:brown;"&gt;0&lt;/span&gt;;
    values[&lt;span style="color:brown;"&gt;1&lt;/span&gt;] = &lt;span style="color:brown;"&gt;0&lt;/span&gt;;
    &lt;span style="color:blue;"&gt;for &lt;/span&gt;(&lt;span style="color:blue;"&gt;long &lt;/span&gt;i = &lt;span style="color:brown;"&gt;2&lt;/span&gt;; i &amp;lt; values.LongLength; ++i)
    {
        &lt;span style="color:blue;"&gt;if &lt;/span&gt;(values[i] != &lt;span style="color:brown;"&gt;0&lt;/span&gt;)
        {
            &lt;span style="color:blue;"&gt;for &lt;/span&gt;(&lt;span style="color:blue;"&gt;long &lt;/span&gt;j = i * &lt;span style="color:brown;"&gt;2&lt;/span&gt;; j &amp;lt; values.LongLength; j += i)
            {
                values[j] = &lt;span style="color:brown;"&gt;0&lt;/span&gt;;
            }
        }
    }

    &lt;span style="color:blue;"&gt;long &lt;/span&gt;retval = &lt;span style="color:brown;"&gt;0&lt;/span&gt;;
    &lt;span style="color:blue;"&gt;foreach &lt;/span&gt;(&lt;span style="color:blue;"&gt;long &lt;/span&gt;k &lt;span style="color:blue;"&gt;in &lt;/span&gt;values)
    {
        retval += k;
    }
    &lt;span style="color:blue;"&gt;return &lt;/span&gt;retval;
}&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;Overall computational complexity is O(n). If you aren’t familiar with big O notation, the overall complexity is bound by the size of the dataset times a constant—in this case 3, since we iterate through the complete dataset 3 times:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Populate the dataset &lt;/li&gt;

  &lt;li&gt;Mark all non primes as 0 &lt;/li&gt;

  &lt;li&gt;Sum the primes &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And yes, this works quite well, even for large values of n. My challenge was to get the sieve to work with performance equal to C#, only in F#. At the start of this, I had my first pass of the C# code running in ~600 ms for a value of 5 million. The challenge I set for myself was to achieve a similar timing in F#. The first few passes left me with runtimes of over 15 minutes (I killed the runs prior to completion). The reason why was simple: I wrote an O(n^3) algorithm. My challenge was to get this faster without using mutable values. My first pass looked like this:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;let rec &lt;/span&gt;sieveofErastosthenes values filterout maxval =
    &lt;span style="color:blue;"&gt;if &lt;/span&gt;(filterout &amp;gt;= (maxval/&lt;span style="color:brown;"&gt;2&lt;/span&gt;)) &lt;span style="color:blue;"&gt;then
        &lt;/span&gt;values
    &lt;span style="color:blue;"&gt;else
        let &lt;/span&gt;shouldFilter =
            &lt;span style="color:blue;"&gt;try
                let &lt;/span&gt;a = values |&amp;gt; List.find(&lt;span style="color:blue;"&gt;fun &lt;/span&gt;x &lt;span style="color:blue;"&gt;-&amp;gt; &lt;/span&gt;x = filterout)
                a &amp;lt;&amp;gt; &lt;span style="color:brown;"&gt;0
            &lt;/span&gt;&lt;span style="color:blue;"&gt;with
            &lt;/span&gt;| _ &lt;span style="color:blue;"&gt;as &lt;/span&gt;ex &lt;span style="color:blue;"&gt;-&amp;gt; false
        if &lt;/span&gt;(shouldFilter) &lt;span style="color:blue;"&gt;then
            &lt;/span&gt;sieveofErastosthenes (values 
                |&amp;gt; List.filter(&lt;span style="color:blue;"&gt;fun &lt;/span&gt;x &lt;span style="color:blue;"&gt;-&amp;gt; &lt;/span&gt;(x = filterout) || ((x % filterout) &amp;lt;&amp;gt; &lt;span style="color:brown;"&gt;0&lt;/span&gt;))) (filterout + &lt;span style="color:brown;"&gt;1&lt;/span&gt;) maxval
        &lt;span style="color:blue;"&gt;else
            &lt;/span&gt;sieveofErastosthenes values (values |&amp;gt; List.find(&lt;span style="color:blue;"&gt;fun &lt;/span&gt;x &lt;span style="color:blue;"&gt;-&amp;gt; &lt;/span&gt;x &amp;gt; filterout)) maxval

&lt;span style="color:blue;"&gt;let &lt;/span&gt;max = &lt;span style="color:brown;"&gt;5000000
&lt;/span&gt;&lt;span style="color:blue;"&gt;let &lt;/span&gt;sumofprimes =  sieveofErastosthenes [&lt;span style="color:brown;"&gt;2 &lt;/span&gt;.. max] &lt;span style="color:brown;"&gt;2 &lt;/span&gt;max |&amp;gt; List.map( &lt;span style="color:blue;"&gt;fun &lt;/span&gt;x &lt;span style="color:blue;"&gt;-&amp;gt; &lt;/span&gt;int64 x) |&amp;gt; List.sum&lt;/pre&gt;

&lt;p&gt;This code is correct—pass in 10 for the max and the value returned is 17. But the answer just never returned for larger values within reasonable time. Next, I tried using a mutable type: System.Collections.Generic.List&amp;lt;T&amp;gt;. This got the time down to a measureable 4s. That’s still 6.5x longer than the C# version. That next attempt looks like this:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;let &lt;/span&gt;sieveOfEratosthenes x =
    &lt;span style="color:blue;"&gt;let &lt;/span&gt;retval = &lt;span style="color:blue;"&gt;new &lt;/span&gt;List&amp;lt;int32&amp;gt;()
    retval.AddRange([&lt;span style="color:brown;"&gt;0 &lt;/span&gt;.. x])
    retval.Item(&lt;span style="color:brown;"&gt;0&lt;/span&gt;) &amp;lt;- &lt;span style="color:brown;"&gt;0
    &lt;/span&gt;retval.Item(&lt;span style="color:brown;"&gt;1&lt;/span&gt;) &amp;lt;- &lt;span style="color:brown;"&gt;0
    &lt;/span&gt;&lt;span style="color:blue;"&gt;for &lt;/span&gt;i &lt;span style="color:blue;"&gt;in &lt;/span&gt;&lt;span style="color:brown;"&gt;2 &lt;/span&gt;.. x &lt;span style="color:blue;"&gt;do
        if &lt;/span&gt;retval.Item(i) &amp;lt;&amp;gt; &lt;span style="color:brown;"&gt;0 &lt;/span&gt;&lt;span style="color:blue;"&gt;then
            for &lt;/span&gt;j &lt;span style="color:blue;"&gt;in &lt;/span&gt;&lt;span style="color:brown;"&gt;2 &lt;/span&gt;* i .. i .. x &lt;span style="color:blue;"&gt;do
                &lt;/span&gt;retval.Item(j) &amp;lt;- &lt;span style="color:brown;"&gt;0
    &lt;/span&gt;retval.ToArray()

&lt;span style="color:blue;"&gt;let &lt;/span&gt;max = &lt;span style="color:brown;"&gt;5000000
&lt;/span&gt;&lt;span style="color:blue;"&gt;let &lt;/span&gt;sumofprimes =  sieveOfEratosthenes max |&amp;gt; Seq.map( &lt;span style="color:blue;"&gt;fun &lt;/span&gt;x &lt;span style="color:blue;"&gt;-&amp;gt; &lt;/span&gt;int64 x) |&amp;gt; Seq.sum
printfn &lt;span style="color:maroon;"&gt;&amp;quot;%A\n&amp;quot; &lt;/span&gt;sumofprimes&lt;/pre&gt;

&lt;p&gt;Notice that this latest iteration executes a lot less code and, frankly, looks pretty close to the C# code. Through some investigation, I found that the call to preload the array consumed 2.6 s. I then switched to a sequence and shrank the execution time to 2300 ms. I was closing in on my goal and learning some stuff about the performance of various F# constructs. Loading using a sequence changed the AddRange call to this:&lt;/p&gt;

&lt;pre class="code"&gt;retval.AddRange([|&lt;span style="color:brown;"&gt;0 &lt;/span&gt;.. x|])&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The reason this takes less time is simple. When allocating a List, F# allocates and initializes all values up front. The Seq is created with an iterator and only allocates enough space to store the iterator and not much else. So far, so good. At this point, I did a search on F# implementations of the Sieve of Eratosthenes and found that &lt;a href="http://blogs.msdn.com/chrsmith/archive/2008/04/29/sieve-of-eratosthenes-in-f.aspx" target="_blank"&gt;Chris Smith had one&lt;/a&gt;. His implementation keeps track of which numbers AREN’T prime. Performance on his algorithm hits 8600 ms. That wound up being a step in the wrong direction.&lt;/p&gt;

&lt;p&gt;Next, I tried, explicitly initializing the list of integers and cut the time down to 1450 ms. The strategy was getting me closer to optimal timing and showed that, for 5 million int32s, I was filling in the list in 46 ms. &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;let &lt;/span&gt;sieveOfEratosthenes x =
    &lt;span style="color:blue;"&gt;let &lt;/span&gt;retval = &lt;span style="color:blue;"&gt;new &lt;/span&gt;List&amp;lt;int32&amp;gt;(x + &lt;span style="color:brown;"&gt;1&lt;/span&gt;)
    &lt;span style="color:blue;"&gt;for &lt;/span&gt;i &lt;span style="color:blue;"&gt;in &lt;/span&gt;&lt;span style="color:brown;"&gt;0 &lt;/span&gt;.. x &lt;span style="color:blue;"&gt;do &lt;/span&gt;retval.Add(i)

    retval.Item(&lt;span style="color:brown;"&gt;0&lt;/span&gt;) &amp;lt;- &lt;span style="color:brown;"&gt;0
    &lt;/span&gt;retval.Item(&lt;span style="color:brown;"&gt;1&lt;/span&gt;) &amp;lt;- &lt;span style="color:brown;"&gt;0
    &lt;/span&gt;&lt;span style="color:blue;"&gt;for &lt;/span&gt;i &lt;span style="color:blue;"&gt;in &lt;/span&gt;&lt;span style="color:brown;"&gt;2 &lt;/span&gt;.. x &lt;span style="color:blue;"&gt;do
        if &lt;/span&gt;retval.Item(i) &amp;lt;&amp;gt; &lt;span style="color:brown;"&gt;0 &lt;/span&gt;&lt;span style="color:blue;"&gt;then
            for &lt;/span&gt;j &lt;span style="color:blue;"&gt;in &lt;/span&gt;&lt;span style="color:brown;"&gt;2 &lt;/span&gt;* i .. i .. x &lt;span style="color:blue;"&gt;do
                &lt;/span&gt;retval.Item(j) &amp;lt;- &lt;span style="color:brown;"&gt;0
    &lt;/span&gt;retval |&amp;gt; Seq.filter(&lt;span style="color:blue;"&gt;fun &lt;/span&gt;x &lt;span style="color:blue;"&gt;-&amp;gt; &lt;/span&gt;x &amp;lt;&amp;gt; &lt;span style="color:brown;"&gt;0&lt;/span&gt;)&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This was better, but I’d like to get closer to the C# version. The last thing I tried was moving to Array from System.Collections.Generic.List. This last change cut 250 ms, bringing my times down to 1200 ms. It looks like using lighter weight objects really will speed things up! That version is:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;let &lt;/span&gt;sieveOfEratosthenes x =
    &lt;span style="color:blue;"&gt;let &lt;/span&gt;retval = Array.zeroCreate(x + &lt;span style="color:brown;"&gt;1&lt;/span&gt;)
    &lt;span style="color:blue;"&gt;for &lt;/span&gt;i &lt;span style="color:blue;"&gt;in &lt;/span&gt;&lt;span style="color:brown;"&gt;0 &lt;/span&gt;.. x &lt;span style="color:blue;"&gt;do &lt;/span&gt;retval.[i] &amp;lt;- i
    retval.[&lt;span style="color:brown;"&gt;0&lt;/span&gt;] &amp;lt;- &lt;span style="color:brown;"&gt;0
    &lt;/span&gt;retval.[&lt;span style="color:brown;"&gt;1&lt;/span&gt;] &amp;lt;- &lt;span style="color:brown;"&gt;0
    &lt;/span&gt;&lt;span style="color:blue;"&gt;for &lt;/span&gt;i &lt;span style="color:blue;"&gt;in &lt;/span&gt;&lt;span style="color:brown;"&gt;2 &lt;/span&gt;.. x &lt;span style="color:blue;"&gt;do
        if &lt;/span&gt;(i % &lt;span style="color:brown;"&gt;2 &lt;/span&gt;&amp;lt;&amp;gt; &lt;span style="color:brown;"&gt;0&lt;/span&gt;) &amp;amp;&amp;amp; retval.[i] &amp;lt;&amp;gt; &lt;span style="color:brown;"&gt;0 &lt;/span&gt;&lt;span style="color:blue;"&gt;then
            for &lt;/span&gt;j &lt;span style="color:blue;"&gt;in &lt;/span&gt;&lt;span style="color:brown;"&gt;2 &lt;/span&gt;* i .. i .. x &lt;span style="color:blue;"&gt;do
                &lt;/span&gt;retval.[j] &amp;lt;- &lt;span style="color:brown;"&gt;0

    &lt;/span&gt;retval |&amp;gt; Seq.filter(&lt;span style="color:blue;"&gt;fun &lt;/span&gt;x &lt;span style="color:blue;"&gt;-&amp;gt; &lt;/span&gt;x &amp;lt;&amp;gt; &lt;span style="color:brown;"&gt;0&lt;/span&gt;)

&lt;span style="color:blue;"&gt;let &lt;/span&gt;max = &lt;span style="color:brown;"&gt;5000000
&lt;/span&gt;&lt;span style="color:blue;"&gt;let &lt;/span&gt;sumofprimes =  sieveOfEratosthenes max |&amp;gt; Seq.map( &lt;span style="color:blue;"&gt;fun &lt;/span&gt;x &lt;span style="color:blue;"&gt;-&amp;gt; &lt;/span&gt;int64 x) |&amp;gt; Seq.sum&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=54649" width="1" height="1"&gt;</content><author><name>sseely</name><uri>http://devlicio.us/members/sseely/default.aspx</uri></author><category term="F#" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/F_2300_/default.aspx" /><category term=".NET" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/.NET/default.aspx" /><category term="VS 2010" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/VS+2010/default.aspx" /></entry><entry><title>Greatest Prime Factor in F#</title><link rel="alternate" type="text/html" href="/blogs/scott_seely/archive/2009/12/16/greatest-prime-factor-in-f.aspx" /><id>/blogs/scott_seely/archive/2009/12/16/greatest-prime-factor-in-f.aspx</id><published>2009-12-17T00:00:00Z</published><updated>2009-12-17T00:00:00Z</updated><content type="html">&lt;p&gt;Today I was reading an article in The Onion, &lt;a target="_blank" href="http://www.theonion.com/content/infograph/conquerors_you_may_have"&gt;Conquerors You May Have Missed&lt;/a&gt;,&amp;nbsp; and noticed that the number for the ant looked like it might be a big old prime, or at least have a large prime divisor. (For reference, the ant is # 43,168,974,563,247.) There are a number of algorithms for finding this answer, but my favorite is a little brute force algorithm that keeps dividing the big number by some other value until the two numbers are equal. Yes, I know I can short circuit a bunch of testing via a square root function, but BigInteger doesn&amp;rsquo;t have a sqrt function (yet&amp;hellip;). &lt;/p&gt;
&lt;p&gt;Anyhow, I cobbled this together and it worked right out of the gate:&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;let rec &lt;/span&gt;largestFactor x y = 
    &lt;span style="color:blue;"&gt;if &lt;/span&gt;(x = y) &lt;span style="color:blue;"&gt;then &lt;/span&gt;y
    &lt;span style="color:blue;"&gt;else
        let &lt;/span&gt;z = x % y
        &lt;span style="color:blue;"&gt;if &lt;/span&gt;z = &lt;span style="color:brown;"&gt;0I &lt;/span&gt;&lt;span style="color:blue;"&gt;then &lt;/span&gt;largestFactor (x/y) y
        &lt;span style="color:blue;"&gt;else &lt;/span&gt;largestFactor x (y + &lt;span style="color:brown;"&gt;1I&lt;/span&gt;)

&lt;span style="color:blue;"&gt;let &lt;/span&gt;LargestPrime x = largestFactor x &lt;span style="color:brown;"&gt;2I

&lt;/span&gt;&lt;span style="color:blue;"&gt;let &lt;/span&gt;a = LargestPrime &lt;span style="color:brown;"&gt;43168974563247I

&lt;/span&gt;printf &lt;span style="color:maroon;"&gt;&amp;quot;%A&amp;quot; &lt;/span&gt;a&lt;/pre&gt;
&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Answer: 84,826,177&lt;/p&gt;
&lt;p&gt;So, the number isn&amp;rsquo;t prime, but the largest prime factor is pretty big! And, writing up the code to figure out the answer itself was pretty simple. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=54579" width="1" height="1"&gt;</content><author><name>sseely</name><uri>http://devlicio.us/members/sseely/default.aspx</uri></author><category term="F#" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/F_2300_/default.aspx" /><category term=".NET" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/.NET/default.aspx" /></entry><entry><title>Slides and Code from Chicago Alt.NET meeting</title><link rel="alternate" type="text/html" href="/blogs/scott_seely/archive/2009/11/12/slides-and-code-from-chicago-alt-net-meeting.aspx" /><id>/blogs/scott_seely/archive/2009/11/12/slides-and-code-from-chicago-alt-net-meeting.aspx</id><published>2009-11-12T15:00:00Z</published><updated>2009-11-12T15:00:00Z</updated><content type="html">&lt;p&gt;I want to say thanks to everyone who came out to watch me speak about OpenSocial at the Chicago Alt.NET meeting. Thanks for inviting me to present and for making the time so enjoyable. I’ve posted the slides and the code for the Canvas page &lt;a href="http://www.scottseely.com/downloads/OpenSocialAltNet.zip" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=53675" width="1" height="1"&gt;</content><author><name>sseely</name><uri>http://devlicio.us/members/sseely/default.aspx</uri></author><category term="OpenSocial" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/OpenSocial/default.aspx" /><category term="JavaScript" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/JavaScript/default.aspx" /></entry><entry><title>Speaking at Chicago Alt.Net Meeting</title><link rel="alternate" type="text/html" href="/blogs/scott_seely/archive/2009/11/09/speaking-at-chicago-alt-net-meeting.aspx" /><id>/blogs/scott_seely/archive/2009/11/09/speaking-at-chicago-alt-net-meeting.aspx</id><published>2009-11-10T02:25:00Z</published><updated>2009-11-10T02:25:00Z</updated><content type="html">&lt;p&gt;This month, I&amp;rsquo;ll be speaking at the Chicago Alt.Net user group meeting. Please check out the details &lt;a target="_blank" href="http://chicagoalt.net/event/November2009Meeting-BuildingOpenSocialApplications"&gt;here&lt;/a&gt; and register &lt;a target="_blank" href="http://altnetchicago-groupsite.eventbrite.com/"&gt;here&lt;/a&gt;. And, here is the blurb on the talk:&lt;/p&gt;
&lt;h4&gt;November 2009 Meeting&lt;/h4&gt;
&lt;h5&gt;Building OpenSocial Applications&lt;/h5&gt;
&lt;p&gt;6:00 pm &lt;br /&gt;Pizza and networking time &lt;/p&gt;
&lt;p&gt;6:30 pm&lt;/p&gt;
&lt;p&gt;From its &lt;a href="http://www.opensocial.org/"&gt;official web site&lt;/a&gt;: &lt;/p&gt;
&lt;blockquote&gt;&lt;i&gt;Friends are fun, but they&amp;#39;re only on some websites. &lt;b&gt;OpenSocial&lt;/b&gt; helps these sites share their social data with the web. Applications that use the OpenSocial APIs can be embedded within a social network itself, or access a site&amp;#39;s social data from anywhere on the web.&lt;/i&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;img src="http://chicagoalt.net/content/images/events/opensocial.png" align="right" alt="" /&gt; &lt;a href="http://www.opensocial.org/"&gt;OpenSocial&lt;/a&gt; is the platform that &lt;a href="http://myspace.com/"&gt;MySpace&lt;/a&gt;, &lt;a href="http://orkut.com/"&gt;Orkut&lt;/a&gt;, &lt;a href="http://ning.com/"&gt;Ning&lt;/a&gt;, &lt;a href="http://LinkedIn.com/"&gt;LinkedIn&lt;/a&gt;, &lt;a href="http://Hi5.com/"&gt;Hi5&lt;/a&gt;, and pretty much every social network but Facebook supports for creating games and other applications that run on these social network sites. &lt;/p&gt;
&lt;p&gt;In this talk, we focus on the MySpace platform and how one builds a MySpace application. This involves interacting with the OpenSocial JavaScript as well as receiving and sending OpenSocial requests on your own servers. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=53599" width="1" height="1"&gt;</content><author><name>sseely</name><uri>http://devlicio.us/members/sseely/default.aspx</uri></author></entry><entry><title>Iowa Code Camp November 2009 Slides Up</title><link rel="alternate" type="text/html" href="/blogs/scott_seely/archive/2009/11/07/iowa-code-camp-november-2009-slides-up.aspx" /><id>/blogs/scott_seely/archive/2009/11/07/iowa-code-camp-november-2009-slides-up.aspx</id><published>2009-11-08T00:39:00Z</published><updated>2009-11-08T00:39:00Z</updated><content type="html">&lt;p&gt;I want to send out a big thank you to the team who put together the &lt;a target="_blank" href="http://iowacodecamp.com/"&gt;Iowa Code Camp&lt;/a&gt;. You people did an awesome job!!! I had a great time giving my talks and really enjoyed hanging out with the crowd in Iowa.&lt;/p&gt;
&lt;p&gt;For those of you who attended my talks, or just want to see the materials, I&amp;rsquo;ve posted things.&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://www.scottseely.com/downloads/IowaCC.WCF.zip"&gt;WCF Diagnostics Talk and Materials&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://www.scottseely.com/downloads/IowaCC.WinDBG.zip"&gt;WinDBG Talk and Materials&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;See you next year&amp;hellip;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=53499" width="1" height="1"&gt;</content><author><name>sseely</name><uri>http://devlicio.us/members/sseely/default.aspx</uri></author><category term="WCF" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/WCF/default.aspx" /><category term="WinDBG" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/WinDBG/default.aspx" /></entry><entry><title>Speaking at nPlus1 ArcSummit- Chicago</title><link rel="alternate" type="text/html" href="/blogs/scott_seely/archive/2009/11/02/speaking-at-nplus1-arcsummit-chicago.aspx" /><id>/blogs/scott_seely/archive/2009/11/02/speaking-at-nplus1-arcsummit-chicago.aspx</id><published>2009-11-02T13:18:00Z</published><updated>2009-11-02T13:18:00Z</updated><content type="html">&lt;p&gt;On December 7, I&amp;rsquo;ll be speaking at the nPlus1 ArcSummit for the optional morning session. I&amp;rsquo;d love to see the place packed! Here are the details:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.clicktoattend.com/invitation.aspx?code=142763"&gt;https://www.clicktoattend.com/invitation.aspx?code=142763&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;About nPlus1.org&lt;/h3&gt;
&lt;p&gt;nPlus1.org is a site dedicated to helping Architects, aspiring Architects and Lead Developers learn, connect and contribute. On this site you&amp;rsquo;ll have access to great first party content written by some of the most skilled and experienced Architects working today. You&amp;rsquo;ll also have access to, and be able to contribute to a nexus of content from around the Internet aimed at keeping Architects up to date on all the new developments in their fields of interest.&lt;/p&gt;
&lt;h4&gt;When&lt;/h4&gt;
&lt;p&gt;Monday December 7, 2009 &amp;ndash; 10:00PM to 5:00PM&lt;/p&gt;
&lt;h4&gt;Where&lt;/h4&gt;
&lt;p&gt;Microsoft MTC - Aon Center&lt;/p&gt;
&lt;p&gt;200 E. Randolph&lt;/p&gt;
&lt;p&gt;Suite 200&lt;/p&gt;
&lt;p&gt;Chicago, IL 60601&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.clicktoattend.com/directions.aspx?code=142763"&gt;driving directions&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Free Lunch Provided&lt;/b&gt;&lt;/p&gt;
&lt;h4&gt;Agenda&lt;/h4&gt;
&lt;h5&gt;Morning Session (Optional): An Introduction to Object Oriented Programming &lt;/h5&gt;
&lt;p&gt;10:00 AM - 12:00 PM&lt;/p&gt;
&lt;p&gt;Are you new to OOP? Do you want a refresher on the benefits of Interfaces and the differences between implements and extends? The morning session is a two hour introductory course of Object Oriented Programming. If you are new to OOP the lessons in this session will prepare you for the more advanced topics in the afternoon.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;If you are already well versed in OOP then feel free to come have a refresher, or simply join us for lunch and the advanced sessions in the afternoon. The morning session is completely optional.&lt;/i&gt;&lt;/p&gt;
&lt;h5&gt;Afternoon sessions:&lt;/h5&gt;
&lt;h5&gt;Session One: Software Patterns&lt;/h5&gt;
&lt;p&gt;Patterns are an important tool to use as architects and developers. They provide a common vocabulary for us to design with, as well as a common approach to a common problem. Come learn about useful patterns, and how to use them in your everyday code.&lt;/p&gt;
&lt;h5&gt;Session Two: How I Learned To Love Dependency Injection &lt;/h5&gt;
&lt;p&gt;Dependency Injection is one of those scary topics that most developers avoid. It sounds all &amp;lsquo;high-falootin&amp;rsquo; and complex. It&amp;rsquo;s not. Really. We wouldn&amp;rsquo;t lie. It&amp;rsquo;s a great way to manage complexity in your system, and a great way to make your system so much more testable. And isn&amp;rsquo;t that what we all want? &lt;/p&gt;
&lt;p&gt;Each session will be followed by open discussions periods.&lt;/p&gt;
&lt;p&gt;A catered lunch will be provided starting at noon. This will divide the morning introductory sessions from the advanced sessions. Register once for all session and choose to attend the morning, the afternoon or both! Lunch is provided for attendees for any of the sessions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=53317" width="1" height="1"&gt;</content><author><name>sseely</name><uri>http://devlicio.us/members/sseely/default.aspx</uri></author></entry><entry><title>Lambdas aren’t just for managed code</title><link rel="alternate" type="text/html" href="/blogs/scott_seely/archive/2009/10/21/lambdas-aren-t-just-for-managed-code.aspx" /><id>/blogs/scott_seely/archive/2009/10/21/lambdas-aren-t-just-for-managed-code.aspx</id><published>2009-10-21T23:50:29Z</published><updated>2009-10-21T23:50:29Z</updated><content type="html">&lt;p&gt;A long time ago, I was a C++ developer. I actually thought of myself as a pretty darn good C++ developer and got way too excited when I finally got to meet folks like Scott Meyers and actually landed a job working with Bobby Schmidt—same team on MSDN. (If you know Bobby’s name, well, you were pretty deep into C++ circa 1999.) Then, like many C++ devs, I moved over to a garbage collected language. I’ve done more than my fair share of professional .NET and Java development. C++ has been left by the wayside. Today, I finally downloaded and installed Visual Studio 2010 Beta 2. I dug into the “What’s New” and, out of curiosity, decided to look at C++ first (I already know about many of the C# and VB changes). I saw two cool things:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;C++ now has an auto keyword. For you C# devs, it is pretty much the same as the C# var keyword. &lt;/li&gt;    &lt;li&gt;C++ has lambdas. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Now, I’m only a little ways into understanding C++ lambdas, so some of my information here may be suspect. The C++ lambda is just an anonymous function. You can pass variables into the function so that the variable is visible within the function. The syntax is:&lt;/p&gt;  &lt;p&gt;[ &lt;em&gt;list of variables from current scope to pass into lambda scope&lt;/em&gt; ] &lt;em&gt;return-type&lt;/em&gt;( &lt;em&gt;function signature&lt;/em&gt; ) { &lt;em&gt;code&lt;/em&gt; }&lt;/p&gt;  &lt;p&gt;The canonical example appears to be std::for_each from &amp;lt;algorithm&amp;gt;. &lt;/p&gt; &lt;code&gt;   &lt;p&gt;#include &amp;quot;stdafx.h&amp;quot;      &lt;br /&gt;#include &amp;lt;iostream&amp;gt;       &lt;br /&gt;#include &amp;lt;algorithm&amp;gt;       &lt;br /&gt;#include &amp;lt;vector&amp;gt;       &lt;br /&gt;using namespace std; &lt;/p&gt;    &lt;p&gt;int _tmain(int argc, _TCHAR* argv[])      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; vector&amp;lt;int&amp;gt; myints;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; for (auto i = 0; i &amp;lt; 10; ++i){       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; myints.push_back(i);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; auto number = 0;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; auto numSquared = 0;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; for_each(myints.begin(), myints.end(), [&amp;amp;number, &amp;amp;numSquared](int n) {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cout &amp;lt;&amp;lt; n &amp;lt;&amp;lt; endl;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; number += n;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; numSquared += n * n;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; });       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; cout &amp;lt;&amp;lt; &amp;quot;The sum is &amp;quot; &amp;lt;&amp;lt; number &amp;lt;&amp;lt; endl;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; cout &amp;lt;&amp;lt; &amp;quot;The sum of the squares is &amp;quot; &amp;lt;&amp;lt; numSquared &amp;lt;&amp;lt; endl;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return 0;       &lt;br /&gt;}&lt;/p&gt; &lt;/code&gt;  &lt;p&gt;In this example, I have two values: number and numSquared. I make references of the value visible to the lambda, which prints out each value as it comes through and then sums the numbers and their squares. Once the function completes, the code emits the values to the console window. If you don’t want to pass anything to the lambda, you still need to state this. If I didn’t want number or numSquared visible, the lambda signature would be:&lt;/p&gt; &lt;code&gt;   &lt;p&gt;[](int n){}&lt;/p&gt; &lt;/code&gt;  &lt;p&gt;At some point, I’ll dig in and see what else this is good for, including how to build my own Functor signatures. Anyhow, just thought I’d share this little nugget with you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=52899" width="1" height="1"&gt;</content><author><name>sseely</name><uri>http://devlicio.us/members/sseely/default.aspx</uri></author><category term="C++" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/C_2B002B00_/default.aspx" /><category term="VS 2010" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/VS+2010/default.aspx" /></entry><entry><title>New F#/WCF Article up at InformIT</title><link rel="alternate" type="text/html" href="/blogs/scott_seely/archive/2009/09/30/new-f-wcf-article-up-at-informit.aspx" /><id>/blogs/scott_seely/archive/2009/09/30/new-f-wcf-article-up-at-informit.aspx</id><published>2009-09-30T19:10:00Z</published><updated>2009-09-30T19:10:00Z</updated><content type="html">&lt;p&gt;My article on programming REST services with F# and WCF went up at InformIT. Please go read it! &lt;a href="http://www.informit.com/articles/article.aspx?p=1394625" title="http://www.informit.com/articles/article.aspx?p=1394625"&gt;http://www.informit.com/articles/article.aspx?p=1394625&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=51921" width="1" height="1"&gt;</content><author><name>sseely</name><uri>http://devlicio.us/members/sseely/default.aspx</uri></author><category term="WCF" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/WCF/default.aspx" /><category term="F#" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/F_2300_/default.aspx" /><category term=".NET" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/.NET/default.aspx" /></entry><entry><title>Review of ANTS Memory Profiler</title><link rel="alternate" type="text/html" href="/blogs/scott_seely/archive/2009/08/23/review-of-ants-memory-profiler.aspx" /><id>/blogs/scott_seely/archive/2009/08/23/review-of-ants-memory-profiler.aspx</id><published>2009-08-23T16:05:00Z</published><updated>2009-08-23T16:05:00Z</updated><content type="html">&lt;p&gt;&lt;strong&gt;Quick Summary&lt;/strong&gt;: Highly recommended! This is a big time saver over WinDBG/SOS/CLRProfiler. Either combination will get the job done, but you will complete simple tasks in significantly less time if you choose ANTS Memory Profiler. &lt;/p&gt;
&lt;h2&gt;The review&lt;/h2&gt;
&lt;p&gt;Our sponsors over at Red Gate Software released a new version of their &lt;a target="_blank" href="http://www.red-gate.com/products/ants_memory_profiler/index.htm"&gt;Memory Profiler&lt;/a&gt; and asked devlicio.us to give it a spin and write up a review. I had never used the tool before, but I have used the standard Microsoft tools to troubleshoot memory issues. My biggest concern with the Red Gate product is not whether it works but if it is worth the price in terms of time saved and productivity. With a list price of US$495 for the standalone product or US$795 for the &lt;a target="_blank" href="http://www.red-gate.com/products/dotnet_tools_overview.htm"&gt;.NET Bundle&lt;/a&gt;, it needs to save a lot of time to be worth the money. To get a feel for how it compares to the Microsoft solution, I decided to run &lt;a target="_blank" href="http://blogs.msdn.com/tess/"&gt;Tess Ferrandez&lt;/a&gt;&amp;rsquo;s &lt;a target="_blank" href="http://blogs.msdn.com/tess/pages/net-debugging-demos-information-and-setup-instructions.aspx"&gt;.NET Debugging labs 3 and 6&lt;/a&gt; against the Red Gate Memory Profiler. In my evaluation, I&amp;rsquo;m mostly interested in seeing if I can get to all the data and find the planted bugs without spinning up WinDBG + the SOS CLR extension, AdPlus, and all those other tools. &lt;/p&gt;
&lt;h3&gt;Setup&lt;/h3&gt;
&lt;p&gt;My test system is a Dell Studio XPS M13 with 4GB RAM running Windows 7 Ultimate x64.&lt;/p&gt;
&lt;p&gt;I installed the &lt;a target="_blank" href="https://www.red-gate.com/dynamic/downloads/downloadform.aspx?download=.netdeveloperbundle"&gt;14 day trial of the .NET Bundle&lt;/a&gt;. When you download, you will get an email from someone at Red Gate asking how they can help you with your evaluation and reminding you that there are demos and exercises to learn the tool at the bottom of the &lt;a target="_blank" href="http://www.red-gate.com/products/ants_memory_profiler/index.htm"&gt;Memory Profiler home page&lt;/a&gt;. I then ran through the demos and labs to get familiar with how the Memory Profiler tool works. &lt;/p&gt;
&lt;p&gt;To recreate the problem scenarios, I used Tinyget from the &lt;a target="_blank" href="http://support.microsoft.com/kb/840671"&gt;IIS 6.0 Resource Kit Tools&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;For setup, I grabbed the &lt;a target="_blank" href="http://blogs.msdn.com/tess/attachment/7431454.ashx"&gt;BuggyBits.zip&lt;/a&gt; file and unzipped it into c:\inetput\wwwroot\BuggyBits. I then opened up Internet Information Services (IIS) Manager, navigated to and right-clicked on the BuggyBits folder, and selected Convert to Application. &lt;/p&gt;
&lt;h3&gt;Debugging &lt;a target="_blank" href="http://blogs.msdn.com/tess/archive/2008/02/15/net-debugging-demos-lab-3-memory.aspx"&gt;.NET Debugging Demos Lab 3: Memory&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This lab stresses a web site and causes a high memory situation. The lab has a simple goal: figure out what caused the issue memory leak. I setup the Memory Profiler to run the BuggyBits application. One thing I ran into was that the profiler won&amp;rsquo;t actually start profiling until you navigate to another page in the IIS application. For BuggyBits, this meant navigating to http://localhost/BuggyBits/Links.aspx in order to start profiling. I then followed these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Take Memory Snapshot &lt;/li&gt;
&lt;li&gt;From a command line, ran tinyget -srv:localhost -uri:/BuggyBits/Links.aspx -loop:400 &lt;/li&gt;
&lt;li&gt;Took another Memory Snapshot &lt;/li&gt;
&lt;li&gt;Started my investigation &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I did find that if I ran the application in a loop of 4000 items, Memory Profiler ran into memory issues during the investigation. That said, it was easy enough to do the troubleshooting with a smaller repro case. &lt;/p&gt;
&lt;p&gt;The first screen I saw after taking the second snapshot is this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/lab3snapshot_5F00_7FF885EC.png"&gt;&lt;img height="484" width="513" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/lab3snapshot_5F00_thumb_5F00_591A49DF.png" alt="lab3snapshot" border="0" title="lab3snapshot" style="border-right-width:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;From that, we can see that we have a lot of strings, but we also have two classes with very similar instance counts: StringBuilder and Link. StringBuilder is a .NET CLR type, but Link isn&amp;rsquo;t. From this same screen, we can also take a look at how many objects are on the Gen 0,1, and 2 heaps. Looking at the Gen 2 heap, we see a similar picture with 3505 Link objects on the heap. What is causing the number of Link objects to be so high? Looking at the source, we see a class with a finalizer declared&amp;mdash;the finalizer does some heavy work (simulated via Thread.Sleep):&lt;/p&gt;
&lt;div style="font-family:courier new;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;~Link()&lt;/p&gt;
&lt;p style="margin:0px;"&gt;{&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:green;"&gt;//some long running operation when cleaning up the data&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;Thread&lt;/span&gt;.Sleep(5000);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;At this point, we have a few things we can do to fix the code:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Eliminate the finalizer altogether. &lt;/li&gt;
&lt;li&gt;Implement IDisposable and make sure to explicitly Dispose any Link objects after they are used. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I tried both options, and saw that we stopped leaking Link onto any of the heaps. &lt;/p&gt;
&lt;p&gt;Discovery in this case was pretty simple as the first screen gave me enough data, via the increase in memory usage on the graph and the analysis to know what was going on as well as inform me if my changes helped. &lt;/p&gt;
&lt;h3&gt;Debugging &lt;a target="_blank" href="http://blogs.msdn.com/tess/archive/2008/03/17/net-debugging-demos-lab-6-memory-leak.aspx"&gt;.NET Debugging Demos Lab 6:_Memory Leak&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Another memory leak situation. I followed a similar setup to the previous example. Steps to gather data are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to http://localhost/BuggyBits/ProductInfo.aspx?ProductName=Bugspray &lt;/li&gt;
&lt;li&gt;Take Memory Snapshot &lt;/li&gt;
&lt;li&gt;From a command line, ran tinyget -srv:localhost -uri:/BuggyBits/ProductInfo.aspx?ProductName=Bugspray &amp;ndash;threads:50 -loop:20 &lt;/li&gt;
&lt;li&gt;Took another Memory Snapshot &lt;/li&gt;
&lt;li&gt;Started my investigation &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This time, I was greeted by the following summary:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/lab6snapshot1_5F00_3C8D3232.png"&gt;&lt;img height="484" width="513" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/lab6snapshot1_5F00_thumb_5F00_55E50F9F.png" alt="lab6snapshot-1" border="0" title="lab6snapshot-1" style="border-right-width:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto;" /&gt;&lt;/a&gt; A large growth in strings still isn&amp;rsquo;t interesting. This grows due to assemblies being loaded in between calls and is hard to pin as an issue. Looking at &amp;ldquo;Largest Growth in Instances&amp;rdquo;, I see that RuntimeType has grown by quite a bit. Let&amp;rsquo;s see why. I clicked on RuntimeType and saw this screen, showing me how the size had changed:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/lab6snapshot2_5F00_633AFCD8.png"&gt;&lt;img height="484" width="570" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/lab6snapshot2_5F00_thumb_5F00_4D60EEAE.png" alt="lab6snapshot-2" border="0" title="lab6snapshot-2" style="border-right-width:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto;" /&gt;&lt;/a&gt; I then selected the Class Reference Explorer and got a hint as to what is going on:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/lab6snapshot3_5F00_3237F9D3.png"&gt;&lt;img height="484" width="518" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/lab6snapshot3_5F00_thumb_5F00_2F429520.png" alt="lab6snapshot-3" border="0" title="lab6snapshot-3" style="border-right-width:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto;" /&gt;&lt;/a&gt;While it doesn&amp;rsquo;t consume much space, the big hint of System.Xml.Serialization.TypeDesc is enough of a hint that we might have a serialization issue. XmlSerialization generates new assemblies when certain constructors are run. One feature I particularly liked in this investigation was the ability to see what types of objects were holding onto the references of other types. Here is an example of the objects referring to our TypeDesc. &lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/lab6snapshot4_5F00_454900B2.png"&gt;&lt;img height="291" width="644" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/lab6snapshot4_5F00_thumb_5F00_03621B64.png" alt="lab6snapshot-4" border="0" title="lab6snapshot-4" style="border-right-width:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;From here, I looked for uses of XmlSerializer and sure enough, found one of the versions that doesn&amp;rsquo;t cache the serializer. DataLayer.cs contains these lines:&lt;/p&gt;
&lt;div style="font-family:courier new;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp; 118&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;Type&lt;/span&gt;[] extraTypes = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Type&lt;/span&gt;[1];&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp; 119&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; extraTypes[0] = &lt;span style="color:blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;ShippingInfo&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp; 120&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp; 121&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;MemoryStream&lt;/span&gt; ms = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MemoryStream&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp; 122&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;XmlSerializer&lt;/span&gt; xs = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;XmlSerializer&lt;/span&gt;(&lt;span style="color:blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;Product&lt;/span&gt;), extraTypes);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp; 123&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xs.Serialize(ms, p);&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;This is one of the constructors that creates a new assembly for every XmlSerializer instance. To fix the issue, one should cache the serializer. I did so by creating a static property on the DataLayer class:&lt;/p&gt;
&lt;div style="font-family:courier new;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;XmlSerializer&lt;/span&gt; _xs = &lt;span style="color:blue;"&gt;null&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:blue;"&gt;object&lt;/span&gt; _xsLock = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:blue;"&gt;object&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;XmlSerializer&lt;/span&gt; Serializer&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;get&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&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; (_xs == &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&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;lock&lt;/span&gt; (_xsLock)&lt;/p&gt;
&lt;p style="margin:0px;"&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;/p&gt;
&lt;p style="margin:0px;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;if&lt;/span&gt; (_xs == &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&lt;/p&gt;
&lt;p style="margin:0px;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;Type&lt;/span&gt;[] extraTypes = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Type&lt;/span&gt;[1];&lt;/p&gt;
&lt;p style="margin:0px;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; extraTypes[0] = &lt;span style="color:blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;ShippingInfo&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin:0px;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _xs = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;XmlSerializer&lt;/span&gt;(&lt;span style="color:blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;Product&lt;/span&gt;), extraTypes);&lt;/p&gt;
&lt;p style="margin:0px;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&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;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&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;return&lt;/span&gt; _xs;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;This sped up execution time and reduced the number of RuntimeType instances by 2,031.&lt;/p&gt;
&lt;h3&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/lab6snapshot5_5F00_287F65D0.png"&gt;&lt;img height="484" width="570" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/scott_5F00_seely/lab6snapshot5_5F00_thumb_5F00_2796DA19.png" alt="lab6snapshot-5" border="0" title="lab6snapshot-5" style="border-right-width:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto;" /&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;h3&gt;Other Impressions&lt;/h3&gt;
&lt;p&gt;Given the speed with which I could diagnose the above two issues, I was really impressed. I also loved the ability to dig around and see what classes were in use and track through object graphs. To get the same job done with the Microsoft SDK tools I would have to correlate information from WinDBG + SOS and from CLRProfiler. The fact that I could do all this drill down in one tool gave me a huge productivity boost. &lt;/p&gt;
&lt;p&gt;I did have some issues with using the profiler. I posted the issue to the Red Gate forum and had a resolution within a few days. It turned out due to the design of the Server Garbage Collector (the GC that runs on multi-core machines) has a behavior that may appear as memory corruption to a profiler. (You can read the forum thread &lt;a target="_blank" href="http://www.red-gate.com/MessageBoard/viewtopic.php?t=9421"&gt;here&lt;/a&gt;.) I had a few other interactions with Red Gate as well and found the company to be very responsive to my needs. Because of the way the tool presents information, I could see patterns quickly and fix the issues with ease. Thanks to the time saving properties, I heartily recommend buying at least one copy of the Memory Profiler for every dev team. This is something I will be using once per sprint to look for memory leaks. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=50429" width="1" height="1"&gt;</content><author><name>sseely</name><uri>http://devlicio.us/members/sseely/default.aspx</uri></author><category term="Tools" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/Tools/default.aspx" /><category term="Red Gate" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/Red+Gate/default.aspx" /><category term=".NET" scheme="http://devlicio.us/blogs/scott_seely/archive/tags/.NET/default.aspx" /></entry></feed>