<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Philip Rieck</title>
        <link>http://philiprieck.com/blog/Default.aspx</link>
        <description>Philip Rieck's intermittent blog</description>
        <language>en-US</language>
        <copyright>Philip Rieck</copyright>
        <generator>Subtext Version 2.1.1.1</generator>
        <image>
            <title>Philip Rieck</title>
            <url>http://philiprieck.com/blog/images/RSS2Image.gif</url>
            <link>http://philiprieck.com/blog/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>Blog goes dark, comes back with amnesia</title>
            <category>Meta</category>
            <category>Personal</category>
            <link>http://philiprieck.com/blog/archive/2009/05/06/blogamnesia.aspx</link>
            <description>My blog (such as it is) went unreachable for a while.  I apologize for that.  In addition, I've managed to lose some posts - about two years worth.  Given the rate I post, that worked out to 8 entries.  Of course, they were my best entries &lt;span style="font-style: italic;"&gt;ever&lt;/span&gt;. &lt;br /&gt;
&lt;br /&gt;
So back up and running, and may have a post or two this year.&lt;br /&gt;
&lt;br /&gt;
It also seems as though many of the posts got reordered and re-dated.  All of these issues are attributable to my horrible backup policy of "occasionally backup, never verify"&lt;img src="http://philiprieck.com/blog/aggbug/51.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Philip Rieck</dc:creator>
            <guid>http://philiprieck.com/blog/archive/2009/05/06/blogamnesia.aspx</guid>
            <pubDate>Wed, 06 May 2009 17:26:00 GMT</pubDate>
            <wfw:comment>http://philiprieck.com/blog/comments/51.aspx</wfw:comment>
            <comments>http://philiprieck.com/blog/archive/2009/05/06/blogamnesia.aspx#feedback</comments>
            <wfw:commentRss>http://philiprieck.com/blog/comments/commentRss/51.aspx</wfw:commentRss>
        </item>
        <item>
            <title>More asp.net Viewstate filters ...</title>
            <category>NetDevelopment</category>
            <link>http://philiprieck.com/blog/archive/2008/02/22/viewrestate.aspx</link>
            <description>&lt;p&gt;&lt;strong&gt;The background:&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;I've seen a lot of articles lately about viewstate (well, in the last two weeks or so. I'm bad about keeping up with the rss) . &lt;a href="http://www.4guysfromrolla.com/ScottMitchell.shtml"&gt;Scott Mitchell&lt;/a&gt; recently published one &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnaspp/html/viewstate.asp"&gt;article on MSDN all about the viewstate&lt;/a&gt;, and (among other things) showed how to send less viewstate. In it he also mentioned that &lt;a href="http://www.mostlylucid.co.uk/"&gt;Scott Galloway&lt;/a&gt; blogged on &lt;a href="http://www.mostlylucid.co.uk/archive/2004/01/03/694.aspx"&gt;viewstate compression using bzip2&lt;/a&gt;. Also of note is the &lt;a href="http://www.flesk.net/fleskviewstate.aspx"&gt;Flesk viewstate optimizer&lt;/a&gt;.  All of these allow you to send less viewstate to the client, which means that you're saving bandwidth twice -- since the browser sends the viewstate back with the next request.  For large pages with lots of viewstate, this can make a difference even on a LAN -- let alone those poor 56K modem users.&lt;/p&gt;
&lt;p&gt;Now, I love these articles (and that looks like a good product), but they all take the same approach. While that's probably because it's the best one, I decided to try for the same result and take a different tack. &lt;/p&gt;
&lt;p&gt;All of the above work by either having you override your page's &lt;code&gt;“PersistViewStateToFileSystem”&lt;/code&gt; and call a method, or have you derive your page class from a base object they provide. All well and good, eh?  Hey, the support is built into the framework!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The divergence:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I like a declarative approach. That is, I want to take an existing site, add on line to the web.config, and have it do what I want.  After all, this is not per-page functionality I'm talking about here... it's a cross-cutting concern.  Why modify all my pages to do it?  &lt;/p&gt;
&lt;p&gt;So I wrote one that just requires you to add an HttpModule (which takes copying a dll to your /bin dir, then adding three lines to your web.config. The module also requires just one more line to configure it).  While this doesn't satisfy my "add one line" need, four lines is pretty close.  And I don't have to modify anything else.  &lt;/p&gt;
&lt;p&gt;Presto! Add a module, and your viewstate shrinks. What could be easier? Now, before the parties start, let me warn you -- this is no magic bullet. GZipping the viewstate takes some time that could be used to download the viewstate... so where's the happy medium? Using a file store means you have lots of files and increased disk I/O. Using the Session or Application object mean more memory. And I can't generalize your database.&lt;/p&gt;
&lt;p&gt;So this has the shotgun approach -- it can either compress the viewstate and leave it in-page (using &lt;a href="http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx"&gt;#ziplib&lt;/a&gt;), it can save it to file, it can keep it in the application or session collections, or you can implement a (very, very simple) interface and do the work yourself.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The goods: &lt;br /&gt;
&lt;a href="http://www.nfission.net/files/getfile.ashx?file=viewrestate&amp;amp;package=source"&gt;&lt;/a&gt;&lt;a href="http://philiprieck.com/files/ViewReState.zip"&gt;  ViewRestate &lt;/a&gt;&lt;br /&gt;
&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The caveat:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This may be slow.  Test it yourself.  It's more of a mental exercise for me.  In my Quick-'n-Dirty (tm) tests with a real-life largish site, the speed improved.  I didn't run scalability or volume requests. The code has about ninety minutes of effort into it, so it's probably "dirty". &lt;/p&gt;
&lt;p&gt;Not waranteed, caveat emptor,  e pluribus unum, ipso fatso, etc, ad naseum.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The details:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The module sets up a filter in both the request and the response.  &lt;/p&gt;
&lt;p&gt;On the first request the response filter does a text search of what the page is writing, and takes whatever is in the viewstate out.  It calls into the IViewstateStore.StoreViewstate() method to have whatever storage provider is active store the viewstate. The "token" it returns is then put into the viewstate along with "$filterd$" (yes, I took out the last e. Why not?). &lt;/p&gt;
&lt;p&gt;On a post back, the request filter takes the token out of the viewstate, then calls IViewstateStore.RetrieveViewstate(), passing the token in.  It takes the returned viewstate and injects it into the request.   See the code for more details …&lt;/p&gt;&lt;img src="http://philiprieck.com/blog/aggbug/31.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Philip Rieck</dc:creator>
            <guid>http://philiprieck.com/blog/archive/2008/02/22/viewrestate.aspx</guid>
            <pubDate>Sat, 23 Feb 2008 04:29:32 GMT</pubDate>
            <comments>http://philiprieck.com/blog/archive/2008/02/22/viewrestate.aspx#feedback</comments>
            <slash:comments>42</slash:comments>
            <wfw:commentRss>http://philiprieck.com/blog/comments/commentRss/31.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Vista's .net - the same version as XP, but different</title>
            <link>http://philiprieck.com/blog/archive/2006/11/22/vistas-.net-the-same-version-as-xp-but-different.aspx</link>
            <description>&lt;p&gt;If you have a .net application running on 2.0, test it on the 2.0 shipped in Vista, even if it has no UI.  .Net 2.0 on Vista is not the same as the 2.0 that's available on other platforms right now.&lt;/p&gt;
&lt;h2&gt;The Synopsis&lt;/h2&gt;
&lt;ul&gt;
    &lt;li&gt;On Vista (RTM), System.Xml.Dll's file version is 2.0.50727.&lt;em&gt;312. &lt;br /&gt;
    &lt;/em&gt;On XP with either .net 2.0 or .net 3.0 installed, it's 2.0.50727.&lt;em&gt;42&lt;/em&gt;&lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;The serialization engine that creates xml serialization assemblies on the fly (via XmlSerializerFactory or XmlSerializer) creates markedly different assemblies &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Things that deserialize fine on XP (which may be coded incorrectly, but run and pass all tests and fxcop rules) do not on Vista&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Yes, really.    No, I don't know why.&lt;/p&gt;
&lt;h2&gt;The Issue&lt;/h2&gt;
&lt;p&gt;You can &lt;a title="Repro Project in a zip file" href="http://philiprieck.com/files/SerializerRepro.zip"&gt;download a very small project that reproduces this issue&lt;/a&gt; if you want to follow along.   This application will run fine under XP with either .Net 2.0 or 3.0 (which installs .Net 2.0) installed and fully patched.   It will not run under Vista.  &lt;/p&gt;
&lt;p&gt;What it does is read in this XML:&lt;/p&gt;
&lt;div contenteditable="false" class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:7f986438-06da-44ab-8ef2-917454e7f7f3" style="margin: 0px; padding: 0px; display: inline; float: none;"&gt;
&lt;pre style="background-color: rgb(238, 238, 238);"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;xml version="1.0" encoding="utf-8" &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;?&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;DummyType &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="tst"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Then it tries to deserialize like this:&lt;br /&gt;
&lt;/p&gt;
&lt;div contenteditable="false" class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:aac32fb5-3fbf-422f-8c69-3458beab72fe" style="margin: 0px; padding: 0px; display: inline; float: none;"&gt;
&lt;pre style="background-color: rgb(238, 238, 238);"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;XmlSerializer ser &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; XmlSerializer(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;typeof&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(DummyType));&lt;br /&gt;DummyType t &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ser.Deserialize(reader) &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;as&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; DummyType;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;into this type:&lt;br /&gt;
&lt;/p&gt;
&lt;div contenteditable="false" class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:178c052a-48aa-4379-93ec-5fd5eef8beac" style="margin: 0px; padding: 0px; display: inline; float: none;"&gt;
&lt;pre style="background-color: rgb(238, 238, 238);"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;[Serializable]&lt;br /&gt;[XmlType(AnonymousType&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, Namespace&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;tst&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)]&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; DummyType&lt;br /&gt;{    &lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;That's it.  Really.    You'll note that in the repro project, I have an app.config with the &amp;lt;requiredRuntime&amp;gt; element.  I wanted to; 1. Make sure that there was no version difference in the runtimes I was testing, and 2. &lt;em&gt;point out that you can't future proof your code when people change functionality but leave the version numbers the same.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h2&gt;The background&lt;/h2&gt;
&lt;p&gt;We had a type that (through the evils of copy/paste) was attributed with [XmlType] instead of [XmlRoot].  But since the 2.0 framework on XP (and even Vista up through RC2) worked as expected, we didn't ever notice.   Until we ran it on Vista RTM - an exception is thrown immediately when deserializing from XML.&lt;/p&gt;
&lt;p&gt;Trying to track it down, we found out that "sgen.exe /k ..." creates markedly different versions of the serialization code between XP and Vista.  I haven't done a full analysis of the differences (and I probably won't - real job and all that), so I don't know what other differences to expect.  Hopefully we just ran into an edge case, but like I said the code is completely different.&lt;/p&gt;
&lt;p&gt;I'm not sure why, but it seems the 2.0 assemblies shipped with Vista's 3.0 are different than the 2.0 assemblies in either the 2.0 or 3.0 redist available from Microsoft for other platforms. (wheh, this 3.0 versioning is fun, isn't it!)&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h2&gt;The Rant&lt;/h2&gt;
&lt;p&gt;&lt;img height="112" width="240" align="right" alt="" src="http://philiprieck.com/blog/images/philiprieck_com/blog/WindowsLiveWriter/Vistas.netthesameversionasXPbutdifferent_C59A/Repro9.png" /&gt; What would a customer think?  "This dumb app isn't Vista compatible" or "Stupid Vista  broke my applications".  If I'm lucky, they'll check for a fix on our website.  &lt;/p&gt;
&lt;p&gt;Really, I expected some UI problems going to vista, but not XmlSerialization issues.  &lt;/p&gt;
&lt;p&gt;I insist on compatibility - if 2.0 runs code -&lt;em&gt;even if it's wrong&lt;/em&gt;- , then 2.0 should always run that code.  I should be able to use &amp;lt;requiredRuntime&amp;gt; to make sure that my code doesn't go into an environment with an untested platform, even one that hasn't been released.   Don't break my running and deployed application.&lt;/p&gt;
&lt;p&gt;I thought we collectively learned our lesson on this one - A contract is immutable once published.  With something like the .net framework, the contract isn't just the signatures of the API!  I'm sorry, I know it sucks for the FCL team and makes their lives harder, but for .net the contract includes all of the functionality, quirks, and side effects.    If you change anything, change the version number.&lt;/p&gt;
&lt;h2&gt;The Hope&lt;/h2&gt;
&lt;p&gt;However, I'll be understanding if compatibility &lt;em&gt;must&lt;/em&gt; be broken for a security update.   Yes, I'll recommend patching 2.0 even if it breaks my applications when there's no other choice to fix a possible vulnerability.  Does Vista have a security patch applied to 2.0 that isn't available yet?  That would make me much less angry -  So that's what I'll hope.&lt;/p&gt;&lt;img src="http://philiprieck.com/blog/aggbug/49.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Philip Rieck</dc:creator>
            <guid>http://philiprieck.com/blog/archive/2006/11/22/vistas-.net-the-same-version-as-xp-but-different.aspx</guid>
            <pubDate>Thu, 23 Nov 2006 01:07:33 GMT</pubDate>
            <comments>http://philiprieck.com/blog/archive/2006/11/22/vistas-.net-the-same-version-as-xp-but-different.aspx#feedback</comments>
            <wfw:commentRss>http://philiprieck.com/blog/comments/commentRss/49.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Glass in Windows Forms</title>
            <category>NetDevelopment</category>
            <link>http://philiprieck.com/blog/archive/2006/09/13/glassform.aspx</link>
            <description>&lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;[Update - 9/13/06]&lt;/font&gt;&lt;/strong&gt;  This seems to not work using RC1 - using DwmEnableBlurBehindWindow seems to work fine creating areas of glass, but DwmExtendFrameIntoClientArea does not - you get nothing but a black rectangle.   I'm trying to figure out why and I'll create another post if I do...  if &lt;em&gt;you&lt;/em&gt; do, please feel free to comment here or point me to your posting!  &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;I've seen a fair number of questions on using Glass in Vista forms, and I've seen a few answers as well.  However, the &lt;a href="http://blogs.msdn.com/tims/archive/2006/04/18/578637.aspx"&gt;answers I've seen&lt;/a&gt; involve using Windows.Forms transparent forms support [1].  There's a big downside to this- when you click a "glassy" area the mouse click is never sent to your form, and is instead passed to whatever's behind it.  Not intuitive!&lt;/p&gt; &lt;p&gt;Also, there's more to glass in Vista than allowing the border to creep in - you can have the whole window look like a sheet of glass, or you can even add little interior bits to be glass.  Why not take advantage of all of it?&lt;/p&gt; &lt;p&gt;This sample does that, and provides a pre-build assembly you can use as well.  If you want to figure out what it's doing, read below and follow along in the source.  If you just want to use it to get glass forms, in c# or vb.net, then :&lt;/p&gt; &lt;p&gt;&lt;a href="http://philiprieck.com/files/vistacontrols.zip"&gt;Get the Zip file&lt;/a&gt; &lt;/p&gt; &lt;ol&gt; &lt;li&gt;Create a new Windows Forms project  &lt;/li&gt;&lt;li&gt;Reference the "GlassForms.dll" assembly.  &lt;/li&gt;&lt;li&gt;Create a new form and open it in code view (or open Form1.cs in code view)  &lt;/li&gt;&lt;li&gt;Change the class it inherits from from "Form" to "GlassForms.GlassForm"  &lt;/li&gt;&lt;li&gt;Mess with your form's new properties "GlassFrameInset", "ShowAsSheetOfGlass", and "FullClientBlur" &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;img src="http://philiprieck.com/files/fullclientblur.png" align="right" /&gt;You can do the last step in code as well. In code, you can also call AddBlurRect and RemoveBlurRect methods to add blurry areas to the interior of your form.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Some important notes!&lt;/strong&gt; &lt;/p&gt; &lt;p&gt;Windows Forms doesn't really support a non-painted tranparent background to the Form (without specifying TransparancyKey, which has the "click-through" problem).  So any controls placed on a glassy portion of your form will probably look funky.  No, I don't know how to solve this yet.  Yes, I am working on it (but time is limited, so I'm not working on it much).  Your best bet is to draw any UI on the glass yourself.  It's a pain, I know.  For this reason as well, "ShowAsSheetOfGlass" and "FullClientBlur" are of &lt;em&gt;extremely&lt;/em&gt; limited usefulness.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Text on Glass&lt;/strong&gt; &lt;/p&gt; &lt;p&gt;I'd like to add support for DrawThemeTextEx, but haven't.  What that would do is allow you to draw text that has that neat white glow around it - making it easier to read on glass against any background.  Coming some day.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;What's really going on&lt;/strong&gt; &lt;/p&gt;&lt;img src="http://philiprieck.com/files/AddBlurRect.png" align="left" /&gt;  &lt;p&gt;It's actually pretty easy.  Look into NativeMethods, and notice three important calls: DwmIsCompositionEnabled(..),  DwmExtendFrameIntoClientArea(...), and DwmEnableBlurBehindWindow(...).  That's it!  really.&lt;/p&gt; &lt;p&gt;The tricky part in Windows forms is painting the area black you set glass to be in.  I do that by keeping a Region around that I fill with black in the OnPaint of the base class.&lt;/p&gt; &lt;p&gt;What, you thought it would be more complicated?  It's really not.  The dwmapi calls are quite straightforward, and with a bit of p/invoke knowledge, quite easy to use.  I hope to find a solution to the windows forms "black paint" problem (see the important notes above), but haven't yet.  &lt;/p&gt; &lt;p&gt;[1] Thereby setting the WS_LAYERED attribute.&lt;/p&gt;&lt;img src="http://philiprieck.com/blog/aggbug/48.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Philip Rieck</dc:creator>
            <guid>http://philiprieck.com/blog/archive/2006/09/13/glassform.aspx</guid>
            <pubDate>Wed, 13 Sep 2006 21:57:17 GMT</pubDate>
            <comments>http://philiprieck.com/blog/archive/2006/09/13/glassform.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://philiprieck.com/blog/comments/commentRss/48.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Leaky abstractions can be great</title>
            <category>BeingADeveloper</category>
            <category>Brain Dump</category>
            <category>NetDevelopment</category>
            <category>Rants</category>
            <link>http://philiprieck.com/blog/archive/2006/07/15/leakingisgood.aspx</link>
            <description>
		&lt;p&gt; &lt;/p&gt;
		&lt;p&gt;I’m sure you’ve heard the term “&lt;a href="http://www.joelonsoftware.com/articles/LeakyAbstractions.html"&gt;law of leaky abstraction&lt;/a&gt;”, apparently put forth by &lt;a href="http://www.joelonsoftware.com/"&gt;Joel Spolsky&lt;/a&gt; (if you’re unfamiliar, please go read it – it’s worth your time). Lots of people have blogged about what leaks, what doesn’t leak, why things leak and so on.&lt;/p&gt;
		&lt;p&gt;To deal with this, people often are in search of creating a “cleaner” abstraction layer that doesn’t leak. And how many times have you seen an internal framework that took way too long to create – time spent refactoring to keep it “clean” by hiding the underlying system ? I think this is a big mistake…&lt;/p&gt;
		&lt;p&gt;Let’s face it, almost any framework today is built on top of a complex something else. And that something else is probably going to have quirks and limitations.&lt;span style="mso-spacerun: yes"&gt;   &lt;/span&gt;I think the trick to a clean framework isn’t hiding the quirks and limitations – it’s letting the user get to them and work around (or with) them in a layered manner.&lt;/p&gt;
		&lt;p&gt;Let me use an example (and I’m going to be light on technicalities here… this is just for illustrative purposes) – VB6 (remember that? ). A huge step away from raw C programming for windows. In VB every control (like a list box) that you drag onto a form had listbox functionality. You called methods and set properties, and it behaved list-boxy. Under the covers it was actually still a win32 window using built-in (to windows) functionality, nothing you couldn’t create with C. But VB abstracted away all of the cruft for things like adding a new item – instead of sending a LB_ADDSTRING message with SendDlgItemMessage using the id of the list and encoding the string to add in the LPARAM (whew!)… you just called ListBox.AddItem(“string”).&lt;/p&gt;
		&lt;p&gt;Great! But what if I want to do something with WM_CHARTOITEM? Or handle odd windows messages sent to to that listbox? Bzzt – no can do without bypassing VB’s listbox control altogether and creating it yourself, and possibly replacing the entire form. Now you basically need to go back and code stuff using a lower level framework (MFC/WTL/Win32/…). The abstraction leaks because I can’t do what I want (sending or handling some special message), and it sucks because I can’t do what I want with this framework at all.&lt;/p&gt;
		&lt;p&gt;Now along comes Windows Forms – we get an all new listbox. It also abstracts away things like creation, adding an item and all that while still using win32’s listbox. Great! But when I want to send or handle some special win32 message the abstraction allows me to – it may not help a whole lot, but it certainly makes it possible if not simple. This abstraction still &lt;b&gt;leaks&lt;/b&gt; because I &lt;i&gt;still&lt;/i&gt; can’t do what I want without sending or handling some special message, but it doesn’t &lt;b&gt;suck&lt;/b&gt; because I can use the framework and still deal with the underlying system. The abstraction feels “cleaner” &lt;i&gt;because&lt;/i&gt; it doesn’t hide the leaks.&lt;/p&gt;
		&lt;p&gt;For this reason, I love the design of some of WCF - it feels great because it allows you to deal with the underlying system at various layers of abstraction. You choose – highly abstracted, some abstraction, or almost none. If you find the framework is hindering you, you can just jump down a level without abandoning the framework and all its existing code. This abstraction feels even cleaner even though it goes to more lengths to show you the underlying system behind the façade.&lt;/p&gt;
		&lt;p&gt;So above we have three levels of abstractions letting water into our boat: &lt;/p&gt;
		&lt;ol&gt;
				&lt;li&gt;VB – There are no leaks, I see no leaks. (gurgle) 
&lt;/li&gt;
				&lt;li&gt;Windows Forms – Yes, there’s leaks. (yawn) - If you don’t like them here’s a bucket – bail ‘em out yourself. 
&lt;/li&gt;
				&lt;li&gt;WCF – There are no leaks, we’re in a swimming pool – enjoy the water. Here’s a floating chair &lt;/li&gt;
		&lt;/ol&gt;
		&lt;p&gt;Which would you choose? And what’s my point? Embrace the leaks. Don’t hide them in your framework to make it cleaner! Instead, find a way to expose them all, within your framework. Get wet. &lt;/p&gt;
&lt;img src="http://philiprieck.com/blog/aggbug/47.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Philip Rieck</dc:creator>
            <guid>http://philiprieck.com/blog/archive/2006/07/15/leakingisgood.aspx</guid>
            <pubDate>Sat, 15 Jul 2006 08:47:44 GMT</pubDate>
            <comments>http://philiprieck.com/blog/archive/2006/07/15/leakingisgood.aspx#feedback</comments>
            <wfw:commentRss>http://philiprieck.com/blog/comments/commentRss/47.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Upgrade engine, upgrade frequency</title>
            <category>Meta</category>
            <link>http://philiprieck.com/blog/archive/2006/07/01/ugradeandupdate.aspx</link>
            <description>
		&lt;p&gt;I've upgraded from .Text 0.95 (yes, quite old) to Subtext.  I had some issues with the .text import where I had to basically do everything manually (yuck) but here I am. The problems were all in the sql script, so I'd advise just running it manually from the get go.  However, if you have problems getting my feed or whatever, please let me know. I'm not 100% confident that I got everything over with zero problems.&lt;/p&gt;
		&lt;p&gt;And, I'm excited to start posting more often.  I've had many things lately that I wanted to blog on, but .text issues and time constraints caused me to abort the posting.  Hopefully this upgrade will drop the first problem.  As for the time constraints, well...&lt;/p&gt;
		&lt;p&gt;
				&lt;br /&gt;About nine months ago I started working for a startup software company in Redmond, Washington. We're building something that has us quite excited, and I get to work with some great people while doing something both fun and challanging.  While overcoming some of the obstacles in our path has provided some good blog fodder, the intense pace of starting something new has kept me from being able to process the ideas and get them pushed up here. I really want that to end, so I'm setting aside some time each week to post&lt;/p&gt;
&lt;img src="http://philiprieck.com/blog/aggbug/46.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Philip Rieck</dc:creator>
            <guid>http://philiprieck.com/blog/archive/2006/07/01/ugradeandupdate.aspx</guid>
            <pubDate>Sat, 01 Jul 2006 07:20:15 GMT</pubDate>
            <comments>http://philiprieck.com/blog/archive/2006/07/01/ugradeandupdate.aspx#feedback</comments>
            <wfw:commentRss>http://philiprieck.com/blog/comments/commentRss/46.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Heartland DC over</title>
            <category>NetDevelopment</category>
            <category>Personal</category>
            <link>http://philiprieck.com/blog/archive/2005/10/14/hdc05.aspx</link>
            <description>&lt;p&gt;I'm not dead.  I just don't publish many of my posts, becase they seem.... pointless after I write them.&lt;/p&gt;
&lt;p&gt;Anyway, I just got back from the &lt;a href="http://www.heartlanddc.com/"&gt;HDC&lt;/a&gt;, and it was lots of fun.   The pre-party the night before, the keynotes by &lt;a href="http://www.lhotka.net/"&gt;Roky Lhotka &lt;/a&gt;and &lt;a href="https://mvp.support.microsoft.com/profile=e9b19045-ee05-4a9f-8603-431e328c2e0a"&gt;Andrew Troelsen&lt;/a&gt;, lots of great sessions, and other cool things.   I hope I can make it next year, surely, and for all you people who missed it - sign up next year as soon as it's announced.... this conference has sold out every year, and fast!  &lt;a href="http://www.joeolsen.com/blog/"&gt;Joe Olsen&lt;/a&gt; told me there were over 100 on the waiting list for this year.&lt;/p&gt;
&lt;p&gt;So to those that attended my session and are looking for the HttpModules I spoke of, they can be found here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://philiprieck.com/blog/archive/2004/06/17/ViewRestate.aspx"&gt;ViewRestate&lt;/a&gt; (allows moving your viewstate out of page) 
&lt;/li&gt;&lt;li&gt;&lt;a href="http://philiprieck.com/blog/archive/2004/02/11/ScrollKeeper.aspx"&gt;Scroll position keeper module&lt;/a&gt; 
&lt;/li&gt;&lt;li&gt;&lt;a href="http://weblogs.asp.net/prieck/archive/2003/05/16/7147.aspx"&gt;ASPNetSpy&lt;/a&gt; (allows you to view user's web activity) 
&lt;/li&gt;&lt;li&gt;&lt;a href="http://weblogs.asp.net/prieck/archive/2003/05/13/6982.aspx"&gt;QuickWebGz&lt;/a&gt; (gzips pages as asp.net spits 'em out)&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;And of course, you can find the slides on the &lt;a href="http://www.heartlanddc.com/slides" target="_blank"&gt;HDC slides site&lt;/a&gt;. We'll see you next year!&lt;br /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;img src="http://philiprieck.com/blog/aggbug/45.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Philip Rieck</dc:creator>
            <guid>http://philiprieck.com/blog/archive/2005/10/14/hdc05.aspx</guid>
            <pubDate>Sat, 15 Oct 2005 04:20:00 GMT</pubDate>
            <comments>http://philiprieck.com/blog/archive/2005/10/14/hdc05.aspx#feedback</comments>
            <wfw:commentRss>http://philiprieck.com/blog/comments/commentRss/45.aspx</wfw:commentRss>
        </item>
        <item>
            <title>VS.NET 2005 - Now supporting multiple languages... For the first time!</title>
            <category>NetDevelopment</category>
            <category>Rants</category>
            <link>http://philiprieck.com/blog/archive/2005/04/19/vs.net-2005-now-supporting-multiple-languages.-for-the-first.aspx</link>
            <description>&lt;p&gt;Back in February of '04, I posted “&lt;font color="#000000"&gt;&lt;a href="http://philiprieck.com/blog/archive/2004/02/17/MultiLangageInVSNet.aspx"&gt;.Net says - multiple languages supported. VS.Net says - don't try it&lt;/a&gt;“.&lt;/font&gt;  A &lt;a href="http://panopticoncentral.net/articles/947.aspx"&gt;quick response&lt;/a&gt; by &lt;a href="http://panopticoncentral.net/"&gt;Paul Vick&lt;/a&gt; showed that it would probably never be fixed for Visual Studios 2002 and 2003 - but that they'd work on it for Whidbey.    &lt;/p&gt;
&lt;p&gt;Alas, the beta 1 and multiple CTPs came and went, and the bug continued.  However, I am happy to report that in VS.NET 2005 Beta 2, the problem seems to have been resolved.  My &lt;a href="http://philiprieck.com/files/bugrep.zip"&gt;test case&lt;/a&gt; now works, and I'm a happy camper.&lt;/p&gt;
&lt;p&gt;Thanks to the background compilation teams for c# and vb.net!  While I'm sure this is an edge case, it's an edge that's cut me more than once.&lt;/p&gt;
&lt;p&gt;Now if only Paul would allow us to turn off &lt;a href="http://www.panopticoncentral.net/archive/2005/04/08/8279.aspx"&gt;VB.Net default form instance&lt;/a&gt; codegen by the compiler, and &lt;a href="http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=65ff7de1-5075-46f5-89e4-2a11dac20db2"&gt;make lots of friends&lt;/a&gt;.  (sure - keep the feature, but make it opt-in, or at least opt-out)&lt;/p&gt;&lt;img src="http://philiprieck.com/blog/aggbug/44.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Philip Rieck</dc:creator>
            <guid>http://philiprieck.com/blog/archive/2005/04/19/vs.net-2005-now-supporting-multiple-languages.-for-the-first.aspx</guid>
            <pubDate>Tue, 19 Apr 2005 21:49:00 GMT</pubDate>
            <comments>http://philiprieck.com/blog/archive/2005/04/19/vs.net-2005-now-supporting-multiple-languages.-for-the-first.aspx#feedback</comments>
            <wfw:commentRss>http://philiprieck.com/blog/comments/commentRss/44.aspx</wfw:commentRss>
        </item>
        <item>
            <title>C# 2.0's Generics - Are we missing some constraints?</title>
            <category>NetDevelopment</category>
            <category>Rants</category>
            <link>http://philiprieck.com/blog/archive/2005/02/17/c-2.0s-generics-are-we-missing-some-constraints.aspx</link>
            <description>&lt;p&gt;I really do like the “Whidbey” generics for both C# and VB.net.  In my opinion, they bring a good solution to some problems with gaps in strong typing to the .net family.  Great stuff, really.&lt;/p&gt;
&lt;p&gt;However, I'm not happy with one of the constraints on constraints.  I'll endevor to explain.  Hopefully this is either addressed or (at the least) acknowledged by those in the know.  (Or, if I'm an idiot, feel free to let me know in comments)&lt;/p&gt;
&lt;p&gt;For a good background on C# generics, see this article on MSDN: &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/csharp_generics.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/csharp_generics.asp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Okay, so let's say I have a generic collection that sorts items:&lt;br /&gt;&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;1&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; SortEx&amp;lt;T&amp;gt;&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;2&lt;/span&gt;{&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;3&lt;/span&gt;   ...&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;4&lt;/span&gt;    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; Add(T value)&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;5&lt;/span&gt;    {&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;6&lt;/span&gt;        &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt;( T item &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; m_collection)&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;7&lt;/span&gt;        {&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;8&lt;/span&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt;( value &amp;lt; item) { ... } &lt;font color="#008200"&gt;&lt;br /&gt;&lt;/font&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;9&lt;/span&gt;        }&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;10&lt;/span&gt;        ...&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;11&lt;/span&gt;    }&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;12&lt;/span&gt;     ...&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;13&lt;/span&gt;}&lt;/p&gt;
&lt;p&gt;This won't work.  Why? well, because the compiler doesn't know if the line “(value &amp;lt; item)” is valid!.  That is, is the “&amp;lt;” operator valid on any and every type that currently exists or will exist?  No - so the compiler won't allow you to write this line.&lt;/p&gt;
&lt;p&gt;To get around this issue, we use the nifty “constraints” feature:&lt;br /&gt;&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;1&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; SortEx&amp;lt;T&amp;gt; where T:IComparable&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;2&lt;/span&gt;{&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;3&lt;/span&gt;   ...&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;4&lt;/span&gt;    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; Add(T value)&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;5&lt;/span&gt;    {&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;6&lt;/span&gt;        &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt;( T item &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; m_collection)&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;7&lt;/span&gt;        {&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;8&lt;/span&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt;( value.compareTo(item) &amp;lt; 0) &lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;9&lt;/span&gt;             { &lt;span style="COLOR: #008200"&gt;//... }&lt;/span&gt;&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;10&lt;/span&gt;        }&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;11&lt;/span&gt;        ...&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;12&lt;/span&gt;    }&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;13&lt;/span&gt;     ...&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;14&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Note that since we've added “where T:IComparable”, only types that implement IComparable can be used to construct an instance of this generic.  So the line “value.compareTo(item)” &lt;em&gt;will&lt;/em&gt; be valid for any type that does exist or ever will exist &lt;em&gt;that can be used as the type parameter in this generic class.&lt;/em&gt;  Very handy.&lt;/p&gt;
&lt;p&gt;Now we come to my issue.  Note that to allow a comparison (normally done using the type's “&amp;lt;” operator), we had to add a constraint and turn it into a method call on an interface.  Why couldn't we say “where T: operator&amp;lt;”?  Answer - not supported, and that's the problem.&lt;/p&gt;
&lt;p&gt;How is this a problem? After all, we worked around it!  Well, imagine that we want to create a generic that will give us a running total of items added to it. That is, we call totaler.Add(value) for every value we come across, and at any time we can look at the property totaler.Total to get the current running total...&lt;br /&gt;&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;1&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; RunTotal&amp;lt;T&amp;gt; &lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;2&lt;/span&gt;{&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;3&lt;/span&gt;   &lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt; T m_total;&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;4&lt;/span&gt;   &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; T Total&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;5&lt;/span&gt;   {&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;6&lt;/span&gt;      get{ &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; m_total; }&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;7&lt;/span&gt;   }&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;8&lt;/span&gt;&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;9&lt;/span&gt;    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; Add(T value)&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;10&lt;/span&gt;    {&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;11&lt;/span&gt;       total += value;&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;12&lt;/span&gt;    }&lt;br /&gt;&lt;span style="BORDER-RIGHT: #999999 1px solid; WIDTH: 40px; COLOR: #008284; MARGIN-RIGHT: 10px; BACKGROUND-COLOR: #e5e5e5; TEXT-ALIGN: right"&gt;13&lt;/span&gt;}&lt;/p&gt;
&lt;p&gt;Okay, again this won't work.  The compiler can't ensure that the operator “+” is valid for every type that does exist or will exist.  However, in this case, there's &lt;em&gt;&lt;strong&gt;nothing we can do about it&lt;/strong&gt;.&lt;/em&gt; There's no way to add a constraint for the operator.  There's no interface that will be supported by all addable types in the runtime.  There's just nothing.&lt;/p&gt;
&lt;p&gt;Now, we could have a big case statement and check if the type is an int, or a string, or a double, or whatever - then cast and add.  But that would limit us to known types and not future types that are addable.  Really, our hands are tied here and &lt;em&gt;all we want to do is add.&lt;/em&gt;  Ouch.  Back to using Object, boxing, explicit casts and runtime errors instead of compile-time.&lt;/p&gt;
&lt;p&gt;So, should the .net creators go about adding either an interface for each operation possible? If they do, it must be done now, or it will be worthless in the future (it may already be too late - if you created your own Complex class, for example, did you put this non-existant interface on it for addition?)  However, this means adding a interfaces to a host of types in the runtime and FCL&lt;/p&gt;
&lt;p&gt;Or, do they allow for constraints on operators, which may be just as complex? Since operator overloading is done with the specialname attribute and actually handled by compilers, this may just not be possible or at least very difficult.&lt;/p&gt;
&lt;p&gt;Either way, I hope this is being addressed somehow.  I admit it may be enough of an edge case that it's not important enough to fix, but it seems to me to be a shortcoming in generics that must either be dismissed as acceptable, or fixed &lt;em&gt;right now&lt;/em&gt;.  Once generics are out there for real, making fundimental changes is going to be that much harder.&lt;/p&gt;&lt;img src="http://philiprieck.com/blog/aggbug/43.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Philip Rieck</dc:creator>
            <guid>http://philiprieck.com/blog/archive/2005/02/17/c-2.0s-generics-are-we-missing-some-constraints.aspx</guid>
            <pubDate>Thu, 17 Feb 2005 22:19:00 GMT</pubDate>
            <comments>http://philiprieck.com/blog/archive/2005/02/17/c-2.0s-generics-are-we-missing-some-constraints.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://philiprieck.com/blog/comments/commentRss/43.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Comments moderated</title>
            <category>Meta</category>
            <category>Rants</category>
            <link>http://philiprieck.com/blog/archive/2005/01/31/comments-moderated.aspx</link>
            <description>&lt;p&gt;Due to mass comment spam, I'm turning on moderation (that I got from &lt;a href="http://donxml.com/"&gt;Don XML&lt;/a&gt;, with his &lt;a href="http://donxml.com/allthingstechie/archive/2005/01/25/1749.aspx"&gt;.text moderation modifications entry&lt;/a&gt;). I did not enable the CAPTCHA stuff yet (from &lt;a href="http://blogs.clearscreen.com/migs/archive/2004/11/10/575.aspx"&gt;Miguel Jimenez’s HIP-CAPTCHA Control&lt;/a&gt;), because I hate to annoy anyone who may want to comment, but I will turn it on without further hesitation if need be. &lt;/p&gt;
&lt;p&gt;However, the thing that's most important to me is now done - I will no longer give Google Juice to spamming losers. (The regular kind of loser can comment here and get juice if they want, as long as it's on topic)&lt;/p&gt;&lt;img src="http://philiprieck.com/blog/aggbug/42.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Philip Rieck</dc:creator>
            <guid>http://philiprieck.com/blog/archive/2005/01/31/comments-moderated.aspx</guid>
            <pubDate>Mon, 31 Jan 2005 21:49:00 GMT</pubDate>
            <comments>http://philiprieck.com/blog/archive/2005/01/31/comments-moderated.aspx#feedback</comments>
            <wfw:commentRss>http://philiprieck.com/blog/comments/commentRss/42.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>