<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/atomfull.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><feed xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="0.3" xml:lang="en-US"><title>Daniel Cazzulino's Blog</title><link rel="alternate" type="text/html" href="http://www.clariusconsulting.net/blogs/kzu/default.aspx" /><tagline type="text/html">data wants to be free, and xml is the key</tagline><id>http://www.clariusconsulting.net/blogs/kzu/default.aspx</id><author><url>http://www.clariusconsulting.net/blogs/kzu/default.aspx</url></author><generator url="http://communityserver.org" version="1.0.1.50214">Community Server</generator><modified>2008-07-18T02:42:44Z</modified><creativeCommons:license>http://creativecommons.org/licenses/by/3.0/</creativeCommons:license><link rel="start" href="http://feeds.feedburner.com/DanielCazzulino" type="application/atom+xml" /><feedburner:emailServiceId>546556</feedburner:emailServiceId><feedburner:feedburnerHostname>http://www.feedburner.com</feedburner:feedburnerHostname><entry><title>PDC Essentials @ Buenos Aires</title><link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/DanielCazzulino/~3/456035704/112739.aspx" /><id>e6de741d-39cb-46fc-b8ae-6ce6880bcef9:112739</id><created>2008-11-17T06:32:08Z</created><content type="text/html" mode="escaped">&lt;p&gt;On Tuesday 18th, &lt;a href="http://clariusconsulting.net/vga"&gt;Victor&lt;/a&gt; and I will be presenting A Lap Around VS2010. Check which other talks are available and register &lt;a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032394696&amp;amp;Culture=es-AR"&gt;here&lt;/a&gt;. &lt;p&gt;This is the event information: &lt;ul&gt; &lt;li&gt;Horario: martes, 18 de noviembre de 2008 16:00 - 22:00 p.m.  &lt;li&gt;Lugar: ITTC. Sarmiento 1113 Piso 5. Buenos Aires Argentina.  &lt;li&gt;&lt;a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032394696&amp;amp;Culture=es-AR"&gt;Registración&lt;/a&gt; &lt;li&gt;Descripción:  &lt;p&gt;Durante los días del 27 al 30 de Octubre se lleva a cabo la Professional Developer Conference en Los Angeles, Estados Unidos. Durante este evento Microsoft realiza grandes anuncios sobre novedades en la plataforma de desarrollo, presentando su visión de Cloud Computing, construyendo aplicaciones que desdibujan las barreras entre la PC, la Web y los dispositivos móviles, lo nuevo en VS 2010, .net Framework 4, distintos avances sobre Windows 7, la siguiente mayor versión de la plataforma cliente Windows y mucho más. En este evento, estaremos presentando algunas de las novedades develadas durante el evento, contando con disertantes asistentes al mismo.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp; &lt;p&gt;My friends &lt;a href="http://weblogs.manas.com.ar/bcardiff/2008/11/pdc-essentials-buenos-aires/"&gt;Brian&lt;/a&gt; and &lt;a href="http://weblogs.manas.com.ar/waj/"&gt;Juan&lt;/a&gt; will also be presenting :)&lt;/p&gt;&lt;img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=112739" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=wUbgN"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=wUbgN" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=0yoTn"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=0yoTn" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=bsfMN"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=bsfMN" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DanielCazzulino/~4/456035704" height="1" width="1"/&gt;</content><slash:comments>1</slash:comments><wfw:commentRss>http://www.clariusconsulting.net/blogs/kzu/commentrss.aspx?PostID=112739</wfw:commentRss><feedburner:origLink>http://www.clariusconsulting.net/blogs/kzu/archive/2008/11/17/112739.aspx</feedburner:origLink></entry><entry><title>XmlSerializerFactory caching issues and leaks</title><link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/DanielCazzulino/~3/452489961/XmlSerializerFactorycachingissuesandleaks.aspx" /><id>e6de741d-39cb-46fc-b8ae-6ce6880bcef9:112025</id><created>2008-11-13T19:42:32Z</created><content type="text/html" mode="escaped">&lt;p&gt;You'd think that after the &lt;a href="http://www.google.com.ar/search?client=firefox-a&amp;amp;rls=org.mozilla%3Aen-US%3Aofficial&amp;amp;channel=s&amp;amp;hl=en&amp;amp;q=xmlserializer%20leaks"&gt;serious leaks&lt;/a&gt; people was hitting with the XmlSerializer, the "new" (in .NET 2.0!!! but which many seem to forget about, just like AVOID doing &lt;a title="My tweet in real-time from PDC on the mostruosity :)" href="http://twitter.com/kzu/status/979325718"&gt;new XmlTextReader in a PDC *keynote*&lt;/a&gt;) &lt;a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializerfactory.aspx"&gt;XmlSerializerFactory&lt;/a&gt; would &lt;a href="http://blogs.msdn.com/kaevans/archive/2006/03/08/546172.aspx"&gt;do away with those&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;Well, bad news: you need to be AS careful as you are with the XmlSerializer in order to avoid those leaks (which are &lt;a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=98384"&gt;BY DESIGN&lt;/a&gt;, BTW). Turns out that apparently the same designer made the same "by design" decisions with the XmlSerializerFactory.&lt;/p&gt; &lt;p&gt;For those not using the factory yet: it was basically meant to be the cache of XmlSerializer types that you had to do manually in the past). If provides a factory method with all the same overloads the XmlSerializer receives and hands you back an instance of a serializer, supposedly caching the generated types (as the &lt;a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializerfactory_members.aspx"&gt;documentation says&lt;/a&gt;: "Creates typed versions of the &lt;a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx"&gt;XmlSerializer&lt;/a&gt; for more efficient serialization."). You can read my friend &lt;a href="http://blogs.msdn.com/kaevans/archive/2006/03/08/546172.aspx"&gt;Kirk's blog&lt;/a&gt; on how to use the factory.&lt;/p&gt; &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializerfactory.createserializer.aspx"&gt;Nowhere does the documentation mention&lt;/a&gt; that depending on which overloads you use, the cache will be in effect or not, JUST LIKE THE "good" old XmlSerializer!!! &lt;/p&gt; &lt;p&gt;VERY easy repro:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Program
&lt;/span&gt;{
    &lt;span style="color: blue"&gt;static void &lt;/span&gt;Main(&lt;span style="color: blue"&gt;string&lt;/span&gt;[] args)
    {
        &lt;span style="color: blue"&gt;var &lt;/span&gt;factory = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlSerializerFactory&lt;/span&gt;();

        &lt;span style="color: blue"&gt;var &lt;/span&gt;cached1 = factory.CreateSerializer(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Foo&lt;/span&gt;));
        &lt;span style="color: blue"&gt;var &lt;/span&gt;cached2 = factory.CreateSerializer(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Foo&lt;/span&gt;));

        &lt;span style="color: green"&gt;// IT WORKS!!! RIGHT???
        &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Debug&lt;/span&gt;.Assert(cached1.GetType() == cached2.GetType());

        &lt;span style="color: blue"&gt;var &lt;/span&gt;serializer1 = factory.CreateSerializer(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Foo&lt;/span&gt;), &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRootAttribute&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"foo"&lt;/span&gt;));
        &lt;span style="color: blue"&gt;var &lt;/span&gt;serializer2 = factory.CreateSerializer(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Foo&lt;/span&gt;), &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRootAttribute&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"foo"&lt;/span&gt;));
        &lt;span style="color: blue"&gt;var &lt;/span&gt;serializer3 = factory.CreateSerializer(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Foo&lt;/span&gt;), &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRootAttribute&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"foo"&lt;/span&gt;));
        &lt;span style="color: blue"&gt;var &lt;/span&gt;serializer4 = factory.CreateSerializer(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Foo&lt;/span&gt;), &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlRootAttribute&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"foo"&lt;/span&gt;));

        &lt;span style="color: blue"&gt;var &lt;/span&gt;allsame = serializer1.GetType() == serializer2.GetType();
        allsame &amp;amp;= serializer2.GetType() == serializer3.GetType();
        allsame &amp;amp;= serializer3.GetType() == serializer4.GetType();

        &lt;span style="color: green"&gt;// FAIL!!!!!
        &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Debug&lt;/span&gt;.Assert(allsame);
    }
}

&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Foo &lt;/span&gt;{ }&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now, I understand the myriad of overloads supported by the class are hard to manage, but how hard do you think it is to create a smart cache key that properly compares if the XmlRootAttribute I'm passing, which has only four properties to compare, is the same I passed before and therefore hand me a cached type??&lt;/p&gt;
&lt;p&gt;Very dissapointing. I had to (once again) implement this myself (on the &lt;a href="http://code.google.com/p/netfx/source/browse/trunk/Source/Collections/Generic/SerializableDictionary.cs"&gt;ULTIMATE serializable generics dictionary&lt;/a&gt; I'll EVER need to write, which I'll blog about sometime...). This time I even used dynamic method generation to have a blazingly fast instantiation of the cached generated type :). Another time I said... &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Anyway, &lt;a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=381858"&gt;please vote for the bug&lt;/a&gt; so this gets fixed (hopefully it's not too late for C# 4.0!).&lt;/p&gt;&lt;img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=112025" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=NhhON"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=NhhON" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=WNFfn"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=WNFfn" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=y4itN"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=y4itN" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DanielCazzulino/~4/452489961" height="1" width="1"/&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://www.clariusconsulting.net/blogs/kzu/commentrss.aspx?PostID=112025</wfw:commentRss><feedburner:origLink>http://www.clariusconsulting.net/blogs/kzu/archive/2008/11/13/XmlSerializerFactorycachingissuesandleaks.aspx</feedburner:origLink></entry><entry><title>Weird procedure to activate Windows 2008 from MSDN subscription</title><link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/DanielCazzulino/~3/431976320/WeirdproceduretoactivateWindows2008fromMSDNsubscription.aspx" /><id>e6de741d-39cb-46fc-b8ae-6ce6880bcef9:106628</id><created>2008-10-25T12:33:08Z</created><content type="text/html" mode="escaped">&lt;p&gt;I kept getting a "Activation Error: Code 0x8007232b DNS Name does not exist" error whenever I tried to activate Windows 2008 Standard (which has been running great on my X61 laptop so far as the host OS!).&lt;/p&gt; &lt;p&gt;Weird procedure you have to follow to activate: &lt;/p&gt;&lt;a href="http://snowstormlife.com/blogs/bliz/archive/2008/02/11/activate-windows-server-2008-rtm-msdn-subscriber-downloads-version.aspx"&gt;Activate Windows Server 2008 RTM (MSDN Subscriber Downloads version)&lt;/a&gt;&lt;img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=106628" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=t2oyM"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=t2oyM" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=0uQjm"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=0uQjm" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=DgVSM"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=DgVSM" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DanielCazzulino/~4/431976320" height="1" width="1"/&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://www.clariusconsulting.net/blogs/kzu/commentrss.aspx?PostID=106628</wfw:commentRss><feedburner:origLink>http://www.clariusconsulting.net/blogs/kzu/archive/2008/10/25/WeirdproceduretoactivateWindows2008fromMSDNsubscription.aspx</feedburner:origLink></entry><entry><title>How to use Windows 2008 on your laptop</title><link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/DanielCazzulino/~3/428066091/HowtouseWindows2008onyourlaptop.aspx" /><id>e6de741d-39cb-46fc-b8ae-6ce6880bcef9:104096</id><created>2008-10-21T18:45:27Z</created><content type="text/html" mode="escaped">&lt;ul&gt; &lt;li&gt;Follow all the tips from &lt;a href="http://www.win2008workstation.com/"&gt;Windows 2008 Workstation&lt;/a&gt; site. &lt;a href="http://support.microsoft.com/kb/947036"&gt;Microsoft has a KB article&lt;/a&gt; also that is useful.  &lt;li&gt;Get &lt;a href="http://www.softpedia.com/progDownload/MSN-Messenger-8-Download-68149.html"&gt;Windows Live Messenger bare MSI from Softpedia&lt;/a&gt; (it's a MS-signed installer, worked just fine for me)  &lt;li&gt;How to get Windows Live Writer on Windows 2008: this was a bit trickier, and involves importing a few registry keys (just copy the registry keys to a .reg file and import it).  &lt;ol&gt; &lt;li&gt;First you need a machine with WLW installed. Copy the entire folder to the new machine. I copied it to %ProgramFiles%\Windows Live\Writer, which is where it'd go if I could run the proper installer.&lt;br&gt; &lt;li&gt;The following registry keys are created by the "root" Windows Live installer:  &lt;p&gt;Windows Registry Editor Version 5.00 &lt;pre class="code"&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Live\installer]
"WLXMarket"="en-us"
"WLXLanguage"="en"
"WLXVersion"="WL20" &lt;/pre&gt;
&lt;li&gt;Next the keys for WLW on HKLM (make sure the InstallDir matches the right folder where you copied the binaries): 
&lt;p&gt;Windows Registry Editor Version 5.00 &lt;pre class="code"&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Live\Writer]
"InstallDir"="C:\\Program Files (x86)\\Windows Live\\Writer\\"&lt;/pre&gt;
&lt;li&gt;Finally, export from your existing WLW installation the entire &lt;code&gt;HKEY_CURRENT_USER\Software\Microsoft\Windows Live\Writer&lt;/code&gt; key. That will bring in your current blog accounts and everything :). Make sure to fix any folders that might be different on your target machine (i.e. Documents and Settings, etc.)&lt;br&gt;
&lt;li&gt;Add a shortcut to the start menu and you're done!&lt;/li&gt;&lt;/ol&gt;
&lt;li&gt;Finally, forget about sleeping/hibernating your computer from the start menu:&lt;br&gt;&lt;br&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" alt="image" src="http://www.clariusconsulting.net/images/blogs/kzu/HowtouseWindows2008onyourlaptop_F80D/image.png"&gt; &lt;br&gt;&lt;br&gt;Even though sleep and hibernation are supported, you have to Ctrl+Alt+Del and choose the respective option which now DOES show up in that screen Shutdown Options button:&lt;br&gt;&lt;br&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" alt="image" src="http://www.clariusconsulting.net/images/blogs/kzu/HowtouseWindows2008onyourlaptop_F80D/image_3.png"&gt; &lt;br&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;So far it's been a blast using Windows 2008 in my laptop. Vista x64 was becoming truly unusable, even with a 7200RPM disc, 4GB RAM and 2.2Ghz proc.&lt;/p&gt;&lt;img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=104096" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=fUE1M"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=fUE1M" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=h3Dam"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=h3Dam" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=uxPKM"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=uxPKM" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DanielCazzulino/~4/428066091" height="1" width="1"/&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://www.clariusconsulting.net/blogs/kzu/commentrss.aspx?PostID=104096</wfw:commentRss><feedburner:origLink>http://www.clariusconsulting.net/blogs/kzu/archive/2008/10/21/HowtouseWindows2008onyourlaptop.aspx</feedburner:origLink></entry><entry><title>Automocking container with Moq</title><link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/DanielCazzulino/~3/420273137/AutomockingcontainerwithMoq.aspx" /><id>e6de741d-39cb-46fc-b8ae-6ce6880bcef9:103446</id><created>2008-10-13T23:56:29Z</created><content type="text/html" mode="escaped">&lt;p&gt;I realized that I never blogged about this cool feature contributed by &lt;a href="http://code.google.com/u/slava42/"&gt;Slava&lt;/a&gt; to &lt;a href="http://code.google.com/p/moq-contrib"&gt;Moq-Contrib&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Auto-mocking containers was an idea originally (IIRC) from the guys at &lt;a href="http://blog.eleutian.com/CommentView,guid,762249da-e25a-4503-8f20-c6d59b1a69bc.aspx"&gt;Eleutian&lt;/a&gt;, later on &lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/02/09/automocker-in-structuremap-2-5.aspx"&gt;picked up by Jeremy Miller&lt;/a&gt; with &lt;a href="http://ayende.com/"&gt;Rhino Mocks&lt;/a&gt; and &lt;a href="http://structuremap.sourceforge.net/"&gt;StructureMap&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;The &lt;a href="http://code.google.com/p/moq-contrib/wiki/Automocking"&gt;wiki document Slava put together on Automocking&lt;/a&gt; is a fantastic overview. Basically, you can have an (&lt;a href="http://autofac.googlecode.com/"&gt;Autofac&lt;/a&gt;-powered) container create your objects under test with all its dependencies injected as mocks:&lt;/p&gt;&lt;pre class="code"&gt;var factory = new MockFactory(MockBehavior.Loose);&lt;br&gt;var container = new AutoMockContainer(factory);&lt;br&gt;var tree = container.Create&amp;lt;Tree&amp;gt;();&lt;/pre&gt;
&lt;p&gt;Because it uses a &lt;a href="http://www.clariusconsulting.net/labs/moq/html/4C85C26D.htm"&gt;MockFactory&lt;/a&gt;, it also integrates with the rest of the features in Moq that are available through the factory, such as consistent settings for &lt;a href="http://www.clariusconsulting.net/labs/moq/html/90760C57.htm"&gt;mock behavior&lt;/a&gt;, whether to &lt;a href="http://www.clariusconsulting.net/labs/moq/html/B8B2A0F0.htm"&gt;call base class implementations&lt;/a&gt;, and the &lt;a href="http://www.clariusconsulting.net/labs/moq/html/186CEE4D.htm"&gt;default value behavior&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Go ahead and &lt;a href="http://code.google.com/p/moq-contrib/wiki/Automocking"&gt;read the wiki&lt;/a&gt; and &lt;a href="http://code.google.com/p/moq-contrib"&gt;get the bits&lt;/a&gt;!&lt;/p&gt;&lt;img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=103446" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=RxIrM"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=RxIrM" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=1SZ0m"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=1SZ0m" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=RvatM"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=RvatM" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DanielCazzulino/~4/420273137" height="1" width="1"/&gt;</content><slash:comments>1</slash:comments><wfw:commentRss>http://www.clariusconsulting.net/blogs/kzu/commentrss.aspx?PostID=103446</wfw:commentRss><feedburner:origLink>http://www.clariusconsulting.net/blogs/kzu/archive/2008/10/13/AutomockingcontainerwithMoq.aspx</feedburner:origLink></entry><entry><title>Where was the stubbing part in Moq?</title><link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/DanielCazzulino/~3/419254076/102928.aspx" /><id>e6de741d-39cb-46fc-b8ae-6ce6880bcef9:102928</id><created>2008-10-12T23:51:26Z</created><content type="text/html" mode="escaped">&lt;p&gt;In my &lt;a href="http://www.clariusconsulting.net/blogs/kzu/archive/2008/10/12/102921.aspx"&gt;very recent previous post&lt;/a&gt; I said "mocking and stubbing easier than ever", but actually forgot to mention the stubbing part :S.&lt;/p&gt; &lt;p&gt;This one is not new for users of &lt;a href="http://moq-contrib.googlecode.com"&gt;moq-contrib&lt;/a&gt;, but we decided to move this to the core Moq library as we get the question on how to stub properties often enough... :)&lt;/p&gt; &lt;p&gt;It's actually rather simple and easy to implement just by using Moq external API, but as a facility, here's what you can do:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;mock = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Mock&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;IHaveValue&lt;/span&gt;&amp;gt;();
&lt;span style="color: green"&gt;// start "tracking" sets/gets to this property
&lt;/span&gt;mock.Stub(v =&amp;gt; v.Value);
&lt;span style="color: green"&gt;// alternatively, provide a default value for the stubbed property
&lt;/span&gt;mock.Stub(v =&amp;gt; v.Value, 5);

&lt;span style="color: green"&gt;// Now you can do:

&lt;/span&gt;&lt;span style="color: #2b91af"&gt;IHaveValue &lt;/span&gt;hv = mock.Object;
&lt;span style="color: green"&gt;// Initial value was stored
&lt;/span&gt;&lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.Equal(5, hv.Value);

&lt;span style="color: green"&gt;// New value set which changes the initial value
&lt;/span&gt;hv.Value = 6;
&lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.Equal(6, hv.Value);
&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What is new in this version beyond the original &lt;a href="http://moq-contrib.googlecode.com"&gt;moq-contrib&lt;/a&gt; stubbing, is the ability to stub all properties of the object in a single call:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;mock = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Mock&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;IFoo&lt;/span&gt;&amp;gt;();
mock.StubAll();
&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;This feature integrates seamlessly with the default value behavior specified for the mock, as explained in the &lt;a href="http://www.clariusconsulting.net/blogs/kzu/archive/2008/10/12/102921.aspx"&gt;previous post&lt;/a&gt;, meaning that you can stub all properties and cause them to return new mocks when appropriate, also recursively (but lazily!), in a single call. This may be redundant to note, but it's just to point that the API and behavior is still consistent.&lt;/p&gt;
&lt;p&gt;If you want to have some fun reading rather crazy reflection API usage to invoke various generic methods including ones receiving Func&amp;lt;T&amp;gt; and passing function pointers with it, &lt;a href="http://code.google.com/p/moq/source/browse/trunk/Source/Stub/StubExtensions.cs"&gt;go ahead&lt;/a&gt;. It was FUN :).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Next: out/ref parameters in Moq!!!&lt;/p&gt;&lt;img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=102928" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=DkkfM"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=DkkfM" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=K3Frm"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=K3Frm" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=2eZGM"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=2eZGM" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DanielCazzulino/~4/419254076" height="1" width="1"/&gt;</content><slash:comments>2</slash:comments><wfw:commentRss>http://www.clariusconsulting.net/blogs/kzu/commentrss.aspx?PostID=102928</wfw:commentRss><feedburner:origLink>http://www.clariusconsulting.net/blogs/kzu/archive/2008/10/12/102928.aspx</feedburner:origLink></entry><entry><title>Mocking and stubbing easier than ever with Moq 2.6</title><link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/DanielCazzulino/~3/419235089/102921.aspx" /><id>e6de741d-39cb-46fc-b8ae-6ce6880bcef9:102921</id><created>2008-10-12T23:11:41Z</created><content type="text/html" mode="escaped">&lt;p&gt;I've just released a new version of &lt;a href="http://moq.me"&gt;Moq&lt;/a&gt; which contains a few bug fixes but two extremely useful features: recursive mocks and mocked default values.&lt;/p&gt; &lt;h2&gt;Recursive mocks&lt;/h2&gt; &lt;p&gt;Quite often you have a root mock object from which other mocks should "hang" through property accesses, such as HttpContextBase.Response: you want the response object returned to also be a mock. &lt;/p&gt; &lt;p&gt;Setting such hierarchies before this release was quite verbose:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;context = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Mock&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;HttpContextBase&lt;/span&gt;&amp;gt;();
&lt;span style="color: blue"&gt;var &lt;/span&gt;response = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Mock&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;HttpResponseBase&lt;/span&gt;&amp;gt;();

context.Expect(c =&amp;gt; c.Response).Returns(response.Object);
response.Expect(r =&amp;gt; r.ContentType).Returns(&lt;span style="color: #a31515"&gt;"application/xml"&lt;/span&gt;);&lt;/pre&gt;
&lt;p&gt;In this new release, it's possible to just use your root object to set expectations on any path in the hierarchy, so the above turns to:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;context = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Mock&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;HttpContextBase&lt;/span&gt;&amp;gt;();

context.Expect(c =&amp;gt; c.Response.ContentType).Returns(&lt;span style="color: #a31515"&gt;"application/xml"&lt;/span&gt;);
&lt;/pre&gt;
&lt;p&gt;The auto-mocked properties have the same behavior as the "owning" mock.&lt;/p&gt;
&lt;p&gt;I've found this extremely useful and right now it's also supported in TypeMock and soon (I hope) followed by Rhino too.&lt;/p&gt;
&lt;h2&gt;Mocked default values&lt;/h2&gt;
&lt;p&gt;In Moq, your mocks are by default "loose", so they never throw exceptions when they are invoked without a corresponding expectation. Most people find this very intuitive as a default, but sometimes wish some properties returned mocks instead. In spirit, this is similar to recursive mocks, but it's more of a lazy-on-demand creation of mocks as needed, without the need to set expectations on anyone. &lt;/p&gt;
&lt;p&gt;Following the example above, you could create the context like so (note the added property to set the default value behavior):&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;context = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Mock&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;HttpContextBase&lt;/span&gt;&amp;gt; { DefaultValue = DefaultValue.Mock };
&lt;font color="#0000ff"&gt;&lt;/font&gt;
&lt;span style="color: blue"&gt;var &lt;/span&gt;response = context.Response; // will be non-null, an auto-generated mock!&lt;br&gt;// I could set further expectations on this object, by retrieving its corresponding Mock&lt;br&gt;Mock.Get(response).Expect(r =&amp;gt; r.ContentType).Returns(&lt;span style="color: #a31515"&gt;"application/xml"&lt;/span&gt;);&lt;/pre&gt;
&lt;p&gt;The setting is recursive, so if I request a property from the response mock that is also of a mock-able type, I'd get a mock too. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Both are closely related, and maybe they could both be called "recursive mocks" if you will. &lt;/p&gt;
&lt;p&gt;One of the coolest things in Moq (IMO) continues to be the transparent continuum between fake/stub/mock which basically depends on how you use the one and only "moq" :). &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;On top of that, I got a really cool domain name for the project: &lt;a href="http://moq.me"&gt;http://moq.me&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Feedback welcomed on both features!&amp;nbsp; Next I have to write about future directions... &lt;/p&gt;&lt;img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=102921" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=qdaFM"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=qdaFM" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=CvaWm"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=CvaWm" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=tJQPM"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=tJQPM" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DanielCazzulino/~4/419235089" height="1" width="1"/&gt;</content><slash:comments>5</slash:comments><wfw:commentRss>http://www.clariusconsulting.net/blogs/kzu/commentrss.aspx?PostID=102921</wfw:commentRss><feedburner:origLink>http://www.clariusconsulting.net/blogs/kzu/archive/2008/10/12/102921.aspx</feedburner:origLink></entry><entry><title>What is all the fuzz about the new common IServiceLocator</title><link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/DanielCazzulino/~3/410256311/WhatisallthefuzzaboutthenewcommonIServiceLocator.aspx" /><id>e6de741d-39cb-46fc-b8ae-6ce6880bcef9:99008</id><created>2008-10-03T06:35:24Z</created><content type="text/html" mode="escaped">&lt;p&gt;There's been &lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/08/16/it-s-time-for-ioc-container-detente.aspx"&gt;some&lt;/a&gt; &lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/08/16/it-s-time-for-ioc-container-detente.aspx"&gt;excitement&lt;/a&gt; &lt;a href="http://www.tavaresstudios.com/Blog/post/Announcing-The-IServiceLocator-interface.aspx"&gt;lately&lt;/a&gt; about the introduction of a &lt;a href="http://www.codeplex.com/CommonServiceLocator"&gt;common IServiceLocator&lt;/a&gt; that all major DI containers apparently will provide.&lt;/p&gt; &lt;p&gt;Unless you're building an "&lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/08/16/it-s-time-for-ioc-container-detente.aspx"&gt;extensible framework leveraging framework consumer selectable IoC containers&lt;/a&gt;", don't sweat it too much, the interface was NOT created for you!&lt;/p&gt; &lt;p&gt;Let me reiterate: adding a dependency on IServiceLocator to your classes is NOT a good idea. When you do so, instead of an explicit and self documenting dependency on an external object, you're tunneling this locator that now hides to the class consumers which are its true dependencies. This is BAD, as it requires users to go to your class documentation (and hope it's updated) rather than its constructor to see what it needs to operate. If you've done any kind of work extending VS you know how bad this can get.&lt;/p&gt; &lt;p&gt;I've seen comments that this is just a "purist" view and that the real world ain't like this and you still need it.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Somehow some people seem to think that we (those who have contributed some &lt;a href="http://mockframeworks.com/moq"&gt;open source framework&lt;/a&gt; of sorts) don't work on real projects and live in an ideal world and make frameworks for these ideal situations which don't actually translate to your real world. That we somehow just dream about the ideal conditions and spit a framework accordingly.&lt;/p&gt; &lt;p&gt;Oh that's so wrong ;). I wish it were that way sometimes, though, hehe.&lt;/p&gt; &lt;p&gt;I speak from experience in actual projects (working on two of them simultaneously these days, one of them fairly large), and let me repeat: &lt;strong&gt;YOU DON'T NEED A DEPENDENCY ON IServiceLocator&lt;/strong&gt; in your business objects.&lt;/p&gt; &lt;p&gt;What you might need is to change your DI framework of choice if it doesn't allow you to get rid of that dependency ;).&lt;br&gt;Let me elaborate on some of the situations that supposedly require so:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Named instances: just move the named instance requirement outside the bz class and into the container configuration:&lt;br&gt;&lt;pre&gt;builder.Register&amp;lt;IBar&amp;gt;(c =&amp;gt; new Bar(c.Resolve&amp;lt;IFoo&amp;gt;("a"))); &lt;/pre&gt;
&lt;li&gt;Need all instances of X: again, move the dependency out of your bz class and into configuration!&lt;br&gt;&lt;pre&gt;builder.Register&amp;lt;IBar&amp;gt;(c =&amp;gt; new Bar( /* get an IEnumerable&amp;lt;T&amp;gt; from container, or whatever */&amp;nbsp; )); &lt;/pre&gt;
&lt;li&gt;Need to create new instances of components inside your bz class (that is, you need a factory?): register a Func&amp;lt;T&amp;gt; factory for your component!&lt;br&gt;&lt;pre&gt;builder.RegisterGeneratedFactory&amp;lt;Func&amp;lt;IBar&amp;gt;&amp;gt;();

ctor Foo(Func&amp;lt;IBar&amp;gt; barFactory);

// Foo needs a new bar?&lt;br&gt;var b = barFactory();&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;br&gt;If you can come up with a real world scenario (which does NOT involve authoring a framework such as ASP.NET MVC, MonoRail, etc.) where a good DI container cannot save you from having that dependency, only then I'll believe you need IServiceLocator. &lt;/p&gt;
&lt;p&gt;I'd argue that people that should care/use such a thing is even less than 1%. That's why I wouldn't go about publicizing this thing so much, and you should hardly care about it. I can see it applied by (non-DI) framework authors to enable different DI frameworks to be plugged-in, but I hardly see how anyone doing "real world" work would benefit rather than detriment from its use.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There you have my rant too :)&lt;/p&gt;&lt;img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=99008" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=ILFEM"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=ILFEM" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=zeMGm"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=zeMGm" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=9poUM"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=9poUM" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DanielCazzulino/~4/410256311" height="1" width="1"/&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://www.clariusconsulting.net/blogs/kzu/commentrss.aspx?PostID=99008</wfw:commentRss><feedburner:origLink>http://www.clariusconsulting.net/blogs/kzu/archive/2008/10/03/WhatisallthefuzzaboutthenewcommonIServiceLocator.aspx</feedburner:origLink></entry><entry><title>Developing orientation and resolution aware Windows Mobile applications just got a TON easier</title><link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/DanielCazzulino/~3/382440553/DevelopingorientationandresolutionawareWindowsMobileapplicationsjustgotaTONeasier.aspx" /><id>e6de741d-39cb-46fc-b8ae-6ce6880bcef9:81848</id><created>2008-09-03T08:40:10Z</created><content type="text/html" mode="escaped">&lt;p&gt;Quite some time ago I posted about how we (&lt;a href="http://clariusconsulting.net"&gt;Clarius Consulting&lt;/a&gt; with &lt;a href="http://msdn.microsoft.com/practices"&gt;Microsoft Patterns &amp;amp; Practices&lt;/a&gt;) &lt;a href="http://www.clariusconsulting.net/blogs/kzu/archive/2006/05/09/OrientationAwareIntroduction.aspx"&gt;solved the multiple resolution/orientation problem&lt;/a&gt; for Windows Mobile developers by introducing the &lt;a href="http://www.clariusconsulting.net/blogs/kzu/archive/2006/07/05/ZeroCodeAdaptiveUIs.aspx"&gt;Orientation Aware Control&lt;/a&gt; (OAC) as part of the &lt;a href="http://msdn.microsoft.com/mobileclientfactory"&gt;Mobile Client Software Factory&lt;/a&gt;. As any 6-month project, there were a number of features that had to be left out because of time constraints. Also, being two years old also shows: that version does not support smartphone project types, neither Windows Mobile 6, nor VS2008, etc. A few bugs were also discovered after being released.&lt;/p&gt; &lt;p&gt;So we took the original version, and improved it substantially, adding highly requested features and keeping it up to date with the new platforms. Just take a look at the &lt;a href="http://orientationaware.net/features.html"&gt;features and a comparison with the original p&amp;amp;p OAC&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;You can now design your mobile applications that support multiple languages, resolutions and orientations in VS2008, and take advantage of the insanely cool VS integration the OAC provides:&lt;/p&gt; &lt;p&gt;&lt;a title="Multiple Screen Designs for a Single Control" href="http://amz.orientationaware.net/img/features/ftr-03_ZOOM.gif"&gt;&lt;img src="http://amz.orientationaware.net/img/features/ftr-03.gif"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;img src="http://amz.orientationaware.net/img/videos/scr-01.gif"&gt;&amp;nbsp; &lt;/p&gt; &lt;p&gt;Last weekend the OAC reached another important milestone with its 2008 RTM version! Just go and look at the &lt;a href="http://www.orientationaware.net/videos.html"&gt;screenshots and videos&lt;/a&gt; to see it in action. I'm quite proud of this particular project, as it involved quite a bit of spelunking with VS designer infrastructure, design-time location internals, run-time location behavior, etc. &lt;/p&gt; &lt;p&gt;My friend and OAC Lead &lt;a href="http://www.mobilepractices.com/"&gt;Joe&lt;/a&gt; has blogged more about &lt;a href="http://www.mobilepractices.com/2008/09/orientation-aware-control-2008-released.html"&gt;the release and why it's important to you&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=81848" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=7xxkzL"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=7xxkzL" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=lbyxGl"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=lbyxGl" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=rdEJOL"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=rdEJOL" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DanielCazzulino/~4/382440553" height="1" width="1"/&gt;</content><slash:comments>1</slash:comments><wfw:commentRss>http://www.clariusconsulting.net/blogs/kzu/commentrss.aspx?PostID=81848</wfw:commentRss><feedburner:origLink>http://www.clariusconsulting.net/blogs/kzu/archive/2008/09/03/DevelopingorientationandresolutionawareWindowsMobileapplicationsjustgotaTONeasier.aspx</feedburner:origLink></entry><entry><title>Weirdest SQL Server 2005 installation on a Vista x64 machine</title><link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/DanielCazzulino/~3/374540466/WeirdestSQLServer2005installationonaVistax64machine.aspx" /><id>e6de741d-39cb-46fc-b8ae-6ce6880bcef9:81438</id><created>2008-08-25T12:35:24Z</created><content type="text/html" mode="escaped">&lt;p&gt;While attempting to install SQL Server x64 I got a number of errors, so I ended up uninstalling all components I could find in the control panel, and reinstalling x32. &lt;/p&gt; &lt;p&gt;Now it was time for SP2, I ended having to download BOTH x64 and x32 versions as half my components are in each platform :S. Miraculously enough, it works just fine.&lt;/p&gt; &lt;p&gt;Here's what I ended with:&lt;/p&gt; &lt;p&gt;Database Services x32&lt;br&gt;SQL Server Native Client x64&lt;br&gt;Client Components x32&lt;br&gt;Backward Compatibility x64&lt;br&gt;Microsoft SQL Server VSS Writer x64 &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;I installed first the x64 SP2, and then x32, and everything went smooth (aside from the 2x download size).&lt;/p&gt;&lt;img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=81438" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=ccuoLK"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=ccuoLK" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=rNVOOk"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=rNVOOk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=AN5CMK"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=AN5CMK" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DanielCazzulino/~4/374540466" height="1" width="1"/&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://www.clariusconsulting.net/blogs/kzu/commentrss.aspx?PostID=81438</wfw:commentRss><feedburner:origLink>http://www.clariusconsulting.net/blogs/kzu/archive/2008/08/25/WeirdestSQLServer2005installationonaVistax64machine.aspx</feedburner:origLink></entry><entry><title>How to get ASP.NET MVC Preview 4 to run with .NET SP1</title><link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/DanielCazzulino/~3/373526135/81380.aspx" /><id>e6de741d-39cb-46fc-b8ae-6ce6880bcef9:81380</id><created>2008-08-24T09:03:24Z</created><content type="text/html" mode="escaped">&lt;p&gt;As you probably know by now (i.e. from &lt;a title="ASP.NET MVC Is Not Part of ASP.NET 3.5 SP1" href="http://haacked.com/archive/2008/08/14/aspnetmvc-not-in-sp1.aspx"&gt;Phill's blog&lt;/a&gt;), however both &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.routing.aspx"&gt;Routing&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.httpcontextbase.aspx"&gt;Abstractions&lt;/a&gt; are. &lt;a href="http://www.asp.net/mvc/"&gt;MVC Preview 4&lt;/a&gt;, however, has its own version of both assemblies.&lt;/p&gt; &lt;p&gt;In order to get MVC to use the new RTM bits of both assemblies (and avoid weird side-by-side errors), you just need to add the following binding redirect to the web.config file:&lt;/p&gt;&lt;pre class="code"&gt;    &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;runtime&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;assemblyBinding &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;urn:schemas-microsoft-com:asm.v1&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;dependentAssembly&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;assemblyIdentity &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;System.Web.Abstractions&lt;/span&gt;" &lt;span style="color: red"&gt;publicKeyToken&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;31bf3856ad364e35&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;bindingRedirect &lt;/span&gt;&lt;span style="color: red"&gt;oldVersion&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;0.0.0.0&lt;/span&gt;" &lt;span style="color: red"&gt;newVersion&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;3.5.0.0&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;dependentAssembly&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;dependentAssembly&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;assemblyIdentity &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;System.Web.Routing&lt;/span&gt;" &lt;span style="color: red"&gt;publicKeyToken&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;31bf3856ad364e35&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;bindingRedirect &lt;/span&gt;&lt;span style="color: red"&gt;oldVersion&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;0.0.0.0&lt;/span&gt;" &lt;span style="color: red"&gt;newVersion&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;3.5.0.0&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;dependentAssembly&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;dependentAssembly&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;assemblyIdentity &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;System.Web.Extensions&lt;/span&gt;" &lt;span style="color: red"&gt;publicKeyToken&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;31bf3856ad364e35&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;bindingRedirect &lt;/span&gt;&lt;span style="color: red"&gt;oldVersion&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;1.0.0.0-1.1.0.0&lt;/span&gt;" &lt;span style="color: red"&gt;newVersion&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;3.5.0.0&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;dependentAssembly&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;dependentAssembly&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;assemblyIdentity &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;System.Web.Extensions.Design&lt;/span&gt;" &lt;span style="color: red"&gt;publicKeyToken&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;31bf3856ad364e35&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;bindingRedirect &lt;/span&gt;&lt;span style="color: red"&gt;oldVersion&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;1.0.0.0-1.1.0.0&lt;/span&gt;" &lt;span style="color: red"&gt;newVersion&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;3.5.0.0&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;dependentAssembly&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;assemblyBinding&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;runtime&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;The other two redirects are added automatically by a Dynamic Data website, so I figured out it's better to put them there too :)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=81380" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=n3eu2K"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=n3eu2K" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=JaJttk"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=JaJttk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=jnBWLK"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=jnBWLK" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DanielCazzulino/~4/373526135" height="1" width="1"/&gt;</content><slash:comments>1</slash:comments><wfw:commentRss>http://www.clariusconsulting.net/blogs/kzu/commentrss.aspx?PostID=81380</wfw:commentRss><feedburner:origLink>http://www.clariusconsulting.net/blogs/kzu/archive/2008/08/24/81380.aspx</feedburner:origLink></entry><entry><title>How to diagnose Linq to SQL easily and production-ready</title><link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/DanielCazzulino/~3/372269711/81319.aspx" /><id>e6de741d-39cb-46fc-b8ae-6ce6880bcef9:81319</id><created>2008-08-22T16:08:05Z</created><content type="text/html" mode="escaped">&lt;p&gt;Here's what we're currently doing: we add an InitializeContext method to all DataContext-derived classes, which is called from all ctors:&lt;/p&gt;&lt;pre class="code"&gt;    &lt;span style="color: blue"&gt;private void &lt;/span&gt;InitializeContext()
    {
&lt;span style="color: blue"&gt;#if &lt;/span&gt;DEBUG
        &lt;span style="color: blue"&gt;if &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Debugger&lt;/span&gt;.IsAttached)
        {
            &lt;span style="color: blue"&gt;this&lt;/span&gt;.Log = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;DebuggerTextWriter&lt;/span&gt;();
        }
&lt;span style="color: blue"&gt;#endif
    &lt;/span&gt;}
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Note that the logger will only be set if a debugger is attached, so that it doesn't pollute the output on a console app while you're running it. &lt;/p&gt;
&lt;p&gt;The DebuggerTextWriter is trivial too:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;#if &lt;/span&gt;DEBUG
    &lt;span style="color: blue"&gt;internal class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;DebuggerTextWriter &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;TextWriter
    &lt;/span&gt;{
        &lt;span style="color: blue"&gt;public override void &lt;/span&gt;Write(&lt;span style="color: blue"&gt;string &lt;/span&gt;value)
        {
            &lt;span style="color: #2b91af"&gt;Debugger&lt;/span&gt;.Log(0, &lt;span style="color: #a31515"&gt;""&lt;/span&gt;, value);
            &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.Write(value);
        }

        &lt;span style="color: blue"&gt;public override void &lt;/span&gt;WriteLine(&lt;span style="color: blue"&gt;string &lt;/span&gt;value)
        {
            &lt;span style="color: #2b91af"&gt;Debugger&lt;/span&gt;.Log(0, &lt;span style="color: #a31515"&gt;""&lt;/span&gt;, value + &lt;span style="color: #2b91af"&gt;Environment&lt;/span&gt;.NewLine);
            &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(value);
        }

        &lt;span style="color: blue"&gt;public override &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Encoding &lt;/span&gt;Encoding
        {
            &lt;span style="color: blue"&gt;get &lt;/span&gt;{ &lt;span style="color: blue"&gt;return &lt;/span&gt;System.Text.&lt;span style="color: #2b91af"&gt;Encoding&lt;/span&gt;.UTF8; }
        }
    }
&lt;span style="color: blue"&gt;#endif
&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In both cases I'm wrapping the code in &lt;span style="color: blue"&gt;#if &lt;/span&gt;DEBUG so that it doesn't even go to production code. The debugger writer will write to the console output as well as the VS debugger output window.&lt;/p&gt;&lt;img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=81319" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=nO2EdK"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=nO2EdK" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=WyCkmk"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=WyCkmk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=pq9bBK"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=pq9bBK" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DanielCazzulino/~4/372269711" height="1" width="1"/&gt;</content><slash:comments>1</slash:comments><wfw:commentRss>http://www.clariusconsulting.net/blogs/kzu/commentrss.aspx?PostID=81319</wfw:commentRss><feedburner:origLink>http://www.clariusconsulting.net/blogs/kzu/archive/2008/08/22/81319.aspx</feedburner:origLink></entry><entry><title>Does CUIL search engine really work?</title><link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/DanielCazzulino/~3/353544208/79701.aspx" /><id>e6de741d-39cb-46fc-b8ae-6ce6880bcef9:79701</id><created>2008-08-02T05:55:28Z</created><content type="text/html" mode="escaped">&lt;p&gt;Query: "how to replace ipod touch boot screen"&lt;br&gt;Cuil: 1 result, completely unrelated to what I'm looking for&lt;br&gt;Google: 140k results, including the one I was looking for in the first 10&lt;br&gt;MS Live: 423k results, the actual answer nowhere to be found in the first 40 results (so, for practical purposes I guess it's the same as Cuil useless result too :))&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Query: "how to locate active item in solution explorer vs"&lt;br&gt;Cuil: 0 results&lt;br&gt;Google: 2M+ results, VERY relevant to the search&lt;br&gt;MS Live: 177k results, first couple links VERY relevant, following ones somewhat related&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Maybe it's because they are geeky questions, but for me, Google is still king, and all the fuss about the &lt;a href="http://www.cuil.com"&gt;"the world's biggest search engine"&lt;/a&gt; is totally bogus.&lt;/p&gt;&lt;img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=79701" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=9ZuRqK"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=9ZuRqK" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=KYjJzk"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=KYjJzk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=2ktieK"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=2ktieK" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DanielCazzulino/~4/353544208" height="1" width="1"/&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://www.clariusconsulting.net/blogs/kzu/commentrss.aspx?PostID=79701</wfw:commentRss><feedburner:origLink>http://www.clariusconsulting.net/blogs/kzu/archive/2008/08/02/79701.aspx</feedburner:origLink></entry><entry><title>Donut Oriented Programming</title><link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/DanielCazzulino/~3/345262897/DonutOrientedProgramming.aspx" /><id>e6de741d-39cb-46fc-b8ae-6ce6880bcef9:79265</id><created>2008-07-24T20:17:52Z</created><content type="text/html" mode="escaped">&lt;p&gt;&lt;strong&gt;Donut Oriented Programming&lt;/strong&gt;: DOP is a required discipline that you need to adhere to when your app will use VERY slow internet connection, such as in Cambodia and some other developing countries. Every action on the application that requires a roundrip to a server on the internet, should result in a donut being displayed to indicate that something is going on.&lt;/p&gt;&lt;img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=79265" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=xjjgqJ"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=xjjgqJ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=QRTR2j"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=QRTR2j" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=crKrYJ"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=crKrYJ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DanielCazzulino/~4/345262897" height="1" width="1"/&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://www.clariusconsulting.net/blogs/kzu/commentrss.aspx?PostID=79265</wfw:commentRss><feedburner:origLink>http://www.clariusconsulting.net/blogs/kzu/archive/2008/07/24/DonutOrientedProgramming.aspx</feedburner:origLink></entry><entry><title>The need for nullable reference types to advertise optional constructor dependencies</title><link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/DanielCazzulino/~3/338871383/Theneedfornullablereferencetypestoadvertiseoptionalconstructordependencies.aspx" /><id>e6de741d-39cb-46fc-b8ae-6ce6880bcef9:78620</id><created>2008-07-18T02:42:44Z</created><content type="text/html" mode="escaped">&lt;p&gt;In "traditional" OOP, you advertise your class required dependencies via constructor arguments:&lt;/p&gt;&lt;pre&gt;public Foo(IOutput output, ILogger logger, ...)&lt;/pre&gt;
&lt;p&gt;Typically, the first few lines of code will check that these dependencies are not null. &lt;/p&gt;
&lt;p&gt;Optional dependencies may be provided as properties, which you can leave unset (null). &lt;/p&gt;
&lt;p&gt;Internally, in order to avoid a multitude of conditionals checking for nulls, you might have your own &lt;a href="http://en.wikipedia.org/wiki/Null_Object_pattern"&gt;"null" implementations&lt;/a&gt; of the dependencies' interfaces (i.e. NullLogger which does nothing). This way the code is more readable, and you can always assume the dependencies are non-null and you'll never get a NullReferenceException ;)&lt;/p&gt;
&lt;p&gt;One problem with property dependency injection is that you can't readily tell which properties are dependencies, and with constructor arguments, you cannot specify which ones are optional (can be passed null OK). &lt;/p&gt;
&lt;p&gt;I think a much more consistent approach, and one that would integrate very well with the &lt;a href="http://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx"&gt;nullable value types&lt;/a&gt; functionality in .NET, is to introduce the concept of a nullable reference type:&lt;/p&gt;&lt;pre&gt;public Foo(IOutput output, ILogger? logger, ...)&lt;/pre&gt;
&lt;p&gt;What this tells the caller, is that the first argument is a required dependency, while the second can be null. I believe the .NET framework should go one step further and give the implementer a null implementation of the interface or abstract class if the argument is null. This way, you get rid of all nulls in your apps.&lt;/p&gt;
&lt;p&gt;You can also avoid depending on properties to advertise optional dependencies (and an associated custom attribute such as &lt;a href="http://blogs.msdn.com/kcwalina/archive/2008/04/25/MEF.aspx"&gt;MEF&lt;/a&gt; in order to indicate it's a dependency and not a regular property).&lt;/p&gt;&lt;img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=78620" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=lV4W9J"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=lV4W9J" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=BN80Uj"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=BN80Uj" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/DanielCazzulino?a=kLxCCJ"&gt;&lt;img src="http://feeds.feedburner.com/~f/DanielCazzulino?i=kLxCCJ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DanielCazzulino/~4/338871383" height="1" width="1"/&gt;</content><slash:comments>2</slash:comments><wfw:commentRss>http://www.clariusconsulting.net/blogs/kzu/commentrss.aspx?PostID=78620</wfw:commentRss><feedburner:origLink>http://www.clariusconsulting.net/blogs/kzu/archive/2008/07/18/Theneedfornullablereferencetypestoadvertiseoptionalconstructordependencies.aspx</feedburner:origLink></entry></feed>
