<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Charlie Calvert's Community Blog</title><link>http://blogs.msdn.com/charlie/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Community Convergence LVII</title><link>http://blogs.msdn.com/charlie/archive/2009/11/16/community-convergence-lvii.aspx</link><pubDate>Mon, 16 Nov 2009 21:14:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9923162</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9923162.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9923162</wfw:commentRss><description>&lt;p&gt;Welcome to the fifty-seventh issue of Community Convergence. In this post I’ll focus on new articles from the C# team, as well as events taking place at &lt;a href="http://blogs.msdn.com/lucabol/archive/2009/11/13/luca-at-pdc-2009-next-week.aspx"&gt;PDC.&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;From the C# Team&lt;/h3&gt;  &lt;p&gt;&lt;strong&gt;Eric Lippert&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/ericlippert/archive/2009/11/12/closing-over-the-loop-variable-considered-harmful.aspx"&gt;Closing over the loop variable considered harmful&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/ericlippert/archive/2009/11/09/three-umpires.aspx"&gt;Three Umpires&lt;/a&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;(The Compiler Calls ‘em as it Sees ‘em) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/ericlippert/archive/2009/11/02/simple-names-are-not-so-simple.aspx"&gt;Simple names are not so simple&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/ericlippert/archive/2009/11/05/simple-names-are-not-so-simple-part-two.aspx"&gt;Simple names are not so simple, Part Two, plus, volcanoes and fried foods&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/ericlippert/archive/2009/10/29/i-have-a-fit-but-a-lack-of-focus.aspx"&gt;I have a Fit, but a lack of Focus.&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Kirill Osenkov&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/kirillosenkov/archive/2009/11/12/visual-studio-2010-beta-2-known-issues-part-2.aspx"&gt;Visual Studio 2010 Beta 2 Known Issues – Part 2&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/kirillosenkov/archive/2009/11/04/a-million-dollar-pen-vs-a-pencil.aspx"&gt;A million-dollar pen vs. a pencil&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/kirillosenkov/archive/2009/11/01/bezier-curves-and-car-manufacturers.aspx"&gt;Bezier Curves and Car Manufacturers&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/kirillosenkov/archive/2009/10/31/irony.aspx"&gt;Irony&lt;/a&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;(.NET compiler construction framework) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Luca Bolognese&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/lucabol/archive/2009/11/13/luca-at-pdc-2009-next-week.aspx"&gt;Luca at PDC 2009 next week&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Dustin Campbell&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://diditwith.net/2009/10/24/NamingAnonymousTypesWithGenerateFromUsage.aspx"&gt;Naming Anonymous Types with Generate from Usage&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Sam Ng&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/samng/archive/2009/11/03/com-interop-in-c-4-0-indexed-properties.aspx"&gt;Com Interop in C# 4.0: Indexed Properties&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/samng/archive/2009/11/03/channel-9-dynamic-in-c.aspx"&gt;Channel 9: Dynamic in C#&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Charlie Calvert&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/11/14/videos-azure-services-in-visual-studio-2010-beta-2-with-jim-nakashima.aspx"&gt;Videos: Azure Services in Visual Studio 2010 Beta 2 with Jim Nakashima, Part I&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/11/15/video-azure-services-in-visual-studio-beta-2-part-ii.aspx"&gt;Video: Azure Services in Visual Studio Beta 2, Part II&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/11/16/video-azure-services-in-visual-studio-2010-beta-2-part-iii.aspx"&gt;Video: Azure Services in Visual Studio 2010 Beta 2, Part III&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/11/10/microsoft-sdk-for-facebook-released.aspx"&gt;Microsoft SDK for Facebook Released&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/11/07/hdi-video-generate-from-usage-with-karen-liu.aspx"&gt;HDI Video: Generate from Usage in Visual Studio 2010 with Karen Liu&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/11/06/new-msdn-library-views.aspx"&gt;Classic, Lightweight and ScriptFree MSDN Library Views&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/11/03/new-article-by-bill-wagner-on-dynamic-method-bags.aspx"&gt;New Article by Bill Wagner on Dynamic Method Bags in C# 4.0&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/11/02/new-article-on-detecting-memory-leaks-net-applications.aspx"&gt;New Article on Detecting Memory Leaks . NET Applications&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/11/01/csharp-how-do-i-videos-for-the-zune-software.aspx"&gt;CSharp “How Do I Videos (Podcasts)” for the Zune Software&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/10/29/visual-studio-2010-beta-2-does-not-load-the-application-cannot-start-and-raster-fonts-errors.aspx"&gt;Visual Studio 2010 Beta 2 does not Load: The “Application Cannot Start” and Raster Font Errors&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/10/25/hosting-ironpython-in-a-c-4-0-program.aspx"&gt;Running IronPython Scripts from a C# 4.0 Program&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/10/25/running-ironpython.aspx"&gt;Getting Started with IronPython&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/10/22/new-videos-on-sharepoint-and-c-by-kathleen-mcgrath.aspx"&gt;New Video on Sharepoint and C# by Kathleen McGrath&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/10/22/ironruby-and-ironpython-for-net-4-0-beta-2-available.aspx"&gt;IronRuby and IronPython for .NET 4.0 Beta 2 Available&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;From others at Microsoft&lt;/h3&gt;  &lt;p&gt;&lt;strong&gt;Mitsu&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/mitsu/archive/2009/11/13/read-write-selector-in-c-3-then-c-4.aspx"&gt;Read/Write selector in C# 3 then C# 4&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Jason Zander&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/jasonz/archive/2009/11/09/announced-at-teched-europe-teamprise-client-suite-acquisition.aspx"&gt;Announced at TechEd Europe, Teamprise Client Suite Acquisition&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/jasonz/archive/2009/10/29/vs2010-beta-2-feedback-survey.aspx"&gt;VS2010 Beta 2 Feedback Survey&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/jasonz/archive/2009/10/21/tutorial-getting-started-with-tfs-in-vs2010.aspx"&gt;Tutorial: Getting Started with TFS in VS2010&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Scott Guthrie&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2009/10/29/add-reference-dialog-improvements-vs-2010-and-net-4-0-series.aspx"&gt;Add Reference Dialog Improvements (VS 2010 and .NET 4.0 Series)&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2009/10/26/wpf-4-vs-2010-and-net-4-0-series.aspx"&gt;WPF 4 (VS 2010 and .NET 4.0 Series)&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2009/10/22/vs-2010-code-intellisense-improvements-vs-2010-and-net-4-0-series.aspx"&gt;VS 2010 Code Intellisense Improvements (VS 2010 and .NET 4.0 Series)&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2009/10/21/searching-and-navigating-code-in-vs-2010-vs-2010-and-net-4-0-series.aspx"&gt;Searching and Navigating Code in VS 2010 (VS 2010 and .NET 4.0 Series)&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Scott Hanselman&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://feedproxy.google.com/~r/ScottHanselman/~3/7gprmpbsbS0/DownloadPodcastsWithPowershell.aspx"&gt;Download Podcasts with Powershell&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://feedproxy.google.com/~r/ScottHanselman/~3/-sPcg8aSXEk/HerdingCatsOrganizeYourDesktopIconsWithStardockFencesForWindows.aspx"&gt;Herding Cats: Organize your Desktop Icons with Stardock Fences for Windows&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://feedproxy.google.com/~r/ScottHanselman/~3/8w59yqf_eEo/Oredev2009LIVENowRecordedClosingPanelVideo.aspx"&gt;Oredev 2009 - LIVE (now recorded) Closing Panel Video&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://feedproxy.google.com/~r/ScottHanselman/~3/NM-VgzLgdWo/HanselminutesOn9DebuggingCrashDumpsWithTessFerrandezAndVS2010.aspx"&gt;Hanselminutes on 9 - Debugging Crash Dumps with Tess Ferrandez and VS2010&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://feedproxy.google.com/~r/ScottHanselman/~3/lKMS3cs9ENo/OfflineInstallerForWindowsLiveEssentialsWLSetupAllexe.aspx"&gt;Offline installer for Windows Live Essentials - WLSetup-All.exe&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://feedproxy.google.com/~r/ScottHanselman/~3/LvvrDb-wH6U/UsingABluetoothJawboneHeadsetForBTAudioMicrophoneOrSpeakersOnWindows7.aspx"&gt;Using a Bluetooth Jawbone Headset for BT-Audio (Microphone or Speakers) on Windows 7&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://feedproxy.google.com/~r/ScottHanselman/~3/dWlpstCubFE/Windows7WithBitLockerAndStillBootingToVHD.aspx"&gt;Windows 7 with BitLocker and Still Booting To VHD&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Brad Abrams&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/brada/archive/2009/10/28/lightweight-linq-parser.aspx"&gt;Lightweight LINQ Parser&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/brada/archive/2009/10/27/index-for-business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update.aspx"&gt;Index for Business Apps Example for Silverlight 3 RTM and .NET RIA Services July Update&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Dan Fernandez&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/danielfe/archive/2009/10/27/visual-studio-documentary-part-1-part-2.aspx"&gt;Visual Studio Documentary Part 1 &amp;amp; Part 2&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/danielfe/archive/2009/10/21/download-visual-studio-2010-express-editions.aspx"&gt;Download Visual Studio 2010 Express Editions&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Downloads and Announcements&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a title="http://silverlight.net/riaservices/" href="http://silverlight.net/riaservices/"&gt;New site dedicated to the Rich Internet Application (RIA) tools for Silverlight from Microsoft&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/msdnmagazine/archive/2009/11/13/9921692.aspx"&gt;A Tentative Content Plan for MSDN Magazine in 2010&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f16%2fcommunity-convergence-lvii.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f16%2fcommunity-convergence-lvii.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9923162" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Community+Convergence/default.aspx">Community Convergence</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx">C# 4.0</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Conferences/default.aspx">Conferences</category></item><item><title>Video: Azure Services in Visual Studio 2010 Beta 2, Part III</title><link>http://blogs.msdn.com/charlie/archive/2009/11/16/video-azure-services-in-visual-studio-2010-beta-2-part-iii.aspx</link><pubDate>Mon, 16 Nov 2009 16:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9922644</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9922644.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9922644</wfw:commentRss><description>&lt;p&gt;This is the first of three videos showing how Visual Studio 2010 Beta 2 provides support for the development and deployment of Azure Services applications. In these short How Do I Videos, I filmed Jim Nakashima as he demonstrated practical techniques for quickly deploying applications to the cloud. These videos will eventually be published in the &lt;a href="http://msdn.microsoft.com/en-us/vcsharp/bb798022.aspx"&gt;How Do I&lt;/a&gt; section of the &lt;a href="http://msdn.microsoft.com/en-us/vcsharp/default.aspx"&gt;C# Dev Center&lt;/a&gt;. I’m hosting them here for now, so that they will be available in time for PDC.&lt;/p&gt;  &lt;h2&gt;Azure Services in Visual Studio Part III&lt;/h2&gt; &lt;iframe style="width: 500px; height: 375px" src="http://silverlight.services.live.com/invoke/14488/Azure%20Services%20with%20Visual%20Studio%20Part%20III/iframe.html" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;  &lt;h2&gt;&amp;#160;&lt;/h2&gt;  &lt;h2&gt;Download the Videos&lt;/h2&gt;  &lt;p&gt;Click the links below to download the videos to your local machine and view them at their native 1024 X 768 resolution.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://silverlight.services.live.com/14488/Azure%20Services%20with%20Visual%20Studio%20Part%2001/video.wmv"&gt;Azure Services with Visual Studio Part I&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://silverlight.services.live.com/14488/Azure%20Services%20in%20Visual%20Studio%20Part%20II/video.wmv"&gt;Azure Services with Visual Studio Part II&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://silverlight.services.live.com/14488/Azure%20Services%20with%20Visual%20Studio%20Part%20III/video.wmv"&gt;Azure Services with Visual Studio Part III&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;Other Posts in this Series&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/11/14/videos-azure-services-in-visual-studio-2010-beta-2-with-jim-nakashima.aspx"&gt;Part I&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/11/15/video-azure-services-in-visual-studio-beta-2-part-ii.aspx"&gt;Part II&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f14%2fvideos-azure-services-in-visual-studio-2010-beta-2-with-jim-nakashima.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f14%2fvideos-azure-services-in-visual-studio-2010-beta-2-with-jim-nakashima.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9922644" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx">C# 4.0</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Azure/default.aspx">Azure</category></item><item><title>Video: Azure Services in Visual Studio Beta 2, Part II</title><link>http://blogs.msdn.com/charlie/archive/2009/11/15/video-azure-services-in-visual-studio-beta-2-part-ii.aspx</link><pubDate>Sun, 15 Nov 2009 16:10:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9922643</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9922643.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9922643</wfw:commentRss><description>&lt;p&gt;This is the second in a series of three videos showing how Visual Studio 2010 provides support for the development and deployment of Azure Services applications. In these short How Do I Videos, I filmed Jim Nakashima as he demonstrated practical techniques for quickly deploying applications to the cloud. These videos will eventually be published in the &lt;a href="http://msdn.microsoft.com/en-us/vcsharp/bb798022.aspx"&gt;How Do I&lt;/a&gt; section of the &lt;a href="http://msdn.microsoft.com/en-us/vcsharp/default.aspx"&gt;C# Dev Center&lt;/a&gt;. I’m hosting them here for now, so that they will be available in time for PDC.&lt;/p&gt;  &lt;h2&gt;Azure Services in Visual Studio Part II&lt;/h2&gt; &lt;iframe style="width: 500px; height: 375px" src="http://silverlight.services.live.com/invoke/14488/Azure%20Services%20in%20Visual%20Studio%20Part%20II/iframe.html" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;  &lt;h2&gt;&amp;#160;&lt;/h2&gt;  &lt;h2&gt;Download the Videos&lt;/h2&gt;  &lt;p&gt;Click the links below to download the videos to your local machine and view them at their native 1024 X 768 resolution.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://silverlight.services.live.com/14488/Azure%20Services%20with%20Visual%20Studio%20Part%2001/video.wmv"&gt;Azure Services with Visual Studio Part I&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://silverlight.services.live.com/14488/Azure%20Services%20in%20Visual%20Studio%20Part%20II/video.wmv"&gt;Azure Services with Visual Studio Part II&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://silverlight.services.live.com/14488/Azure%20Services%20with%20Visual%20Studio%20Part%20III/video.wmv"&gt;Azure Services with Visual Studio Part III&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;To see the post which embeds the first video in this series, click &lt;a href="http://blogs.msdn.com/charlie/archive/2009/11/14/videos-azure-services-in-visual-studio-2010-beta-2-with-jim-nakashima.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f14%2fvideos-azure-services-in-visual-studio-2010-beta-2-with-jim-nakashima.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f14%2fvideos-azure-services-in-visual-studio-2010-beta-2-with-jim-nakashima.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9922643" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx">C# 4.0</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Azure/default.aspx">Azure</category></item><item><title>Videos: Azure Services in Visual Studio 2010 Beta 2 with Jim Nakashima, Part I</title><link>http://blogs.msdn.com/charlie/archive/2009/11/14/videos-azure-services-in-visual-studio-2010-beta-2-with-jim-nakashima.aspx</link><pubDate>Sun, 15 Nov 2009 04:41:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9922571</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9922571.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9922571</wfw:commentRss><description>&lt;p&gt;This is the first of three videos showing how Visual Studio 2010 Beta 2 provides support for the development and deployment of Azure Services applications. In these short How Do I Videos, I filmed Jim Nakashima as he demonstrated practical techniques for quickly deploying applications to the cloud. These videos will eventually be published in the &lt;a href="http://msdn.microsoft.com/en-us/vcsharp/bb798022.aspx"&gt;How Do I&lt;/a&gt; section of the &lt;a href="http://msdn.microsoft.com/en-us/vcsharp/default.aspx"&gt;C# Dev Center&lt;/a&gt;. I’m hosting them here for now, so that they will be available in time for PDC.&lt;/p&gt;  &lt;h2&gt;Azure Servies in Visual Studio Part I&lt;/h2&gt; &lt;iframe style="width: 500px; height: 375px" src="http://silverlight.services.live.com/invoke/14488/Azure%20Services%20with%20Visual%20Studio%20Part%2001/iframe.html" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;  &lt;h2&gt;&amp;#160;&lt;/h2&gt;  &lt;h2&gt;Download the Videos&lt;/h2&gt;  &lt;p&gt;Click the links below to download the videos to your local machine and view them at their native 1024 X 768 resolution.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://silverlight.services.live.com/14488/Azure%20Services%20with%20Visual%20Studio%20Part%2001/video.wmv"&gt;Azure Services with Visual Studio Part I&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://silverlight.services.live.com/14488/Azure%20Services%20in%20Visual%20Studio%20Part%20II/video.wmv"&gt;Azure Services with Visual Studio Part II&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://silverlight.services.live.com/14488/Azure%20Services%20with%20Visual%20Studio%20Part%20III/video.wmv"&gt;Azure Services with Visual Studio Part III&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The second post in this series is available &lt;a href="http://blogs.msdn.com/charlie/archive/2009/11/15/video-azure-services-in-visual-studio-beta-2-part-ii.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f14%2fvideos-azure-services-in-visual-studio-2010-beta-2-with-jim-nakashima.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f14%2fvideos-azure-services-in-visual-studio-2010-beta-2-with-jim-nakashima.aspx" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9922571" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx">C# 4.0</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Azure/default.aspx">Azure</category></item><item><title>Microsoft SDK for Facebook Released</title><link>http://blogs.msdn.com/charlie/archive/2009/11/10/microsoft-sdk-for-facebook-released.aspx</link><pubDate>Wed, 11 Nov 2009 06:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9919179</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9919179.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9919179</wfw:commentRss><description>&lt;p&gt;Microsoft has created an SDK to make it easier for you to write Facebook applications.&lt;/p&gt;  &lt;h1&gt;Resources&lt;/h1&gt;  &lt;ul&gt;   &lt;li&gt;Read the &lt;a href="http://team.silverlight.net/announcement/announcing-the-new-microsoft-sdk-for-facebook-platform/"&gt;announcement&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;Find out more about the &lt;a href="http://www.microsoft.com/facebooksdk "&gt;.NET Facebook SDK&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f10%2fmicrosoft-sdk-for-facebook-released.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f10%2fmicrosoft-sdk-for-facebook-released.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9919179" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/Community/default.aspx">Community</category></item><item><title>HDI Video: Generate from Usage in Visual Studio 2010 with Karen Liu</title><link>http://blogs.msdn.com/charlie/archive/2009/11/07/hdi-video-generate-from-usage-with-karen-liu.aspx</link><pubDate>Sat, 07 Nov 2009 23:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9898211</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9898211.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9898211</wfw:commentRss><description>&lt;style type="text/css"&gt;




span.squiggle { color: red; text-decoration: underline;}
.listing { font-weight: bold }
.figure { font-weight: bold }
.note { font-weight: italic; background: lightgray; border: 1px solid black; }&lt;/style&gt;  &lt;p&gt;Karen Liu, the Lead Program Manager for the Visual C# and Visual Basic IDEs, has created a &lt;a href="http://msdn.microsoft.com/en-us/vcsharp/ee633445.aspx"&gt;new video&lt;/a&gt; on &lt;a href="http://msdn.microsoft.com/en-us/library/dd409796(VS.100).aspx"&gt;Generate from Usage&lt;/a&gt; (GFU), a feature found in Visual Studio 2010, Beta 2. This post recaps what is included in the video, including the sections that show how GFU can be used to enhance &lt;a href="http://www.extremeprogramming.org/rules/testfirst.html"&gt;test first development&lt;/a&gt;. The video is shot in both VB and C#. Since this is a C# blog, I’ll show only C# code, and will translate the VB code that Karen shows into C#.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Download the &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=8077"&gt;source code&lt;/a&gt; from the &lt;a href="http://code.msdn.microsoft.com/linqfarm"&gt;LINQ Farm&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Generate from Usage (GFU) is a new feature in 2010 that allows you to write code that consumes a library or API before that API even exists. Using Visual Studio menus or shortcuts, you can automatically generate classes, constructors, methods, fields and properties from the code you typed in the editor.&lt;/p&gt;  &lt;p&gt;As the video begins, Karen first types in the code to initialize a class called &lt;strong&gt;Automobile&lt;/strong&gt; that does not yet exist:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5cf3a3f0-6bee-4a46-8d17-8a5e29158786" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; myCar = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; Automobile(Make: &lt;span style="color:#a31515"&gt;&amp;quot;Honda&amp;quot;&lt;/span&gt;, Model: &lt;span style="color:#a31515"&gt;&amp;quot;Accord&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Notice that the class name &lt;strong&gt;Automobile&lt;/strong&gt; is &lt;u&gt;not&lt;/u&gt; colored in teal, which is Visual Studio’s way of telling you that it does not yet it exist. When seen inside Visual Studio, the word &lt;strong&gt;Automobile&lt;/strong&gt; will also have red squiggly (or wavy) underline, and a small blue&lt;strong&gt; smart tag &lt;/strong&gt;under the letter A, as shown in Figure 1. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure01_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure01" border="0" alt="Figure01" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure01_thumb.png" width="644" height="161" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p class="figure"&gt;Figure 1: The red squiggle is Visual Studio’s way of telling you that the type &lt;u&gt;Automobile&lt;/u&gt; will not compile. The blue &lt;em&gt;smart tag&lt;/em&gt; under the letter A let’s the user know that an expansion tip is available by simultaneously pressing the Control key and a period (Ctrl + .).&lt;/p&gt;  &lt;p&gt;The smart tag under the letter A is Visual Studio’s way of telling you to press the control and period keys to bring up a special expansion tip, as shown in Figure 2. Here we see two options, one for directly creating a class called &lt;strong&gt;Automobile&lt;/strong&gt;, and the other for bringing up a dialog which allows us to define or tweak the details of the type of we create.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure02_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure02" border="0" alt="Figure02" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure02_thumb.png" width="644" height="247" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p class="figure"&gt;Figure 2: Viewing an expansion tip in Visual Studio.&lt;/p&gt;  &lt;p&gt;You can also bring up the options to create a new class or type by right clicking on the word &lt;strong&gt;Automobile&lt;/strong&gt; and selecting &lt;strong&gt;Generate&lt;/strong&gt; from the popup menu, as shown in Figure 3.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure03_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure03" border="0" alt="Figure03" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure03_thumb.png" width="644" height="174" /&gt;&lt;/a&gt; &lt;/strong&gt;&lt;/p&gt;  &lt;p class="figure"&gt;Figure 3: A second way to generate a class is to right click the word &lt;u&gt;Automobile&lt;/u&gt; and choose &lt;u&gt;Generate &lt;/u&gt;from the popup menu.&lt;/p&gt;  &lt;p&gt;If you select the option to create a new class, then Visual Studio will automatically generate a new file called &lt;strong&gt;Automobile.cs&lt;/strong&gt; and place inside it a new class called &lt;strong&gt;Automobile&lt;/strong&gt;. The entire generated file is shown in Listing 1.&lt;/p&gt;  &lt;p class="listing"&gt;Listing 1: The code generate when you choose to create a new class based on an undefined identifier in Visual Studio 2010.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:51302077-3aa5-4dcb-94f7-45db8bcc830f" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Text;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; DeleteMe&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Automobile&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;You can now go back to your original source file where you will see that there is still a red squiggly and blue tool tip, as shown in Figure 4. These hints are shown because we have not yet created a constructor for the &lt;strong&gt;Automobile&lt;/strong&gt; class. If we again press control plus period, then the option to generate these code elements is made available to us, as shown in Figure 4.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure04_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure04" border="0" alt="Figure04" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure04_thumb_1.png" width="644" height="146" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p class="figure"&gt;Figure 4: Selecting the smart tag a second time brings up an option to automatically generate the constructor and associated fields for your class.&lt;/p&gt;  &lt;p&gt;The code that is generated by selecting the expansion tip is shown in Listing 2. Notice that on lines 10 and 11 fields were created for your class and on lines 16 and 17 code was generated inside the constructor for initializing them. A comment in the form of a &lt;strong&gt;TODO&lt;/strong&gt; item is also added to your class. These &lt;strong&gt;TODO&lt;/strong&gt; items are visible in the Visual Studio &lt;a href="http://msdn.microsoft.com/en-us/library/zce12xx2(VS.100).aspx"&gt;Task List&lt;/a&gt;. You can access the &lt;strong&gt;Task List &lt;/strong&gt;by choosing &lt;strong&gt;View | Task List &lt;/strong&gt;from the menu, or by pressing &lt;strong&gt;Ctrl+W, T&lt;/strong&gt;. Be sure to choose the &lt;strong&gt;Comments&lt;/strong&gt; option from the drop down at the top of the &lt;strong&gt;Task List&lt;/strong&gt;.&lt;/p&gt;  &lt;p class="listing"&gt;Listing 2: The code for the Automobile’s constructor is automatically generated by the IDE.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:39825868-2600-44c3-aca2-c3e2393bc188" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Text;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; GenerateFromUsageSample&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Automobile&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Make;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Model;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; Automobile(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Make, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Model)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#008000"&gt;// TODO: Complete member initialization&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;.Make = Make;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;.Model = Model;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Karen next types in code for a &lt;strong&gt;TurnLeft &lt;/strong&gt;method, and for a property called &lt;strong&gt;IsFacingNorth&lt;/strong&gt;. As she types each item, a smart tag appears, and again she has the option to press &lt;strong&gt;Ctrl+.&lt;/strong&gt; to automatically generate code for the &lt;strong&gt;Automobile &lt;/strong&gt;class. The code typed in the program’s entry point is shown in Listing 3, and the code generated by the IDE is shown mostly in Listing 4. Notice, however, that code for a private object called &lt;strong&gt;distance &lt;/strong&gt;was automatically generated in the &lt;strong&gt;Main&lt;/strong&gt; method. The IDE actually gives you the option to create either a &lt;strong&gt;private &lt;/strong&gt;field, as shown here, or a &lt;strong&gt;public&lt;/strong&gt; property.&lt;/p&gt;  &lt;p class="listing"&gt;Listing 3: The complete code for Karen’s first sample includes a constructor, a method called &lt;u&gt;TurnLeft&lt;/u&gt;, and a property called &lt;u&gt;IsFacingNorth&lt;/u&gt;.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:98dfe693-a81d-4df2-8435-00a22ea59678" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; GenerateFromUsage&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Program&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;object&lt;/span&gt; distance;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; Main(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;[] args)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; myCar = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Automobile&lt;/span&gt;(Make: &lt;span style="color:#a31515"&gt;&amp;quot;Honda&amp;quot;&lt;/span&gt;, Model: &lt;span style="color:#a31515"&gt;&amp;quot;Accord&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;myCar.TurnLeft(distance);&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;myCar.IsFacingNorth = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p class="listing"&gt;Listing 4: The code generated by the IDE for the TurnLeft method and the IsFacingNorth property.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f7d9d6bd-a681-4139-b84f-0468606a8287" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; GenerateFromUsage&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Automobile&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Make;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Model;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; Automobile(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Make, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Model)&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#008000"&gt;// TODO: Complete member initialization&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;.Make = Make;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;.Model = Model;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;internal&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; TurnLeft(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; distance)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;NotImplementedException&lt;/span&gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; IsFacingNorth { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;When looking at Listing 4, notice that code for generating a &lt;strong&gt;NotImplementedException &lt;/strong&gt;is automatically generated in the &lt;strong&gt;TurnLeft &lt;/strong&gt;method. The IDE was also smart enough to discern that the &lt;strong&gt;IsFacingNorth&lt;/strong&gt; property returns a &lt;strong&gt;bool&lt;/strong&gt;. All the lines of code shown in Listing 4 were generated by typing just three lines of code in the &lt;strong&gt;main &lt;/strong&gt;method found in Listing 3.&lt;/p&gt;  &lt;h2&gt;The C# Side&lt;/h2&gt;  &lt;p&gt;In the second part of the video Karen shows how you can use &lt;em&gt;generate from usage&lt;/em&gt; (GFU) to enhance your experience when creating unit tests. Many theorists advocate using a test first methodology in which you first create a test, and then write the code that you want to test. You will see that GFU can be used to make this style of development quite natural and simple to use inside of Visual Studio.&lt;/p&gt;  &lt;p class="note"&gt;NOTE: This section of the post requires high end versions of Visual Studio that contain the test wizards. Even if you don’t have those tools, you can still follow along to see how Generate from Usage can be used in all versions of Visual Studio to make it easier to create unit tests.&lt;/p&gt;  &lt;p&gt;Begin by starting a new console application called &lt;strong&gt;Customer&lt;/strong&gt;. Choose &lt;strong&gt;Tests | New Test &lt;/strong&gt;from the Visual Studio menu. Select &lt;strong&gt;Basic Unit Test&lt;/strong&gt; from the dialog, and name it &lt;strong&gt;Customers&lt;/strong&gt;, as shown in Figure 5. When you press &lt;strong&gt;OK &lt;/strong&gt;in the &lt;strong&gt;Add New Test &lt;/strong&gt;dialog you will be prompted for the name of your unit test project. Type in &lt;strong&gt;CustomerTests&lt;/strong&gt;. When you are done, the &lt;strong&gt;Solution Explorer&lt;/strong&gt; for your project should look as it does in Figure 6.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure06_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure06" border="0" alt="Figure06" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure06_thumb.png" width="577" height="484" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;  &lt;p class="figure"&gt;Figure 5: Create a new unit test project that will house a file called Customers.&lt;/p&gt;  &lt;p&gt;Right click on the &lt;strong&gt;Customer&lt;/strong&gt; node in the &lt;strong&gt;solution explorer&lt;/strong&gt; and choose &lt;strong&gt;Add | New Folder&lt;/strong&gt; to create a new directory called &lt;strong&gt;Models&lt;/strong&gt;. When you are done you should see a new node in the &lt;strong&gt;solution explorer&lt;/strong&gt;, as shown in Figure 6. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure07_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure07" border="0" alt="Figure07" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure07_thumb.png" width="315" height="386" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;  &lt;p class="figure"&gt;Figure 6: This solution contains two projects, one a simple console application called &lt;u&gt;Customer &lt;/u&gt;that contains a folder called &lt;u&gt;Models&lt;/u&gt;. The other project is called &lt;u&gt;CustomerTests&lt;/u&gt; and it is designed to hold unit tests.&lt;/p&gt;  &lt;p&gt;I want to check if my Customer list is create correctly. In the Customers file from your test project, create a method called IsCustomerListValid. Inside the method create code to initialize a &lt;strong&gt;CustomerList&lt;/strong&gt; object, as shown in Listing X. &lt;/p&gt;  &lt;p&gt;Listing 5: A simple unit test with the code to initialize a class called CustomerList. Note that the CustomerList is not colored in Teal, since its declaration has not been created yet.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fbbd71a3-4443-4c5b-bdba-8d3dee069dfa" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Text;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; Microsoft.VisualStudio.TestTools.UnitTesting;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; CustomerTests&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;[&lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;]&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Customers&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;[&lt;span style="color:#2b91af"&gt;TestMethod&lt;/span&gt;]&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; IsCustomerListValid()&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;CustomerList cust = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; CustomerList();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;At this stage, there is no CustomerList, so in Visual Studio you will again see the red squiggles and the blue smart tag, just as I showed in Figure 2. Without needing to take your hands off the keyboard, you can press control plus dot to bring up the expansion tips as in Figure 2. This time select &lt;strong&gt;New Type. &lt;/strong&gt;A dialog comes up like the one shown in Figure 7. In the dialog we can change the accessibility, the kind of code to generate and the project file and directory where we want to place it. Set the &lt;strong&gt;Access&lt;/strong&gt; to &lt;strong&gt;public&lt;/strong&gt; and the &lt;strong&gt;Kind&lt;/strong&gt; to &lt;strong&gt;class&lt;/strong&gt;. Use the &lt;strong&gt;Project&lt;/strong&gt; drop down to select the &lt;strong&gt;Customer&lt;/strong&gt; project and the the &lt;strong&gt;Create new file&lt;/strong&gt; drop down to select the &lt;strong&gt;Model&lt;/strong&gt; directory. Type in &lt;strong&gt;CustomerList.cs &lt;/strong&gt;as the name of the file to create. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure05_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure05" border="0" alt="Figure05" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure05_thumb.png" width="378" height="407" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p class="figure"&gt;Figure 7. Selecting the kind of type that you want to create, as well as the project, folder and file in which you want to place it.&lt;/p&gt;  &lt;p&gt;When you press OK in the&lt;strong&gt; Generate New Type&lt;/strong&gt; dialog, the new type will be created, and the IDE will add the using directive and the correct references. You can now fill out your test and your generated class as shown in Listing 6 and 7. Note that we have used generate from usage to enhance the &lt;strong&gt;CustomerList&lt;/strong&gt; class with a method called &lt;strong&gt;Add.&lt;/strong&gt; I then manually wrote code to create a list into which the text we pass can be inserted.&lt;/p&gt;  &lt;p class="listing"&gt;Listing 6: A simple unit test.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2d4608a7-da3a-480f-8b2f-520f6b9aea55" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; Customer.Models;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; Microsoft.VisualStudio.TestTools.UnitTesting;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; CustomerTests&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;[&lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;]&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Customers&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;[&lt;span style="color:#2b91af"&gt;TestMethod&lt;/span&gt;]&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; IsCustomerListValid()&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;CustomerList&lt;/span&gt; cust = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CustomerList&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;cust.Add(&lt;span style="color:#a31515"&gt;&amp;quot;Karen&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;Assert&lt;/span&gt;.IsNotNull(cust);&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p class="listing"&gt;Listing 7: The using directive, namespace, CustomerList class and header for the Add method were auto-generated. I manually created the list and inserted the call to Add an item into it.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2c11c353-a69d-4687-bb78-e50d45f80650" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; Customer.Models&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CustomerList&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt; list = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; Add(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; p)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;list.Add(p);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;You can now use the Test | View menu to bring up the Test List Editor and Test View to select and run your test.&lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;In this post you got a second look at the code used in Karen Liu’s generate from usage video. You saw that GFU can be used to create classes, constructors, parameters, properties and fields. You also explored the powerful &lt;strong&gt;Generate New Type&lt;/strong&gt; dialog which gives you the flexibility to choose the kind of type you want to create, as well as the project, directory and file in which you want to insert it. Finally, you saw that generate from usage can be powerful aid when you are engaged in test first development.&lt;/p&gt;  &lt;h2&gt;Resources&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;Download the &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=8077"&gt;source code&lt;/a&gt; from the &lt;a href="http://code.msdn.microsoft.com/linqfarm"&gt;LINQ Farm&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/vcsharp/ee633445.aspx"&gt;The How Do I Generate from Usage Video&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd409796(VS.100).aspx"&gt;Generate from Usage in the MSDN Library&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/vbteam/archive/2008/12/13/walkthrough-tdd-support-with-the-generate-from-usage-feature-in-vs-2010-lisa-feigenbaum.aspx"&gt;Walkthrough: TDD Support with the Generate From Usage Feature in VS 2010 (Lisa Feigenbaum)&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blog.noop.se/archive/2009/06/16/generate-from-usage-in-visual-studio-2010.aspx"&gt;Magnus Martensson on Generate from Usage&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/zce12xx2(VS.100).aspx"&gt;Task Lists and TODO comments in the MSDN Library&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f07%2fhdi-video-generate-from-usage-with-karen-liu.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f07%2fhdi-video-generate-from-usage-with-karen-liu.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9898211" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Video/default.aspx">Video</category><category domain="http://blogs.msdn.com/charlie/archive/tags/LinqFarm/default.aspx">LinqFarm</category><category domain="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx">C# 4.0</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Testing/default.aspx">Testing</category></item><item><title>Classic, Lightweight and ScriptFree MSDN Library Views</title><link>http://blogs.msdn.com/charlie/archive/2009/11/06/new-msdn-library-views.aspx</link><pubDate>Sat, 07 Nov 2009 00:58:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9918925</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9918925.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9918925</wfw:commentRss><description>&lt;p&gt;There have been a number of changes to the &lt;a href="http://msdn.microsoft.com/en-us/library/kx37x362.aspx"&gt;MSDN library&lt;/a&gt; of late, and to the way it is integrated with Visual Studio 2010. &lt;a href="http://blogs.msdn.com/kathleen/default.aspx"&gt;Kathleen McGrath&lt;/a&gt; and Mark D'Urso have created a &lt;a href="http://channel9.msdn.com/posts/kmcgrath/New-MSDN-Library-views/"&gt;nice little video&lt;/a&gt; that walks you through some of the new features such as the classic, lightweight and script-free views, as well as the new feedback mechanism. If you have questions about how the new features in the library work you might find that this is a useful way to spend 9 minutes and 36 seconds. &lt;/p&gt;  &lt;p&gt;You might also enjoy &lt;a href="http://channel9.msdn.com/posts/kmcgrath/Help-30-New-Help-System-in-Visual-Studio-2010/"&gt;Kathleen’s video interview&lt;/a&gt; with Ryan Linton. It&amp;#160; focuses on using help from inside Visual Studio.&lt;/p&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f06%2fnew-msdn-library-views.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f06%2fnew-msdn-library-views.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9918925" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Help+System/default.aspx">Help System</category></item><item><title>New Article by Bill Wagner on Dynamic Method Bags in C# 4.0</title><link>http://blogs.msdn.com/charlie/archive/2009/11/03/new-article-by-bill-wagner-on-dynamic-method-bags.aspx</link><pubDate>Tue, 03 Nov 2009 22:30:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9917015</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9917015.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9917015</wfw:commentRss><description>&lt;p&gt;C# MVP and wunderkind Bill Wagner has written an article entitled &lt;a href="http://msdn.microsoft.com/en-us/library/ee658247.aspx"&gt;Dynamic Method Bags&lt;/a&gt; which is now available on MSDN. Bill explores the new dynamic feature in C# 4.0. Most posts on this subject explain how to use dynamic to call Python, Ruby or Office. In his article, Bill explains how dynamic can be used not to call another language or tool, but to call your own C# objects without directly using the reflection API’s. The solution he provides combines generics, expression tress and dynamic to create a “type that allows developers to add new methods at runtime” and call those methods through dynamic dispatch.&lt;/p&gt;  &lt;h2&gt;Resources&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ee658247.aspx"&gt;Bill’s Dynamic Method Bags article&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://srtsolutions.com/blogs/billwagner/"&gt;Bills Blog&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Download a Doc file providing an &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=csharpfuture&amp;amp;DownloadId=3550"&gt;Overview of C# 4.0 Language Features&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://code.msdn.microsoft.com/csharpfuture"&gt;C# Future Samples&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/vcsharp/dd819407.aspx"&gt;Visual C# 2010 Resources&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd441784.aspx"&gt;VS 2010 Walkthroughs&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/vbteam/archive/2008/12/17/walkthrough-dynamic-programming-in-visual-basic-10-0-and-c-4-0-lisa-feigenbaum.aspx"&gt;Some Dynamic Walkthroughs&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.codeplex.com/wikipage?ProjectName=IronPython"&gt;IronPython on CodePlex&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://ironruby.net/"&gt;IronRuby&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f03%2fnew-article-by-bill-wagner-on-dynamic-method-bags.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f03%2fnew-article-by-bill-wagner-on-dynamic-method-bags.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9917015" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/Dynamic/default.aspx">Dynamic</category><category domain="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx">C# 4.0</category></item><item><title>New Article on Detecting Memory Leaks . NET Applications</title><link>http://blogs.msdn.com/charlie/archive/2009/11/02/new-article-on-detecting-memory-leaks-net-applications.aspx</link><pubDate>Mon, 02 Nov 2009 23:49:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9916466</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9916466.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9916466</wfw:commentRss><description>&lt;p&gt;MSDN has published an excellent article by &lt;a href="http://proagora.com/en/experts/profiles/fabrice.marguerie"&gt;Fabrice Marguerie&lt;/a&gt; entitled “&lt;a href="http://msdn.microsoft.com/en-us/library/ee658248.aspx"&gt;How to Detect and Avoid Memory and Resource Leaks in .NET Applications&lt;/a&gt;.” In the article, the author explains how memory leaks are introduced into .NET applications, and what you can do to discover and eliminate them. The code shown in the article is in C#, but the topics covered will likely be useful to a broad range of .NET developers. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/NewArticleonDetectingMem.NETApplications_D88F/FabriceMarguerie_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="FabriceMarguerie" border="0" alt="FabriceMarguerie" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/NewArticleonDetectingMem.NETApplications_D88F/FabriceMarguerie_thumb.jpg" width="82" height="104" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Fabrice Marguerie is a Microsoft MVP, French Software Architect and Web Entrepreneur with an in-depth understanding of .NET technology.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Fabrice explains his subject in great depth, providing information that will be useful both to advanced developers, and to those with an intermediate-level understanding of .NET development. Features included in the text include:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;An explanation of how memory and resource leaks occur in .NET application &lt;/li&gt;    &lt;li&gt;A demonstration of how to detect those leaks &lt;/li&gt;    &lt;li&gt;A list of common causes of memory leaks and how to avoid them &lt;/li&gt;    &lt;li&gt;A useful reference section listing a number of tools that can be used to help you find and manage leaks &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;This is a well written article with a wealth of information in it. Hurry on over to the Dev Center and &lt;a href="http://msdn.microsoft.com/en-us/library/ee658248.aspx"&gt;take a look&lt;/a&gt;.&lt;/p&gt;  &lt;h2&gt;References&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ee658248.aspx"&gt;How to Detect and Avoid Memory and Resource Leaks in .NET Applications&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://proagora.com/fr/experts/profiles/fabrice.marguerie"&gt;Fabrice’s bio&lt;/a&gt; on proagora &lt;/li&gt; &lt;/ul&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f02%2fnew-article-on-detecting-memory-leaks-net-applications.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f02%2fnew-article-on-detecting-memory-leaks-net-applications.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9916466" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>CSharp “How Do I Videos (Podcasts)” for the Zune Software</title><link>http://blogs.msdn.com/charlie/archive/2009/11/01/csharp-how-do-i-videos-for-the-zune-software.aspx</link><pubDate>Sun, 01 Nov 2009 20:54:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9915933</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9915933.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9915933</wfw:commentRss><description>&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;p&gt;It can be handy to create custom RSS feeds for the Zune so that it is easy to download and watch selected videos. You can watch these videos either on your PC, or on the Zune itself. &lt;a href="http://www.elvenware.com/charlie/rss/CSharpZuneReadyHowDoIVideos.rss"&gt;Here&lt;/a&gt; is a custom feed I created that contains all the new C# 4.0 language and IDE &lt;a href="http://msdn.microsoft.com/en-us/bb629407.aspx"&gt;How Do I Videos&lt;/a&gt;, plus a selection of other How Do I videos. In total, at this time, there are 35 videos in the feed. The RSS I created uses a simple and quite minimal syntax tested only with Internet Explorer 8 and the software for Zune 4.0.740.0. The source for the C# program that generated the feed includes regular expressions, LINQ to Objects and LINQ to SQL. I discuss that program briefly at the bottom of this post.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.elvenware.com/charlie/rss/CSharpZuneReadyHowDoIVideos.rss"&gt;Charlie’s Custom C# and Visual Studio Feed&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/bb629407.aspx"&gt;The How Do I Video Home Page with over 500 Videos&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;How Do Videos for &lt;a href="http://msdn.microsoft.com/en-us/vstudio/bb507746.aspx"&gt;Visual Studio&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/vcsharp/bb798022.aspx"&gt;How Do I Videos for C#&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Download the &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=7971"&gt;source&lt;/a&gt; for this post from the &lt;a href="http://code.msdn.microsoft.com/linqfarm"&gt;LINQ farm&lt;/a&gt;. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;You can use this custom feed from inside IE, as shown in Figure 0. However, I really created this feed to run on the Zune, so you should import the feed into the Zune software as a series of podcast. I explain this latter process in the next section of this post.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/CSharpHowDoIVideosfortheZuneSoftware_AB92/Figure00_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure00" border="0" alt="Figure00" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/CSharpHowDoIVideosfortheZuneSoftware_AB92/Figure00_thumb.png" width="644" height="471" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 0: Viewing a simple RSS feed in IE 8. Click the image to expand it.&lt;/strong&gt;&lt;/p&gt;  &lt;h2&gt;Using the Feed in the Zune Software&lt;/h2&gt;  &lt;p&gt;In this section I provide a quick tutorial for those who’ve never used Podcasts with a Zune. Open &lt;a href="http://www.elvenware.com/charlie/rss/CSharpZuneReadyHowDoIVideos.rss"&gt;the custom RSS&lt;/a&gt; feed in IE and grab the URL from the address bar. Alternately, you can just right click on any of the links to the feed in this document and choose &lt;strong&gt;Copy Shortcut &lt;/strong&gt;or whatever the equivalent command is in Firefox or other browsers. Open the Zune software and turn to the &lt;strong&gt;Collection | Podcasts&lt;/strong&gt; page. Click the button on the bottom left of the page called &lt;strong&gt;Add a Podcast&lt;/strong&gt;. The &lt;strong&gt;Subscribe&lt;/strong&gt; dialog appears. Paste in the URL for the feed, as shown in Figure 1, and then click the &lt;strong&gt;Subscribe&lt;/strong&gt; button. The various How Do I podcasts included in the feed should begin downloading to your system, as shown in Figure 2.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure01" border="0" alt="Figure01" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/CSharpHowDoIVideosfortheZuneSoftware_AB92/Figure01_3.png" width="471" height="223" /&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Subscribing to an RSS Podcast feed in Zune Software 4.0.740.0&lt;/strong&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/CSharpHowDoIVideosfortheZuneSoftware_AB92/Figure02_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure02" border="0" alt="Figure02" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/CSharpHowDoIVideosfortheZuneSoftware_AB92/Figure02_thumb.png" width="644" height="317" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 2: Viewing a feed in the Zune Software.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You can then plug in your Zune and right click on the feed and choose to sync the videos to your device. I’ll confess, however, that many of these videos look best on a PC, since you need a certain amount of screen real estate to adequately view the code typed in by the presenters. &lt;/p&gt;  &lt;h2&gt;&lt;strong&gt;Creating the RSS Feed by Screen Scrapping&lt;/strong&gt;&lt;/h2&gt;  &lt;p&gt;I created this feed by the time honored hack of screen scraping. I first copied the URL for the home page of each video and passed it to C# code designed to download the HTML associated with the URL. The program parsed the HTML looking for the elements I needed in my feed. LINQ to XML provided a handy tool for creating my simple RSS feed. I simply passed in the data retrieved from the HTML file to a set of LINQ routines designed to produce the XML for an RSS feed. &lt;/p&gt;  &lt;p&gt;This technique is simple to implement.&amp;#160; Screen scraping is nevertheless a very brittle practice, as my code will last only so long as the basic structure of the HTML pages that I’m parsing remains static. How long such conditions will prevail one can only suppose.&lt;/p&gt;  &lt;p&gt;I called my quick and dirty program &lt;strong&gt;CreateRssFeed, &lt;/strong&gt;and its source is available for &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=7971"&gt;download&lt;/a&gt;. The program is based on two custom classes, one for generating the RSS feed, the other for using Regular Expressions to parse the HTML file.&amp;#160; I store the URLs for the 35 HDI video pages in a file called &lt;strong&gt;UrlsToProcess.txt&lt;/strong&gt;. I won’t bore you with the complete listings for this code, but I show the main body in Listing 1, and a short excerpt from the RSS feed is shown in Listing 2. &lt;/p&gt;  &lt;p&gt;When you download the source, you will find versions for both VS 2008 and VS 2010, Beta 2. The latter solution contains both a console and a windows forms app. They each have their advantages, but I tend to prefer the former.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Listing 1: The main body of the program.&lt;/strong&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:86edbd1a-51cc-4e41-8c27-625eb52e991e" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.IO;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; CreateRssVideo.Code;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; CreateRssVideo&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ProgramConsole&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; Main(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;[] args)&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;[] urls = &lt;span style="color:#2b91af"&gt;File&lt;/span&gt;.ReadAllLines(&lt;span style="color:#a31515"&gt;&amp;quot;UrlsToProcess.txt&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt; items = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;ParseHdiVideoPages&lt;/span&gt; parser = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ParseHdiVideoPages&lt;/span&gt;(items);&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; url &lt;span style="color:#0000ff"&gt;in&lt;/span&gt; urls)&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;parser.ProcessUrl(url);&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(items[items.Count-&lt;span style="color:#a52a2a"&gt;1&lt;/span&gt;]);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;File&lt;/span&gt;.WriteAllText(&lt;span style="color:#a31515"&gt;@&amp;quot;..&amp;#92;..&amp;#92;CSharpZuneReadyHowDoIVideos.rss&amp;quot;&lt;/span&gt;, parser.RetrieveXml());&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Listing 1: An abbreviated version of the RSS Feed created by the code for the CreateRssVideo program.&lt;/strong&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:afae1f2d-aa35-488e-b6cb-aa3a70ad7f2b" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#a31515"&gt;xml&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;1.0&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;encoding&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;utf-8&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;standalone&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;yes&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;?&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="color:#008000"&gt;Charlie&amp;#39;s RSS Feed for Videos&lt;/span&gt;&lt;span style="color:#0000ff"&gt;--&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;rss&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;2.0&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;channel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;CSharp How Do I Video Custom Feed for Zune Software&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;description&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;VS 2010 Related Videos&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;description&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;link&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;http://blogs.msdn.com/charlie&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;link&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;item&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;Add Tool Windows to the Visual Studio IDE?&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;description&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;This video demonstrates how to&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;description&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;link&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;http://msdn.microsoft.com/en-us/vstudio/dd250814.aspx&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;link&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;enclosure&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;url&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;http://download.microsoft.com/CreatingToolWindows.wmv&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;video/x-ms-wmv&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;item&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;channel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;rss&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The C# code for the &lt;strong&gt;CreateRssVideo&lt;/strong&gt; program uses the build-in &lt;strong&gt;WebClient&lt;/strong&gt; object to download the HTML for the video home page as a string: &lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; RetrieveHtmlFromSite(&lt;span class="kwrd"&gt;string&lt;/span&gt; urlName)
{
    WebClient objWebClient = &lt;span class="kwrd"&gt;new&lt;/span&gt; WebClient();
    &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] requestedUrl = objWebClient.DownloadData(urlName);
    UTF8Encoding utf8 = &lt;span class="kwrd"&gt;new&lt;/span&gt; UTF8Encoding();
    &lt;span class="kwrd"&gt;string&lt;/span&gt; htmlAsString = utf8.GetString(requestedUrl);
    &lt;span class="kwrd"&gt;return&lt;/span&gt; htmlAsString;
}&lt;/pre&gt;

&lt;p&gt;It then uses bits of Regular Expression code to parse the HTML and extract the title, description and video URL from it:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; FindStringInHtmlFile(&lt;span class="kwrd"&gt;string&lt;/span&gt; htmlAsString, &lt;span class="kwrd"&gt;string&lt;/span&gt; regEx)
{
    Regex r = &lt;span class="kwrd"&gt;new&lt;/span&gt; Regex(regEx, RegexOptions.IgnoreCase);

    MatchCollection matchCollection = r.Matches(htmlAsString);
    &lt;span class="kwrd"&gt;string&lt;/span&gt; groupItem = &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;;

    &lt;span class="kwrd"&gt;if&lt;/span&gt; (matchCollection.Count &amp;gt; 0)
    {
        &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (Group groupItemFound &lt;span class="kwrd"&gt;in&lt;/span&gt; matchCollection[0].Groups)
        {
            groupItem = groupItemFound.Value;
        }
    }
    &lt;span class="kwrd"&gt;return&lt;/span&gt; groupItem;
}        &lt;/pre&gt;

&lt;p&gt;Below is a sample of one of the simple regular expressions that I pass into the &lt;strong&gt;FindStringInHtmlFile &lt;/strong&gt;method. This particular bit of code is used to retrieve the description of the video from the HTML file:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; regExDescriptionText = &lt;span class="str"&gt;@&amp;quot;([A-Z\s0-9#\.,\(\)\-]+)&amp;quot;&lt;/span&gt;;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; regExDescription = &lt;span class="str"&gt;@&amp;quot;&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;About this Video&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&amp;quot;&lt;/span&gt; + regExDescriptionText;&lt;/pre&gt;

&lt;p&gt;While we are parsing the HTML, the program works step by step to create the RSS document using LINQ to XML. The first stage in the RSS creation is to new-up an outline or shell that will hold the meat of the document:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Start()
{
    &lt;span class="kwrd"&gt;string&lt;/span&gt; link = &lt;span class="str"&gt;&amp;quot;http://blogs.msdn.com/charlie&amp;quot;&lt;/span&gt;;
    &lt;span class="kwrd"&gt;string&lt;/span&gt; title = &lt;span class="str"&gt;&amp;quot;CSharp How Do I Video Custom Feed for Zune Software&amp;quot;&lt;/span&gt;;
    &lt;span class="kwrd"&gt;string&lt;/span&gt; description = &lt;span class="str"&gt;&amp;quot;VS 2010 Related Videos&amp;quot;&lt;/span&gt;;

    theDocument = &lt;span class="kwrd"&gt;new&lt;/span&gt; XDocument(&lt;span class="kwrd"&gt;new&lt;/span&gt; XDeclaration(&lt;span class="str"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;yes&amp;quot;&lt;/span&gt;),
        &lt;span class="kwrd"&gt;new&lt;/span&gt; XComment(&lt;span class="str"&gt;&amp;quot;Charlie's RSS Feed for Videos&amp;quot;&lt;/span&gt;),
        GetChannel(link, title, description));
}        

&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; XElement GetChannel(&lt;span class="kwrd"&gt;string&lt;/span&gt; link, &lt;span class="kwrd"&gt;string&lt;/span&gt; title, &lt;span class="kwrd"&gt;string&lt;/span&gt; description)
{
    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;rss&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; XAttribute(&lt;span class="str"&gt;&amp;quot;version&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;2.0&amp;quot;&lt;/span&gt;),
        &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;channel&amp;quot;&lt;/span&gt;,
                        &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;title&amp;quot;&lt;/span&gt;, title),
                        &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;description&amp;quot;&lt;/span&gt;, description),
                        &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;link&amp;quot;&lt;/span&gt;, link)));
}&lt;/pre&gt;

&lt;p&gt;The &lt;strong&gt;Start&lt;/strong&gt; method creates the document itself, including an XML declaration and a comment. The &lt;strong&gt;GetChannel&lt;/strong&gt; method adds a few simple fields to the document that describes its purpose and which list the URL for my home page. Compare this code with the first few lines from Listing 1 to be sure you understand its purpose. &lt;/p&gt;

&lt;p&gt;As the information for each HDI video is discovered, a new &lt;strong&gt;&amp;lt;item&amp;gt;&lt;/strong&gt; node is created for the RSS feed. This node lists the title for the video, describes the video, and references the URL for the HTML page where the video is stored. Finally, and most importantly, the code includes the &lt;strong&gt;&amp;lt;enclosure&amp;gt;&lt;/strong&gt; node which stores the URL of the actual video. It is the &lt;strong&gt;&amp;lt;enclosure&amp;gt;&lt;/strong&gt; node that the Zune software uses to locate the video which it downloads to your system:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; XElement GetItem(&lt;span class="kwrd"&gt;string&lt;/span&gt; itemTitle, &lt;span class="kwrd"&gt;string&lt;/span&gt; description, &lt;span class="kwrd"&gt;string&lt;/span&gt; linkUrl, &lt;span class="kwrd"&gt;string&lt;/span&gt; videoUrl)
{
    XElement item = &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;item&amp;quot;&lt;/span&gt;,
                &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;title&amp;quot;&lt;/span&gt;, itemTitle),
                &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;description&amp;quot;&lt;/span&gt;, description),
                &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;link&amp;quot;&lt;/span&gt;, linkUrl),
                &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;enclosure&amp;quot;&lt;/span&gt;,
                    &lt;span class="kwrd"&gt;new&lt;/span&gt; XAttribute(&lt;span class="str"&gt;&amp;quot;url&amp;quot;&lt;/span&gt;, videoUrl), &lt;span class="kwrd"&gt;new&lt;/span&gt; XAttribute(&lt;span class="str"&gt;&amp;quot;type&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;video/x-ms-wmv&amp;quot;&lt;/span&gt;)));
    &lt;span class="kwrd"&gt;return&lt;/span&gt; item;
}&lt;/pre&gt;

&lt;p&gt;Once the &lt;strong&gt;&amp;lt;item&amp;gt;&lt;/strong&gt; node has been created, it is added to the XML document itself:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddItem(&lt;span class="kwrd"&gt;string&lt;/span&gt; itemTitle, &lt;span class="kwrd"&gt;string&lt;/span&gt; description, &lt;span class="kwrd"&gt;string&lt;/span&gt; linkUrl, &lt;span class="kwrd"&gt;string&lt;/span&gt; videoUrl)
{            
    XElement item = GetItem(itemTitle, description, linkUrl, videoUrl);            

    var linkNode = from x &lt;span class="kwrd"&gt;in&lt;/span&gt; theDocument.Descendants(&lt;span class="str"&gt;&amp;quot;link&amp;quot;&lt;/span&gt;)
                   select x;
    
    linkNode.First().AddAfterSelf(item);            
}&lt;/pre&gt;

&lt;p&gt;Note that this code includes a simple LINQ query used to discover the proper insertion point in the XML document, and then employs the LINQ to XML &lt;strong&gt;AddAfterSelf&lt;/strong&gt; operator to insert the new &lt;strong&gt;&amp;lt;item&amp;gt;&lt;/strong&gt; XML node into the code for the RSS feed. The program enters and loop and repeats the process of creating and inserting &lt;strong&gt;&amp;lt;item&amp;gt; &lt;/strong&gt;nodes into our RSS feed multiple times. Once all the URLs in our &lt;strong&gt;UrlsToProcess.txt&lt;/strong&gt; document have been examined the program exits.&lt;/p&gt;

&lt;h2&gt;Summary&lt;/h2&gt;

&lt;p&gt;The primary purpose of this post is to provide an RSS feed that you can use to download videos for viewing in the Zune software or in the Zune itself. I also showed a simple, and very brittle, screen scraping program that I used to create the feed. I wrote this program for my own use, and pass it on to you with only minimal claims of its value. If nothing else, it provides some examples of how to have fun writing Regular Expressions, and demonstrates how easy it is to use LINQ to Objects and LINQ to XML to create XML documents.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The &lt;a href="http://www.elvenware.com/charlie/rss/CSharpZuneReadyHowDoIVideos.rss"&gt;video feed&lt;/a&gt;. &lt;/li&gt;

  &lt;li&gt;The &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=7971"&gt;source&lt;/a&gt; from the &lt;a href="http://code.msdn.microsoft.com/linqfarm"&gt;LINQ farm&lt;/a&gt;. &lt;/li&gt;
&lt;/ul&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f01%2fcsharp-how-do-i-videos-for-the-zune-software.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f01%2fcsharp-how-do-i-videos-for-the-zune-software.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9915933" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Samples/default.aspx">Samples</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Video/default.aspx">Video</category><category domain="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx">C# 4.0</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Web/default.aspx">Web</category></item><item><title>VSL at DevConnections</title><link>http://blogs.msdn.com/charlie/archive/2009/10/31/vsl-at-devconnections.aspx</link><pubDate>Sat, 31 Oct 2009 08:38:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9915621</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9915621.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9915621</wfw:commentRss><description>&lt;p&gt;The following talks will be given by Visual Studio Languages team members at the &lt;a href="http://www.devconnections.com/"&gt;DevConnections&lt;/a&gt; Conference in Las Vegas. &lt;/p&gt; &lt;td&gt;  &lt;table border="2"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;th&gt;Tuesday, November 10, 2009&lt;/th&gt;        &lt;th&gt;Title&lt;/th&gt;        &lt;th&gt;Speaker&lt;/th&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;10:00am - 11:00am&lt;/td&gt;        &lt;td&gt;VMS01: The Future of C#&lt;/td&gt;        &lt;td&gt;Charlie Calvert&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;11:15am - 12:15pm&lt;/td&gt;        &lt;td&gt;VMS02: Future Directions for Visual Basic&lt;/td&gt;        &lt;td&gt;Jared Parsons&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;1:45pm - 2:45pm&lt;/td&gt;        &lt;td&gt;VMS03: Microsoft Visual C# IDE Tips and Tricks&lt;/td&gt;        &lt;td&gt;Charlie Calvert&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;3:15pm - 4:15pm&lt;/td&gt;        &lt;td&gt;VMS04: Microsoft Visual Basic IDE Tips and Tricks&lt;/td&gt;        &lt;td&gt;Jared Parsons&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;For additional Information see:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.devconnections.com/"&gt;DevConnections Home Page&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.devconnections.com/shows/FALL2009VS/default.asp?s=136"&gt;Visual Studio Connections&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.devconnections.com/shows/FALL2009VS/default.asp?c=2&amp;amp;s=136"&gt;Speakers&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.devconnections.com/shows/FALL2009VS/default.asp?c=1&amp;amp;s=136"&gt;Sessions&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.devconnections.com/shows/FALL2009VS/default.asp?c=27&amp;amp;s=136"&gt;Schedule&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f31%2fvsl-at-devconnections.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f31%2fvsl-at-devconnections.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9915621" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx">C# 4.0</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Conferences/default.aspx">Conferences</category></item><item><title>Visual Studio 2010 Beta 2 does not Load: The “Application Cannot Start” and Raster Font Errors</title><link>http://blogs.msdn.com/charlie/archive/2009/10/29/visual-studio-2010-beta-2-does-not-load-the-application-cannot-start-and-raster-fonts-errors.aspx</link><pubDate>Thu, 29 Oct 2009 22:13:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9914988</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9914988.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9914988</wfw:commentRss><description>&lt;p&gt;I was working at home the other night with a freshly installed copy of Visual 2010 Beta 2. I closed the IDE for a moment, and when I tried to reopen it, I got an error that read: “The application cannot start.” I found I could start the IDE by using the Jump Lists in Windows 7 to start a specific application rather than simply opening the IDE without loading a project. After getting back inside the development environment, I rummaged about for a bit and finally fixed the problem, probably by resetting my profile (&lt;strong&gt;Tools | Import Export Settings&lt;/strong&gt;). That may or may not work for you, but these two excellent and authoritative posts are more likely to solve your problem if you encounter a similar error:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/visualstudio/archive/2009/10/29/how-to-fix-the-application-cannot-start-error.aspx"&gt;How to fix the “Application Cannot Start” Error&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/visualstudio/archive/2009/10/27/VS-2010-Beta2_3A00_--Workaround-for-Raster-Font-Settings-Issue.aspx"&gt;Work around for the Raster Font Settings Issue&lt;/a&gt; (“Object reference not set to an instance of an object.”) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/TwoIssueswithVisualStudio2010Beta2TheApp_D481/ApplicationCannotStart_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ApplicationCannotStart" border="0" alt="ApplicationCannotStart" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/TwoIssueswithVisualStudio2010Beta2TheApp_D481/ApplicationCannotStart_thumb.png" width="634" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: There is no joy in Mudville, Visual Studio 2010, Beta 2 will not start!&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I was having an excellent time working inside VS 2010 Beta 2, so I was frustrated to hit this glitch. I don’t want you to wander into the same troubled climes, so I’m posting here this good information from two experts on the VS IDE. By the way, these issues are all fixed in our new internal builds, and those fixes will be part of the final release of Visual Studio 2010.&lt;/p&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f29%2fvisual-studio-2010-beta-2-does-not-load-the-application-cannot-start-and-raster-fonts-errors.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f29%2fvisual-studio-2010-beta-2-does-not-load-the-application-cannot-start-and-raster-fonts-errors.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9914988" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx">C# 4.0</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Beta+Software/default.aspx">Beta Software</category></item><item><title>A Chance to Influence the MSDN Visual Studio Documentation (Help System)</title><link>http://blogs.msdn.com/charlie/archive/2009/10/27/a-chance-to-influence-the-visual-studio-documentation.aspx</link><pubDate>Tue, 27 Oct 2009 21:43:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9913729</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9913729.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9913729</wfw:commentRss><description>&lt;p&gt;The docs team here at Microsoft has created a &lt;a href="http://go.microsoft.com/fwlink/?LinkID=102169"&gt;new survey&lt;/a&gt; to solicit your opinion on the help system found in the &lt;a href="http://msdn.microsoft.com/en-us/library/default.aspx"&gt;MSDN technical library&lt;/a&gt;. This the same information you see if you press F1 in Visual Studio to get help on the IDE or your development language. I know the people who create and process this survey, and I can assure that any feedback you give will be processed and carefully considered. The team is strongly driven by input from our users, and this is your chance to have your say. I’ve taken the survey myself, and found that it consists of about 10 pages with an average of 2 or 3 questions per page. I didn’t spend much time contemplating each question, and was therefore able to finish the survey in about 5 minutes.&lt;/p&gt;  &lt;h2&gt;Links&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;The Survey: &lt;a href="http://go.microsoft.com/fwlink/?LinkID=102169"&gt;http://go.microsoft.com/fwlink/?LinkID=102169&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/default.aspx"&gt;The MSDN Library&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd831853(VS.100).aspx"&gt;The MSDN Library page on Visual Studio 2010 Beta 2&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Thank you for your input!&lt;/p&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f27%2fa-chance-to-influence-the-visual-studio-documentation.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f27%2fa-chance-to-influence-the-visual-studio-documentation.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9913729" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Help+System/default.aspx">Help System</category></item><item><title>Running IronPython Scripts from a C# 4.0 Program</title><link>http://blogs.msdn.com/charlie/archive/2009/10/25/hosting-ironpython-in-a-c-4-0-program.aspx</link><pubDate>Mon, 26 Oct 2009 06:41:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9912809</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9912809.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9912809</wfw:commentRss><description>&lt;p&gt;IronPython is a scripting language hosted on the .NET platform. This posts shows how you can use the &lt;a href="http://www.codeplex.com/dlr"&gt;Dynamic Language Runtime (DLR)&lt;/a&gt; and the new &lt;a href="http://code.msdn.microsoft.com/csharpfuture"&gt;C# 4.0&lt;/a&gt; &lt;strong&gt;dynamic&lt;/strong&gt; keyword to call an IronPython script from a C# program.&lt;/p&gt; &lt;p&gt;Before going any further, it might be helpful to take a moment to explore the architecture that makes this technology possible. The key building block is the DLR, which sits on top of the .NET 4.0 CLR and provides the tooling for adding dynamic programs such as Python to the family of .NET languages. C# 4.0 adds the &lt;strong&gt;dynamic&lt;/strong&gt; keyword and some related technologies to integrate support for dynamic binding into the language. The end result is that developers can arbitrary Python scripts directly from C# or other .NET languages.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=7927"&gt;Download Source&lt;/a&gt; from the &lt;a href="http://code.msdn.microsoft.com/linqfarm"&gt;LinqFarm&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;h2&gt;Setting up a C# Project to Call IronPython&lt;/h2&gt; &lt;p&gt;In two previous posts I described how to install and run a simple IronPython program:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/10/22/ironruby-and-ironpython-for-net-4-0-beta-2-available.aspx"&gt;Announcing IronPython and IronRuby releases for Visual Studio 2010 Beta 2&lt;/a&gt;  &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/10/25/running-ironpython.aspx"&gt;Getting Started with IronPython&lt;/a&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;If you don’t already have the latest version of IronPython installed or if you need a little refresher course in writing Python scripts, then you might want to glance at these posts. Otherwise, you can just keep reading to learn how to call Python from C#.&lt;/p&gt; &lt;p&gt;After the IronPython installation, its interpreter and its libraries will be installed in your &lt;strong&gt;Program Files&lt;/strong&gt; directory, as shown in Listing 1. The interpreter is installed in &lt;strong&gt;ipy.exe&lt;/strong&gt;, where ipy is pronounced “Eye-Pie.” The interpreter remains dormant when you call Python from C#, so our focus here should be on the assemblies shown in the second half of the listing, with a particular emphasis on &lt;strong&gt;IronPython.dll&lt;/strong&gt;.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Listing 1: At the command prompt you can easily see the core files that form the basis for the IronPython installation.&lt;/strong&gt;&lt;/p&gt;&lt;pre class="myclass"&gt;C:\Program Files (x86)\IronPython 2.6 CTP for .NET 4.0 Beta 2&amp;gt;dir *.exe *.dll
 Volume in drive C has no label.
 Volume Serial Number is 4C6B-EE0E

 Directory of C:\Program Files (x86)\IronPython 2.6 CTP for .NET 4.0 Beta 2

10/18/2009  01:47 PM            12,624 ipy.exe
10/18/2009  01:47 PM            12,624 ipyw.exe

 Directory of C:\Program Files (x86)\IronPython 2.6 CTP for .NET 4.0 Beta 2

10/18/2009  01:47 PM         1,433,424 IronPython.dll
10/18/2009  01:47 PM           435,536 IronPython.Modules.dll
10/18/2009  01:47 PM           875,856 Microsoft.Dynamic.dll
10/18/2009  01:47 PM            58,192 Microsoft.Scripting.Debugging.dll
10/18/2009  01:47 PM           159,056 Microsoft.Scripting.dll
               7 File(s)      2,987,312 bytes
               0 Dir(s)  16,881,614,848 bytes free&lt;/pre&gt;
&lt;p&gt;To run a Python script inside a C# program, you should include some or all of the libraries shown in Listing 1 in the &lt;strong&gt;References&lt;/strong&gt; section of your project. To get started, choose&lt;strong&gt; File | New Project (Ctrl-Shift-N)&lt;/strong&gt; from the &lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"&gt;Visual Studio 2010&lt;/a&gt; menu and create a new console application. Then open the &lt;strong&gt;Solution Explorer (Ctrl-W, S)&lt;/strong&gt; and go to the &lt;strong&gt;References&lt;/strong&gt; section for your project. Right click and choose&lt;strong&gt; Add Reference.&lt;/strong&gt; Take a moment to appreciate how quickly the &lt;strong&gt;Add References&lt;/strong&gt; dialog appeared (the team worked hared on this performance improvement), and then select the &lt;strong&gt;Browse&lt;/strong&gt; tab and navigate to the directory where IronPython resides. The path to the directory hosting IronPython will probably be similar to the one shown in Listing 1. For now, the simplest choice is to select all the assemblies found in that directory, as shown in Figure 1. If you wish to keep things simple, then you only need to select &lt;strong&gt;IronPython.dll, Microsoft.Dynamic.dll&lt;/strong&gt; and &lt;strong&gt;Microsoft.Scripting.dll &lt;/strong&gt;to compile and run the program shown in this example.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure01" border="0" alt="Figure01" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HostingIronPythoninaC4.0Program_147F2/Figure01_6.png" width="486" height="412"&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Figure 1: Using the &lt;em&gt;&lt;u&gt;Add References&lt;/u&gt;&lt;/em&gt; dialog to select the assemblies found in that directory.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When you are done, the IronPython libraries should appear in the &lt;strong&gt;References&lt;/strong&gt; section of the &lt;strong&gt;Solution Explorer&lt;/strong&gt;, as shown in Figure 2.&lt;/p&gt;
&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure02" border="0" alt="Figure02" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HostingIronPythoninaC4.0Program_147F2/Figure02_3.png" width="286" height="410"&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Figure 2: The References node of the Solution Explorer for a C# program that calls an IronPython script.&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;Writing the Code for Calling IronPython&lt;/h2&gt;
&lt;p&gt;Now that you have your project set up correctly you need to do two things:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Write or find a script containing Python code that you want to run 
&lt;li&gt;Write C# code to call the script. &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Listing 2 shows a very simple IronPython script that contains a single method called &lt;strong&gt;Simple() &lt;/strong&gt;that writes a few strings to a console window. Save this script to a file called Test.py, and add it to your project, as shown in Figure 2. There are several ways to do this. One is to right click on your project in the Solution Explorer, and choose &lt;strong&gt;Add | New Item. &lt;/strong&gt;Add a text file, and call it &lt;strong&gt;Test.py&lt;/strong&gt;. Click on the new node when it is added to your project, and set its &lt;strong&gt;Copy to Output Directory&lt;/strong&gt; property to &lt;strong&gt;Copy Always. &lt;/strong&gt;If the Properties window is not visible, you can bring it up by selecting Ctrl-W, P.&lt;/p&gt;
&lt;p&gt;Listings 3a and 3b show the C# code for calling the script, and Listing 4 shows the output from the C# program that hosts the script.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Listing 2: A Simple Python script stored in a file called Test.py. This code prints out some basic information about the environment in which Python is running.&lt;/strong&gt;&lt;/p&gt;&lt;pre class="myclass"&gt;import sys

def Simple():
	print "Hello from Python"
	print "Call Dir(): "
	print dir()
	print "Print the Path: " 
	print sys.path&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Listing 3a: A simple C# program for calling a Python script&lt;/strong&gt;&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:582600b1-95f9-44b5-a83f-01d23c2d1477" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; IronPython.Hosting;&lt;/li&gt;
&lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; Microsoft.Scripting.Hosting;&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;dynamic_demo&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt;
&lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; Main()&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt;
&lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; ipy = &lt;span style="color:#2b91af"&gt;Python&lt;/span&gt;.CreateRuntime();&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;dynamic&lt;/span&gt; test = ipy.UseFile(&lt;span style="color:#a31515"&gt;&amp;quot;Test.py&amp;quot;&lt;/span&gt;);&lt;/li&gt;
&lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;test.Simple();&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt;
&lt;li&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Listing 3b: The same C# program shown in Listing 3a, but this presentation is easier for you to block copy into your own version of the program.&lt;/strong&gt;&lt;/p&gt;&lt;pre class="myclass"&gt;using System;
using IronPython.Hosting;
using Microsoft.Scripting.Hosting;

public class dynamic_demo
{
    static void Main()
    {
        var ipy = Python.CreateRuntime();
        dynamic test = ipy.UseFile("Test.py");
        test.Simple();
    }
}&lt;/pre&gt;
&lt;p&gt;The code in Listing 2 is a very simple Python script. Before calling it from C#, you might want to see it in action. That way you can be sure the script works and you can verify what the script is supposed to do. To get started, block copy the code in Listing 2. Use the Windows Start Menu to open up the Python Console window and paste in the code. Finally, you should explicitly call the &lt;strong&gt;Simple()&lt;/strong&gt; method, as shown in Figure 3. When looking at this screen shot, you can see the version of the Python Console on the first two lines. The next 8 lines show the code that I pasted into the console. Finally, you see where I typed in the call to &lt;strong&gt;Simple(),&lt;/strong&gt; and after that the output from the script. Once again, this has nothing to do with calling the code from C#, it is just a way of verifying that you have a valid script, and of confirming how it should perform.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HostingIronPythoninaC4.0Program_AB98/Figure03_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure03" border="0" alt="Figure03" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HostingIronPythoninaC4.0Program_AB98/Figure03_thumb.png" width="644" height="327"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Figure 3: A screenshot showing a run of the Python script that we will be calling from our C# program.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now let’s look at the 3 lines of code used to call this script from a C# program. This code is shown in Listings 3a and 3b. It first creates an instance of the Python runtime, as shown in line 9:&lt;/p&gt;&lt;pre class="myclass"&gt;var ipy = Python.CreateRuntime();&lt;/pre&gt;
&lt;p&gt;The call to &lt;strong&gt;CreateRunTime&lt;/strong&gt; loads or sets up the core Python libraries and the &lt;a href="http://www.codeplex.com/dlr"&gt;DLR code&lt;/a&gt; needed to to execute the Python script. The second line of code, found on line 10, calls &lt;strong&gt;UseFile&lt;/strong&gt; to load our simple Python script into memory. Notice that the result of this call is a &lt;strong&gt;dynamic&lt;/strong&gt; object. The &lt;strong&gt;dynamic&lt;/strong&gt;&amp;nbsp; keyword is a new feature in C# 4.0 and Visual Studio 2010 which tells the compiler to resolve this particular call not at compile time, but at runtime.&lt;/p&gt;
&lt;p&gt;It’s very important to understand that the dynamic keyword breaks the strong type checking that has always been a hallmark of C# development. There is no doubt that the ability to call dynamic objects is a useful and important feature. However, it should be used sparingly since it sidesteps the strict type checking that makes C# such a powerful and useful language.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;dynamic&lt;/strong&gt; keyword is needed here because Python is an interpreted scripting language where calls are bound at run time, not at compile time. There is no simple or practical way to bind calls to Python at compile time because Python is designed to be a dynamic language which is resolved at runtime. Since C# is a strongly typed language it expects to resolve calls at compile time with strict type checking. In short, we are at an impasse. C# binds statically at compile time, Python dynamically at runtime. Something has to give, and the only valid solution was for C# to allow runtime binding for method calls. &lt;/p&gt;
&lt;p&gt;It is important to grasp that calls into Python are not strictly type checked at compile time, and are therefore not guaranteed to succeed at runtime. Just because your program compiled without error does not mean that you have properly bound each call in your program. In this case we call the method named &lt;strong&gt;Simple()&lt;/strong&gt;, which does in fact exist. As a result, the call succeeds, as shown by the output from the program found in Listing 4. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Listing 4: The output from the C# program which calls a Python script.&lt;/strong&gt;&lt;/p&gt;&lt;pre class="myclass"&gt;Hello from Python
Call Dir():
[]
Print the Path:
['.', 'C:\\Users\\Charlie\\Documents\\SyncData\\Source\\ProjectsShared\\Python\\CallPython\\CallPython\\bin\\Debug\\Lib', 
'C:\\Users\\Charlie\\Documents\\SyncData\\Source\\ProjectsShared\\Python\\CallPython\\CallPython\\bin\\Debug\\DLLs']
Press any key to continue . . .&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;p&gt;Listing 4 shows the good side of working with dynamic code. Now let’s take a moment to consider the dark side. Suppose we called a method on our dynamic test class that does not exist. For the sake of argument, let’s call the method &lt;strong&gt;NonexistentMethod(),&lt;/strong&gt; which is shown in Listing 5. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Listing 5: This code contains a call to a method called NonexistentMethod() that does not exist in our Test.py file. As a result, the call will fail at runtime.&lt;/strong&gt;&lt;/p&gt;&lt;pre class="myclass"&gt; var ipy = Python.CreateRuntime();
dynamic test = ipy.UseFile("Test.py");
test.Simple();            // Succeeds
test.NonexistentMethod(); // Fails&lt;/pre&gt;
&lt;p&gt;The code in Listing 5 contains a call to the method &lt;strong&gt;Simple()&lt;/strong&gt; that will succeed, since the Python script shown in Listing 2 does contain a method called &lt;strong&gt;Simple()&lt;/strong&gt;. However, the call to the method &lt;strong&gt;NonexistentMethod()&lt;/strong&gt; will raise an exception at runtime. This happens because the call cannot be resolved at runtime. At compile time, however, the compiler knows nothing about the object called &lt;strong&gt;test&lt;/strong&gt;. It makes no attempt to see whether or not the call will succeed. It simply takes your word for it and allows the compilation to succeed. At runtime, however, the error raises its head, as shown in Figure 4 and Listing 6.&lt;/p&gt;
&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure03a" border="0" alt="Figure03a" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HostingIronPythoninaC4.0Program_147F2/Figure03a_3.png" width="456" height="256"&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Figure 4: The exception raised inside the IDE at runtime when you attempt to call a method that does not exist.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Listing 6: The details of the exception that you receive at runtime when you attempt to call a method that does not exist.&lt;/strong&gt;&lt;/p&gt;&lt;pre class="myclass"&gt;Microsoft.CSharp.RuntimeBinder.RuntimeBinderException was unhandled
  Message='Microsoft.Scripting.Hosting.ScriptScope' does not contain a definition for 'NonexistentMethod'
  Source=Anonymously Hosted DynamicMethods Assembly
  StackTrace:
       at CallSite.Target(Closure , CallSite , Object )
       at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid1[T0](CallSite site, T0 arg0)
       at dynamic_demo.Main() in C:\Users\Charlie\Documents\SyncData\Source\ProjectsShared\Python\CallPython\CallPython\Program.cs:line 12
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
&lt;/pre&gt;
&lt;p&gt;The team went to lengths to ensure that the error you get at runtime looks almost exactly like the error you would have received at compile time had you attempted to call a static method that did not exist. Everything possible is done to make this experience easy for your to understand and handle, including giving you an exception that you can catch with your own custom code. &lt;/p&gt;
&lt;p&gt;It goes without saying that everyone on the Visual Studio Languages team at Microsoft understands the implications of introducing the &lt;strong&gt;dynamic&lt;/strong&gt; keyword into the C# language. We understand completely the advantages of statically linked code, and believe that strict type checking is a powerful tool that helps developers create robust code. In most cases, you should still use statically linked calls in your program. There are, however, scenarios that cannot be efficiently supported from the C# language without the introduction of dynamic programming. One is calling a dynamic language such as Python, and another is calling into a some COM objects, such as those used in those used by Microsoft Office. In order to make it easy for you to use dynamic languages and to perform COM Interop, the dynamic keyword was introduced into the C# 4.0 language, and the DLR became a built-in extension of .NET 4.0. Use these tools judiciously, and they will be your friend. Abuse them, and you are on your own.&lt;/p&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;p&gt;In this article you learned how to call a simple Python script from a C# application. You saw how to set up the &lt;strong&gt;References&lt;/strong&gt; section for your program so that it contains the assemblies used when calling an IronPython script. You then saw how to write a simple Python script, and how to call it from a C# program.&lt;/p&gt;
&lt;p&gt;The dynamic technology on display in this example makes use of a body of code called the DLR, or Dynamic Language Runtime. The &lt;strong&gt;dynamic&lt;/strong&gt; keyword that is part of C# 4.0 provides supports when you call dynamic languages or COM objects, and particularly when you use C# 4.0 to call into Microsoft Office applications. Coverage of calling into Office is separate subject, and will be covered in another post. A third topic deserving of coverage is using the &lt;strong&gt;dynamic&lt;/strong&gt; keyword in scenarios where you previously used reflection. &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=7927"&gt;Download Source&lt;/a&gt; from the &lt;a href="http://code.msdn.microsoft.com/linqfarm"&gt;LinqFarm&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f25%2fhosting-ironpython-in-a-c-4-0-program.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f25%2fhosting-ironpython-in-a-c-4-0-program.aspx"&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9912809" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Dynamic/default.aspx">Dynamic</category><category domain="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx">C# 4.0</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Python/default.aspx">Python</category></item><item><title>Getting Started with IronPython</title><link>http://blogs.msdn.com/charlie/archive/2009/10/25/running-ironpython.aspx</link><pubDate>Mon, 26 Oct 2009 01:03:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9912728</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9912728.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9912728</wfw:commentRss><description>&lt;style type="text/css"&gt;









 	pre.myclass {color:black; background:lightgray}
 &lt;/style&gt;  &lt;p&gt;I recently spent some time getting IronPython up and running on my system; I will review what I learned in this post. &lt;/p&gt;  &lt;p&gt;Hosted inside an interpreter, Python belongs to the same family of scripting tools as VBScript, JavaScript, Perl and Ruby. You can fairly compare Python to a general purpose language such as C#. Developers praise this loosely typed, dynamic language for its ease of use and rapid development capabilities. IronPython is Microsoft’s free version of the open source &lt;a href="http://www.python.org/"&gt;Python language&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;IronPython can be hosted inside a C# program as a scripting language. Nonetheless, Python is a powerful standalone language frequently used as the glue in web based applications. Before I came to work for Microsoft I enjoyed using it as part of my daily toolkit.&lt;/p&gt;  &lt;p&gt;In this post I explore the simple steps needed to run IronPython as a standalone tool from the command prompt. In other posts I will show how to call Python from inside a C# application.&lt;/p&gt;  &lt;h2&gt;Installing Python&lt;/h2&gt;  &lt;p&gt;I started by &lt;a href="http://blogs.msdn.com/charlie/archive/2009/10/22/ironruby-and-ironpython-for-net-4-0-beta-2-available.aspx"&gt;downloading IronPython&lt;/a&gt; from &lt;a href="http://www.codeplex.com/"&gt;CodePlex&lt;/a&gt; and installing it. The whole process from first visit to the IronPython web site until IronPython was installed probably took me little more than a minute. Below are the links to retrieve the code. If you are reading this article in 2009 or early 2010, consider using the first link, if the date is later than that then use the second link and look for a newer release:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=28125"&gt;The Beta 2 Release of IronPython&lt;/a&gt; (2.6 CTP for .NET 4.0 Beta 2) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://ironpython.codeplex.com/"&gt;IronPython Site&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Download the IronPython MSI Windows install file, then double click on it to run setup. When you are done, your IronPython installation will probably be located in a directory similar to this one:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;C:\Program Files (x86)\IronPython 2.6 CTP for .NET 4.0 Beta 2&lt;/strong&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Once you have the IronPython interpreter installed, you need to follow these steps to run a sample program:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Put IronPython on your Path &lt;/li&gt;    &lt;li&gt;Create an IronPython program &lt;/li&gt;    &lt;li&gt;Compile and run the program. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;In the next few sections of this post I’ll walk you through these steps. When you are done, you will have IronPython up and running on your system.&lt;/p&gt;  &lt;h2&gt;Setting Up Your Path&lt;/h2&gt;  &lt;p&gt;You can run IronPython from inside Visual Studio, but the tools for doing so are still primitive. Most Python developers work inside a lightweight editor and run Python from inside the IronPython interpreter or from the command line. This post focuses on building Python from the command line. To get started with that process, you will probably want to begin by ensuring that the IronPython interpreter is on your System Path. &lt;/p&gt;  &lt;p&gt;They say there must be fifty ways to set &lt;a href="http://technet.microsoft.com/en-us/library/cc753427(WS.10,loband).aspx#BKMK_examples"&gt;the system path&lt;/a&gt;. In this post I will outline two of them as practiced by developers on Vista or Windows 7. In both cases you can begin with a four step process to bring up the &lt;strong&gt;Environment Variables Dialog&lt;/strong&gt;:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Method One      &lt;ul&gt;       &lt;li&gt;Press the Windows Key to bring up the Start Menu &lt;/li&gt;        &lt;li&gt;Right click on &lt;strong&gt;Computer&lt;/strong&gt; and choose &lt;strong&gt;Properties&lt;/strong&gt; &lt;/li&gt;        &lt;li&gt;Click &lt;strong&gt;Advanced Computer Settings&lt;/strong&gt; &lt;/li&gt;        &lt;li&gt;Click &lt;strong&gt;Environment&lt;/strong&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Method Two      &lt;ul&gt;       &lt;li&gt;Press the Windows Key to ring up the Start Menu &lt;/li&gt;        &lt;li&gt;Type &lt;strong&gt;Control Panel&lt;/strong&gt; and press enter &lt;/li&gt;        &lt;li&gt;You should be taken automatically to the search box on the top right of the control panel, if not, press Ctrl-E to get there and type &lt;strong&gt;Environment. &lt;/strong&gt;(The first three letters should be all that’s necessary) &lt;/li&gt;        &lt;li&gt;Hit tab twice to select &lt;strong&gt;Edit Environment Variables&lt;/strong&gt;, and then hit enter. &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Which ever technique you use, the dialog shown in Figure 1 should appear. You can use this dialog to edit the system path. &lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure01" border="0" alt="Figure01" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/RunningIronPython_D2FC/Figure01_3.png" width="398" height="440" /&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: In this screenshot, a variable called Path has been added to the list of User Variables. It lists the path to the IronPython Interpreter.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Once the dialog appears, click New (Alt-N) to add a &lt;strong&gt;Path&lt;/strong&gt; variable for your account. A small dialog appears. Paste the path to IronPython into this dialog and click the OK button. The path should be similar to the path shown above which points to the directory where IronPython was installed. Click OK to close the Environment Variables dialog. From now on, and Command prompt window that you open should have an environment automatically set up to point to the IronPython interpreter. To test that everything is working correctly, go to the command prompt and type &lt;strong&gt;ipy&lt;/strong&gt;. If everything has gone well, you should see a result like the following. &lt;/p&gt;  &lt;pre class="myclass"&gt;C:\Users\Charlie\Documents\Python\PythonPost&amp;gt;ipy
IronPython 2.6 (2.6.10920.0) on .NET 4.0.21006.1
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.
&amp;gt;&amp;gt;&amp;gt; exit()&lt;/pre&gt;

&lt;p&gt;As shown above, you can type&lt;strong&gt; exit()&lt;/strong&gt; and then &lt;strong&gt;enter&lt;/strong&gt; to quit the interpreter. You can also execute Python code from inside the interpreter. Working interactively inside the interpreter is a useful and powerful way to write code, but I will not cover it in this post.&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;Create a Python Program&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;Now that you have Python on your path, you can easily compile your projects from the command line. Depending on your tastes, you can edit your program in Visual Studio, in NotePad, or in &lt;a href="http://notepad-plus.sourceforge.net/"&gt;NotePad++&lt;/a&gt;. The goal is to create a simple text-based source file with the letters py as an extension. Here, for example, is the complete contents of a simple Python source file:&lt;/p&gt;

&lt;pre class="myclass"&gt;&lt;font color="#0000ff"&gt;print&lt;/font&gt; &amp;quot;Very Simple Test&amp;quot;&lt;/pre&gt;

&lt;p&gt;You can save this source file as &lt;strong&gt;VerySimpleTest.py&lt;/strong&gt;, and process and run it by passing its name to the Python interpreter. The interpreter will process and run the program:&lt;/p&gt;

&lt;pre class="myclass"&gt;C:\Users\Charlie\Documents\Python\PythonPost&amp;gt;ipy VerySmipleTest.py.
Very Simple Test&lt;/pre&gt;

&lt;p&gt;Now that you understand the basics, the next step is to understand how to create functions, classes and multiple module projects. &lt;/p&gt;

&lt;p&gt;Python uses indentation rather than keywords or syntax to define blocks of code. Here, for instance, is how to define a function in Python:&lt;/p&gt;

&lt;pre class="myclass"&gt;def WriteTest():
	print &amp;quot;This is a test&amp;quot;&lt;/pre&gt;

&lt;p&gt;The keyword &lt;strong&gt;def&lt;/strong&gt; followed by a name and a colon defines the header for the function. The next line begins with tab character. This defines the beginning of main block for the function, which in this case contains a single line of code. If you had multiple lines in the function, then you would indent each line with a tab character. An empty line defines the end of the function.&lt;/p&gt;

&lt;p&gt;To define a class, you repeat the same process, but use the keyword &lt;strong&gt;class&lt;/strong&gt; rather than &lt;strong&gt;def&lt;/strong&gt;:&lt;/p&gt;

&lt;pre class="myclass"&gt;class SimpleLocalClass:
	def SimpleMethod(self):
		print &amp;quot;Simple Local Class&amp;quot;&lt;/pre&gt;

&lt;p&gt;Here you see the definition for a class called &lt;strong&gt;SimpleLocalClass&lt;/strong&gt; which has a single method called &lt;strong&gt;SimpleMethod&lt;/strong&gt;. Not everyone likes the Python syntax for defining classes and methods, but I have found intuitive and easy to use. &lt;/p&gt;

&lt;p&gt;Listings 1 and 2 contain a project with two files that demonstrates how to use functions and classes in Python:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Listing 1: Here is the main module for the project. It is a simple source file called &lt;u&gt;&lt;em&gt;Project.py&lt;/em&gt;&lt;/u&gt; containing a function and a simple class. This source file also has a dependency on a class called &lt;em&gt;&lt;u&gt;SimpleClassTest&lt;/u&gt;&lt;/em&gt; that is shown in Listing 2&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="myclass"&gt;from SimpleClass import SimpleClassTest

class SimpleLocalClass:
	def SimpleMethod(self):
		print &amp;quot;Simple Local Class&amp;quot;

def WriteTest():
	print &amp;quot;This is a test&amp;quot;
	
WriteTest()

simpleLocalClass = SimpleLocalClass()
simpleLocalClass.SimpleMethod()

simpleClass = SimpleClassTest()
simpleClass.SimpleMethod()	&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Listing 2: The second file in this project is called &lt;/strong&gt;&lt;u&gt;&lt;em&gt;SimpleClass.py&lt;/em&gt;&lt;/u&gt;&lt;strong&gt;. The file shown in Listing 1 depends on this class.&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="myclass"&gt;class SimpleClassTest:
	def SimpleMethod(self):
		print &amp;quot;Simple Class&amp;quot;&lt;/pre&gt;

&lt;p&gt;Notice the &lt;strong&gt;from&lt;/strong&gt; statement at the top of Listing 1. It is used to import the class found in Listing 2. I should also point out that there is no &lt;strong&gt;main()&lt;/strong&gt; method shown in listing 1. The word &lt;strong&gt;main&lt;/strong&gt; does not have the same significance in Python that it does in C#. The entry point for this Python program is the last set of un-indented statements found in &lt;strong&gt;Project.py&lt;/strong&gt;&lt;strong&gt;. &lt;/strong&gt;In this case the entry point begins with the call to &lt;strong&gt;WriteTest().&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;Compiling and Running the Program&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;Now that you have the two source files for your project, all you need do is compile and run them. The Python interpreter is designed to make this task as simple as possible. You need only reference the primary file for your project, the interpreter is smart enough to to parse the &lt;strong&gt;from&lt;/strong&gt; import statement at the top of Listing 1 and figure out from that how to include &lt;strong&gt;SimpleClass.py&lt;/strong&gt; in the project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Listing 3: Here is the command to process and run the files shown in Listings 1 and 2. The output from the command is also shown.&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="myclass"&gt;C:\Users\Charlie\Python\PythonPost&amp;gt;ipy Project.py
This is a test
Simple Local Class
Simple Class&lt;/pre&gt;

&lt;h2&gt;Summary &lt;/h2&gt;

&lt;p&gt;In this post I have reviewed how to download and install IronPython, and how to get some simple Python scripts up and running on your system. You saw how to run a simple program from the command line, how to create:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A simple function&lt;/li&gt;

  &lt;li&gt;A simple class&lt;/li&gt;

  &lt;li&gt;And a mutli-module project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In future posts I will focus on calling IronPython from a C# program.&lt;/p&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f25%2frunning-ironpython.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f25%2frunning-ironpython.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9912728" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Dynamic/default.aspx">Dynamic</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Python/default.aspx">Python</category></item></channel></rss>