<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>.NET 2.0</title>
        <link>http://geekswithblogs.net/michelotti/category/3765.aspx</link>
        <description>.NET 2.0</description>
        <language>en-US</language>
        <copyright>Steve Michelotti</copyright>
        <managingEditor>stevemic21@yahoo.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>ConfigurationErrorsException - The configuration is read only.</title>
            <link>http://geekswithblogs.net/michelotti/archive/2007/08/14/114679.aspx</link>
            <description>&lt;p&gt;The .NET 2.0 Configuration API is a huge step up from the previous versions of the framework rendering many other previous configuration framework (Enterprise Library Configuration block, etc.) virtually obsolete.  However, one thing that can trip people up is when they try to assign to a configuration property at run-time you can get a ConfigurationErrorsException - The configuration is read only even when a setter is defined on their property:&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;[ConfigurationProperty(item1Property, DefaultValue = 1, IsRequired=true)]&lt;br /&gt;
[IntegerValidator(MinValue=1, MaxValue=100)]&lt;br /&gt;
public int ConfigItem1&lt;br /&gt;
{&lt;br /&gt;
   get  { return Convert.ToInt32(this[item1Property]); }&lt;br /&gt;
   set  { this[item1Property] = value; }&lt;br /&gt;
}&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;The ConfigurationSection inherits from ConfigurationElement which defines a virtual method for IsReadOnly().  If you want to avoid this exception and actually assign your values at run-time simply override this method in your ConfigurationSection or ConfigurationElement class like this:&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;public override bool IsReadOnly()&lt;br /&gt;
{&lt;br /&gt;
    return false;&lt;br /&gt;
}&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=114679"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=114679" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/114679.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2007/08/14/114679.aspx</guid>
            <pubDate>Wed, 15 Aug 2007 02:23:29 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/114679.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2007/08/14/114679.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/114679.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/114679.aspx</trackback:ping>
        </item>
        <item>
            <title>WinDbg real world example</title>
            <link>http://geekswithblogs.net/michelotti/archive/2007/08/14/114676.aspx</link>
            <description>&lt;p&gt;I recently had to debug a problem for my current client which was exceptionally weird and I was able to utilize WinDbg to help get to the bottom of the problem relatively quickly.  Basically the application in question is an asp.net application that takes a custom object and puts in in an MSMQ message (which currently uses the default binary serializer).  The class in question is marked with the Serializable attribute, has a couple of primitive members (e.g., ints, strings) and a couple of NameValueCollections.  One of the NameValueCollections is assigned directly from the HttpRequest.Headers NameValueCollection like this:&lt;/p&gt;
&lt;p&gt;&lt;font color="#3366ff"&gt;myObject.Headers = request.Headers;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;One day we started getting this error:&lt;/p&gt;
&lt;p&gt;&lt;font color="#ff6600"&gt;System.Runtime.Serialization.SerializationException: Type 'System.Web.HttpHeaderCollection' in Assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;This made absolutely no sense since, like my class, the NameValueCollection class was also marked with the Serializable attribute.  Not only that, but where was the System.Web.HttpHeaderCollection coming from?&lt;/p&gt;
&lt;p&gt;So since I was already debugging, I took a memory dump of the asp.net process from the command line like this:&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;&lt;strong&gt;cscript.exe adplus.vbs -hang -p 1808 -quiet -o c:\temp&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;The "1808" was simply the PID of my w3wp.exe process and I output the dump to the c:\temp directory.&lt;/p&gt;
&lt;p&gt;I then launched WinDbg and opened the crash dump that was produced in the previous step. First, you have to run (the sos extensions is what allows WinDbg to understand .NET 2.0):&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;&lt;strong&gt;.loadby sos mscorwks&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;So the first thing I wanted to see was all the types in memory and their corresponding method tables so I ran:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font face="Courier New" color="#0000ff"&gt;!dumpheap -stat&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A snippet of the results:&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;strong&gt;00000642802ae6c0&lt;/strong&gt;        5          320 MyNamespace.Foo&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;(just using Foo here for the class name.  The real output included the fully qualified namespace with correct object name).  The &lt;font face="Arial"&gt;00000642802ae6c0 is the method table for my Foo object. The 5 shows that we currently have 5 of my Foo objects loaded into memory.  The 320 is the total size (320/5 tells me each of my objects is taking up 64 bytes).&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Now I can narrow in on my issues a little bit. This shows me all 5 of the memory addresses for my Foo objects:&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;font face="Courier New" color="#0000ff"&gt;&lt;strong&gt;0:000&amp;gt; !dumpheap -mt 00000642802ae6c0 &lt;br /&gt;
&lt;/strong&gt;&lt;/font&gt;------------------------------&lt;br /&gt;
Heap 0&lt;br /&gt;
         Address               MT     Size&lt;br /&gt;
total 0 objects&lt;br /&gt;
------------------------------&lt;br /&gt;
Heap 1&lt;br /&gt;
         Address               MT     Size&lt;br /&gt;
00000000c0012e18 00000642802ae6c0       64     &lt;br /&gt;
total 1 objects&lt;br /&gt;
------------------------------&lt;br /&gt;
Heap 2&lt;br /&gt;
         Address               MT     Size&lt;br /&gt;
000000010053b830 00000642802ae6c0       64     &lt;br /&gt;
total 1 objects&lt;br /&gt;
------------------------------&lt;br /&gt;
Heap 3&lt;br /&gt;
         Address               MT     Size&lt;br /&gt;
0000000140235c60 00000642802ae6c0       64     &lt;br /&gt;
0000000140430fd8 00000642802ae6c0       64     &lt;br /&gt;
&lt;font color="#3366ff"&gt;00000001405275d0 00000642802ae6c0       64     &lt;br /&gt;
&lt;/font&gt;total 3 objects&lt;br /&gt;
------------------------------&lt;br /&gt;
total 5 objects&lt;br /&gt;
Statistics:&lt;br /&gt;
              MT    Count    TotalSize Class Name&lt;br /&gt;
00000642802ae6c0        5          320 MyNamespace.Foo&lt;br /&gt;
Total 5 objects&lt;br /&gt;
&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;So now I'm going to pick one of these five objects and drill down further.  I'll pick the one highlighted in blue that resides at 00000001405275d0:&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;font face="Arial"&gt;&lt;strong&gt;&lt;font face="Courier New" color="#0000ff"&gt;0:000&amp;gt; !do 00000001405275d0&lt;br /&gt;
&lt;/font&gt;&lt;/strong&gt;Name: MyNamespace.Foo&lt;br /&gt;
MethodTable: 00000642802ae6c0&lt;br /&gt;
EEClass: 00000642802baf08&lt;br /&gt;
Size: 64(0x40) bytes&lt;br /&gt;
 (C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\e22c2559\92c7e946\assembly\dl3\fed41db4\000e24c3_21cac701\MyAssemblyName.DLL)&lt;br /&gt;
Fields:&lt;br /&gt;
              MT    Field   Offset                 Type VT     Attr            Value Name&lt;br /&gt;
0000000000000000  4000028        8                       0 instance 0000000140527610 requests&lt;br /&gt;
0000064274e85620  4000029       10 ...meValueCollection  0 instance &lt;font color="#ff0000"&gt;0000000140528d60&lt;/font&gt; headers&lt;br /&gt;
0000064274e85620  400002a       18 ...meValueCollection  0 instance 0000000140527838 extraRequestData&lt;br /&gt;
0000000000000000  400002b       20                       0 instance 0000000140527a38 userStateData&lt;br /&gt;
000006427881edc8  400002c       28        System.String  0 instance 0000000000000000 endOfLineData&lt;br /&gt;
0000064278825318  400002d       30       System.Boolean  0 instance                0 isOptOut&lt;br /&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;font face="Arial"&gt;So I know the "headers" member is the one I want for focus on so I inspect that next:&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;font face="Arial"&gt;&lt;font face="Arial"&gt;&lt;font face="Courier New" color="#0000ff"&gt;&lt;strong&gt;0:000&amp;gt; !do 0000000140528d60 &lt;br /&gt;
&lt;/strong&gt;&lt;/font&gt;&lt;font color="#ff6600"&gt;Name: System.Web.HttpHeaderCollection&lt;br /&gt;
&lt;/font&gt;MethodTable: 00000642bcefad78&lt;br /&gt;
EEClass: 00000642bcf3be38&lt;br /&gt;
Size: 120(0x78) bytes&lt;br /&gt;
 (C:\WINDOWS\assembly\GAC_64\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll)&lt;br /&gt;
Fields:&lt;br /&gt;
              MT    Field   Offset                 Type VT     Attr            Value Name&lt;br /&gt;
0000064278825318  4001165       44       System.Boolean  0 instance                1 _readOnly&lt;br /&gt;
00000642788426f0  4001166        8 ...ections.ArrayList  0 instance 0000000140528f78 _entriesArray&lt;br /&gt;
000006427881f650  4001167       10 ...IEqualityComparer  0 instance 00000000ffffc148 _keyComparer&lt;br /&gt;
00000642788448c8  4001168       18 ...ections.Hashtable  0 instance 0000000140529000 _entriesTable&lt;br /&gt;
0000064274e82360  4001169       20 ...e+NameObjectEntry  0 instance 0000000000000000 _nullKeyEntry&lt;br /&gt;
0000064274e9e7e8  400116a       28 ...se+KeysCollection  0 instance 00000001405481c0 _keys&lt;br /&gt;
0000064278857210  400116b       30 ...SerializationInfo  0 instance 0000000000000000 _serializationInfo&lt;br /&gt;
000006427882b338  400116c       40         System.Int32  0 instance               10 _version&lt;br /&gt;
000006427881d280  400116d       38        System.Object  0 instance 000000014054ad48 _syncRoot&lt;br /&gt;
000006427881f748  400116e      a70 ...em.StringComparer  0   shared           static defaultComparer&lt;br /&gt;
                                 &amp;gt;&amp;gt; Domain:Value  0000000000136900:NotInit  0000000000177700:00000000ffffc110 &amp;lt;&amp;lt;&lt;br /&gt;
00000642788d8ba8  4001179       48      System.Object[]  0 instance 0000000000000000 _all&lt;br /&gt;
00000642788d8ba8  400117a       50      System.Object[]  0 instance 0000000140548160 _allKeys&lt;br /&gt;
00000642bceef310  400101b       58 ...m.Web.HttpRequest  0 instance 00000001405265f0 _request&lt;br /&gt;
00000642bceef7b8  400101c       60 ....Web.HttpResponse  0 instance 0000000000000000 _response&lt;br /&gt;
00000642bcf3ad30  400101d       68 ...IIS7WorkerRequest  0 instance 0000000000000000 _wr&lt;br /&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;font face="Arial"&gt;&lt;font face="Arial"&gt;And NOW we see something extremely interesting.  The headers member was supposed to be a NameValueCollection so why is my !do showing it to be an HttpHeaderCollection and what is this HttpHeaderCollection anyway and how is this System.Web DLL even compiling? So at this point, it's time for us to crack open trusty old Reflector and find its class definition:&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;font face="Arial"&gt;&lt;font face="Arial"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Arial"&gt;i&lt;/font&gt;&lt;font face="Arial"&gt;nternal class HttpHeaderCollection : HttpValueCollection&lt;/font&gt; &lt;/p&gt;
&lt;p&gt;So this is an &lt;em&gt;internal&lt;/em&gt; class to the System.Web DLL but it's being returned for a NameValueCollection property.  Also notice that it is NOT marked with the [Serializable] attribute (which was our problem to begin with).  It inherits from the HttpValueCollection (which is yet another internal class) and the HttpValueCollection (while it DOES have the Serializable attribute) inherits from the NameValueCollection object and THAT is how the code is compiling because of course this is a perfectly legal use of polymorphism.&lt;/p&gt;
&lt;p&gt;So...in the end, all of these classes are marked with the Serializable attribute except for the HttpHeadersCollection (which I believe to have been an oversight on Microsoft's part) which is causing our serialization problems and we cannot control the internal code of System.Web.  The fix ends up being pretty trivial - just iterate the NameValueCollection and adds the string primitives so that all serialization is happy.&lt;/p&gt;
&lt;p&gt;But the real moral of the story is that this is a good real world example that shows how to debug an issue that, at first glance, seems impossible. Using WinDbg like this is a very repeatable process that can help you get to the bottom of memory issues (and others) quite fast.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=114676"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=114676" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/114676.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2007/08/14/114676.aspx</guid>
            <pubDate>Wed, 15 Aug 2007 01:16:01 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/114676.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2007/08/14/114676.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/114676.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/114676.aspx</trackback:ping>
        </item>
        <item>
            <title>WinDbg / SOS Cheat sheet</title>
            <link>http://geekswithblogs.net/michelotti/archive/2007/08/14/114674.aspx</link>
            <description>This is a great post that anyone who works with WinDbg should check out:&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://geekswithblogs.net/.netonmymind/archive/2006/03/14/72262.aspx"&gt;http://geekswithblogs.net/.netonmymind/archive/2006/03/14/72262.aspx&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Bookmark it - it will come in handy anytime you're debugging with WinDbg.&lt;br /&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=114674"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=114674" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/114674.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2007/08/14/114674.aspx</guid>
            <pubDate>Wed, 15 Aug 2007 00:30:28 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/114674.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2007/08/14/114674.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/114674.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/114674.aspx</trackback:ping>
        </item>
        <item>
            <title>Build 64-bit MSI file on Cruise Control</title>
            <link>http://geekswithblogs.net/michelotti/archive/2007/03/17/109091.aspx</link>
            <description>&lt;P&gt;There is a known bug when trying to build 64-bit MSI files.&amp;nbsp; That is, the wrong InstallUtilLib.dll is embedded in the MSI.&amp;nbsp; A workaround to that problem is to use Orca to manually manipulate the MSI file in embed the correct version - the workaround is documented &lt;A href="http://blogs.msdn.com/heaths/archive/2006/02/01/64-bit-managed-custom-actions-with-visual-studio.aspx"&gt;here&lt;/A&gt;.&amp;nbsp; However, what if you want to automate this process on your build server?&amp;nbsp; Orca is a windows appication requiring user input.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;To automate this from the command line, you can leverage a few lines of VBScript code that essentially duplicates the Orca functionality.&amp;nbsp; Specifically, what we are trying to do is embed the 64-bit version of InstallUtilLib.dll into the MSI so that the BadImageFormatException does not rear its ugly head.&amp;nbsp; The key line of the VBScript is the &lt;A href="http://blogs.msdn.com/heaths/archive/2006/02/01/64-bit-managed-custom-actions-with-visual-studio.aspx"&gt;SetStream&lt;/A&gt; method of the Record object.&amp;nbsp; The complete VBScript solution is shown below and can simply be invoked from CCNet using a standard command line task such as the &lt;A href="http://msdn2.microsoft.com/en-us/library/x8zx72cd.aspx"&gt;Exec&lt;/A&gt; MSBuild task with the appropriate command line arguments.&lt;/P&gt;
&lt;P&gt;Option Explicit&lt;BR&gt;On Error Resume Next&lt;/P&gt;
&lt;P&gt;Const msiViewModifyInsert&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 1&lt;BR&gt;Const msiViewModifyUpdate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 2&lt;BR&gt;Const msiViewModifyAssign&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 3&lt;BR&gt;Const msiViewModifyReplace&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 4&lt;BR&gt;Const msiViewModifyDelete&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 6&lt;/P&gt;
&lt;P&gt;If (WScript.Arguments.Count = 0) Then&lt;BR&gt;&amp;nbsp;&amp;nbsp; Msgbox("No command line argument specified for MSI location. Please try again.")&lt;BR&gt;&amp;nbsp;&amp;nbsp; Wscript.Quit 1&lt;BR&gt;Else&lt;BR&gt;&amp;nbsp;AdjustInstallUtil()&lt;BR&gt;End If&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;public sub AdjustInstallUtil()&lt;BR&gt;&amp;nbsp;On Error Resume Next&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;dim msiInstance : msiInstance = WScript.Arguments.Item(0)&lt;BR&gt;&amp;nbsp;dim installer : Set installer = CreateObject("WindowsInstaller.Installer") &lt;BR&gt;&amp;nbsp;dim installerDb : Set installerDb = installer.OpenDatabase(cstr(msiInstance), 1)&lt;BR&gt;&amp;nbsp;dim sqlCommand : sqlCommand = "SELECT * FROM Binary WHERE `Name`='InstallUtil'"&lt;BR&gt;&amp;nbsp;dim view : Set view = installerDb.OpenView(sqlCommand)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;view.Execute()&lt;BR&gt;&amp;nbsp;dim record : Set record = view.Fetch()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;If Not record Is Nothing Then&lt;BR&gt;&amp;nbsp;&amp;nbsp;const dataCol = 2&lt;BR&gt;&amp;nbsp;&amp;nbsp;record.SetStream dataCol, "C:\Program Files\CruiseControl.NET\64BitMSI\InstallUtilLib.dll"&lt;BR&gt;&amp;nbsp;&amp;nbsp;view.Modify msiViewModifyUpdate, record&lt;BR&gt;&amp;nbsp;&amp;nbsp;installerDb.Commit&lt;BR&gt;&amp;nbsp;End IF&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;'clean up&lt;BR&gt;&amp;nbsp;Set installerDb = Nothing&lt;BR&gt;&amp;nbsp;Set view = Nothing&lt;BR&gt;&amp;nbsp;Set installer = Nothing&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;'Error Handling&lt;BR&gt;&amp;nbsp;If Err.number &amp;gt; 0 Then&lt;BR&gt;&amp;nbsp;&amp;nbsp; Msgbox("Error while adjusting x64 InstallUtilLib: " &amp;amp; Err.Description &amp;amp; ": " &amp;amp; Err.Source &amp;amp; ": " &amp;amp; Err.number)&lt;BR&gt;&amp;nbsp;End If &lt;BR&gt;end sub&lt;BR&gt;&lt;/P&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=109091"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=109091" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/109091.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2007/03/17/109091.aspx</guid>
            <pubDate>Sun, 18 Mar 2007 00:44:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/109091.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2007/03/17/109091.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/109091.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/109091.aspx</trackback:ping>
        </item>
        <item>
            <title>Validation framework on CodePlex</title>
            <link>http://geekswithblogs.net/michelotti/archive/2006/11/23/97954.aspx</link>
            <description>&lt;P&gt;This past summer I had an article published in Visual Studio magazine in which I outlined a Validation framework that I created to declaratively validate business objects.&amp;nbsp; Simon&amp;nbsp;Cropp has taken the initiative to put the source code up on CodePlex as an open source community project.&amp;nbsp; It can be found here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.codeplex.com/ValidationFramework"&gt;http://www.codeplex.com/ValidationFramework&lt;/A&gt;&lt;/P&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=97954"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=97954" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/97954.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2006/11/23/97954.aspx</guid>
            <pubDate>Fri, 24 Nov 2006 00:14:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/97954.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2006/11/23/97954.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/97954.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/97954.aspx</trackback:ping>
        </item>
        <item>
            <title>Error MSB6006: "aspnet_merge.exe" exited with code 1 - Web Deployment Project</title>
            <link>http://geekswithblogs.net/michelotti/archive/2006/07/31/86754.aspx</link>
            <description>&lt;P&gt;This error often rears its ugly head when compiling an ASP.NET 2.0 Web Deployment Project.&amp;nbsp; At first glance, it is extremely difficult to troubleshoot because there is not much information along with the error.&amp;nbsp; In order to troubleshoot this, you need to use a higher level of verbosity.&amp;nbsp; If you're using MSBuild from the command line you can use the /verbosity switch like this (and then look at Output window for build):&lt;/P&gt;
&lt;P&gt;C:\projects&amp;gt;msbuild YourSolutionFile.sln /t:Rebuild /p:Configuration=Release &lt;STRONG&gt;/verbosity:detailed&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If you're using Visual Studio, then you can set Tools - Options like this:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="/images/geekswithblogs_net/michelotti/4145/o_verbosity.JPG"&gt;&lt;/P&gt;
&lt;P&gt;Typically the problem is that when aspnet_merge merges the entire web project into a single assembly, you might find naming collisions.&amp;nbsp; By default, asp.net 2005 web site applications do not put a default namespace in the class files so if you create MyPage.aspx in the root and also in a sub-folder, this would causes a conflict when merged into a single assembly for the Release build.&amp;nbsp; This problem would not manifest itself during development because you're not pre-compiling the entire web site into a single DLL so there are several DLLs that make up the web project and naming collisions&amp;nbsp;are avoided.&amp;nbsp; To fix the problem you can obviously either rename one of the classes or provide a namespace to avoid the conflict.&lt;/P&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=86754"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=86754" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/86754.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2006/07/31/86754.aspx</guid>
            <pubDate>Mon, 31 Jul 2006 22:47:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/86754.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2006/07/31/86754.aspx#feedback</comments>
            <slash:comments>37</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/86754.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/86754.aspx</trackback:ping>
        </item>
        <item>
            <title>Visual Studio Magazine Article on Validating Business Objects</title>
            <link>http://geekswithblogs.net/michelotti/archive/2006/06/27/83340.aspx</link>
            <description>&lt;P&gt;I just had an article published in the June issue of Visual Studio magazine.&amp;nbsp; The article essentially presents a flexible framework for validating business objects utilizing attributes.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.visualstudiomagazine.com"&gt;http://www.visualstudiomagazine.com&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;This is my first time in &amp;#8220;print&amp;#8221;!&amp;nbsp; The direct link to my article is:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.ftponline.com/vsm/2006_06/magazine/features/smichelotti/"&gt;http://www.ftponline.com/vsm/2006_06/magazine/features/smichelotti/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;A couple of people had trouble downloading the code from the VSM site.&amp;nbsp;&amp;nbsp;Alternatively, it can be downloaded here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.4shared.com/file/2397388/6e60ba0b/validationframework.html"&gt;http://www.4shared.com/file/2397388/6e60ba0b/validationframework.html&lt;/A&gt;&lt;/P&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=83340"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=83340" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/83340.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2006/06/27/83340.aspx</guid>
            <pubDate>Tue, 27 Jun 2006 21:45:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/83340.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2006/06/27/83340.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/83340.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/83340.aspx</trackback:ping>
        </item>
        <item>
            <title>Visual Studio Magazine Article on Validating Business Objects</title>
            <link>http://geekswithblogs.net/michelotti/archive/2006/06/27/83338.aspx</link>
            <description>&lt;P&gt;I just had an article published in the June issue of Visual Studio magazine.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.visualstudiomagazine.com"&gt;http://www.visualstudiomagazine.com&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;This is my first time in &amp;#8220;print&amp;#8221;!&amp;nbsp; The direct link to my article is:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.ftponline.com/vsm/2006_06/magazine/features/smichelotti/"&gt;http://www.ftponline.com/vsm/2006_06/magazine/features/smichelotti/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;A couple of people had trouble downloading the code from the VSM site so I'm happy to provide directly.&amp;nbsp; The article essentially presents a flexible framework for validating business objects utilizing attributes.&lt;/P&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=83338"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=83338" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/83338.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2006/06/27/83338.aspx</guid>
            <pubDate>Tue, 27 Jun 2006 21:19:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/83338.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2006/06/27/83338.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/83338.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/83338.aspx</trackback:ping>
        </item>
        <item>
            <title>GridView - Set column properties at run-time</title>
            <link>http://geekswithblogs.net/michelotti/archive/2006/03/30/73896.aspx</link>
            <description>&lt;P&gt;An interesting issue came up today that, although it now looks simple, did not have an immediately obvious solution.&amp;nbsp; Specifically, what if you want to set properties of individual columns of a GridView at run-time (via C# code) rather than at design time in the aspx code.&lt;/P&gt;
&lt;P&gt;For example, let's say you want to set the DataFormatString property of a BoundField column.&amp;nbsp; In short, it is a 2-part solution.&amp;nbsp; First, you must positionally extract your column out of the GridView's Columns property while casting it to your desired type (in this case a BoundField).&amp;nbsp; Second, after you have set the properties, do the databind.&amp;nbsp; So if you have column that you want to format as currency, the code might look like this:&lt;/P&gt;&lt;FONT color=#008080 size=1&gt;
&lt;P&gt;BoundField&lt;/FONT&gt;&lt;FONT size=1&gt; priceField = grid.Columns[0] &lt;/FONT&gt;&lt;FONT color=#0000ff size=1&gt;as&lt;/FONT&gt;&lt;FONT size=1&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=1&gt;BoundField&lt;/FONT&gt;&lt;FONT size=1&gt;;&lt;BR&gt;priceField.DataFormatString = &lt;/FONT&gt;&lt;FONT color=#ff0000 size=1&gt;"{0:c}"&lt;/FONT&gt;&lt;FONT size=1&gt;;&lt;BR&gt;priceField.HtmlEncode = &lt;/FONT&gt;&lt;FONT color=#0000ff size=1&gt;false&lt;/FONT&gt;&lt;FONT size=1&gt;;&lt;BR&gt;grid.DataSource = list;&lt;BR&gt;grid.DataBind();&lt;BR&gt;&lt;/FONT&gt;
&lt;P&gt;Note that since you're manually doing the data binding this will preclude you from using the ObjectDataSource in this case (since that happens before your user code in the Page_Load event).&lt;/P&gt;
&lt;P&gt;Taking this one step further, you could even add columns dynamically at run-time doing this:&lt;/P&gt;&lt;FONT color=#008080 size=1&gt;
&lt;P&gt;BoundField&lt;/FONT&gt;&lt;FONT size=1&gt; someField = &lt;/FONT&gt;&lt;FONT color=#0000ff size=1&gt;new&lt;/FONT&gt;&lt;FONT size=1&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=1&gt;BoundField&lt;/FONT&gt;&lt;FONT size=1&gt;();&lt;BR&gt;someField.DataField = &lt;/FONT&gt;&lt;FONT color=#ff0000 size=1&gt;"Price"&lt;/FONT&gt;&lt;FONT size=1&gt;;&lt;BR&gt;someField.DataFormatString = &lt;/FONT&gt;&lt;FONT color=#ff0000 size=1&gt;"{0:c}"&lt;/FONT&gt;&lt;FONT size=1&gt;;&lt;BR&gt;someField.HtmlEncode = &lt;/FONT&gt;&lt;FONT color=#0000ff size=1&gt;false&lt;/FONT&gt;&lt;FONT size=1&gt;;&lt;BR&gt;grid.Columns.Add(someField);&lt;BR&gt;&lt;/FONT&gt;
&lt;P&gt;Note: One reason this might throw you off at first is that in the C# intellisense, BoundColumn comes up first and if you're not watching carefully you might try to use that instead of BoundField which will prevent you from compiling!&lt;/P&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=73896"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=73896" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/73896.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2006/03/30/73896.aspx</guid>
            <pubDate>Thu, 30 Mar 2006 22:51:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/73896.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2006/03/30/73896.aspx#feedback</comments>
            <slash:comments>11</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/73896.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/73896.aspx</trackback:ping>
        </item>
        <item>
            <title>Real world example of C# Anonymous Methods</title>
            <link>http://geekswithblogs.net/michelotti/archive/2006/03/21/72909.aspx</link>
            <description>&lt;P&gt;Often when a new language features come out (in this case anonymous method) we often see syntax examples like this:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&lt;FONT size=1&gt;delegate void SomeDelegate();&lt;BR&gt;public void InvokeMethod()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp; SomeDelegate del = delegate() &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show("Hello");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;BR&gt;&amp;nbsp; del&lt;/FONT&gt;();&amp;nbsp;&amp;nbsp; &lt;BR&gt;}&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;and we say, great but when is code like THAT ever going to be useful to me?&amp;nbsp; In that trivial example, of course that's not very useful.&amp;nbsp; But when you consider the power anonymous methods gives you both to pass in parameters and also make use of local objects then tons of possibilities are opened up for making code more concise and efficient.&amp;nbsp; Consider a case where you're using a DataReader to read multiple result sets.&amp;nbsp; Your code might look something like this:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=1&gt;public Person GetPerson(int personID)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;//(Perform data access code here to create DataReader)&lt;BR&gt;&amp;nbsp;Person person = new Person();&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;if (dr.Read())&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;person = personMapper.BuildItem(dr);&lt;BR&gt;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;dr.NextResult();&lt;BR&gt;&amp;nbsp;if (dr.Read())&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;person.Address = addressMapper.BuildItem(dr);&lt;BR&gt;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;dr.NextResult();&lt;BR&gt;&amp;nbsp;if (dr.Read())&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;person.EmploymentInfo = employmentMapper.BuildItem(dr);&lt;BR&gt;&amp;nbsp;}&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;This code is now littered with IF statements and dr.NextResult() method calls.&amp;nbsp; To make this more concise, you could create a simple method that passes in a delegate that you can use anonymously:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=1&gt;public static void ReadNextResult(NullableDataReader dr, Execute execute)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;dr.NextResult();&lt;BR&gt;&amp;nbsp;if (dr.Read())&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;execute();&lt;BR&gt;&amp;nbsp;}&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Then the consuming code can simply look like this:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=1&gt;public Person GetPerson(int personID)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;//(Perform data access code here to create DataReader)&lt;BR&gt;&amp;nbsp;Person person = new Person();&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;DataUtil.ReadNextResult(dr, delegate()&lt;BR&gt;&amp;nbsp;&amp;nbsp;{ person = personMapper.BuildItem(dr); });&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=1&gt;&amp;nbsp;DataUtil.ReadNextResult(dr, delegate()&lt;BR&gt;&amp;nbsp;&amp;nbsp;{ person.Address = addressMapper.BuildItem(dr); });&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=1&gt;&amp;nbsp;DataUtil.ReadNextResult(dr, delegate()&lt;BR&gt;&amp;nbsp;&amp;nbsp;{ person.EmploymentInfo = employmentMapper.BuildItem(dr); });&amp;nbsp;&amp;nbsp;&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Notice that because of the use of anonymous methods, not only can we pass in the DataReader to the method but also we can use local objects (e.g., the &amp;#8220;mapper&amp;#8221; objects) inside the anonymous methods.&amp;nbsp; Internally the C# compiler creates private nested classes containing the delegates we want to execute that have member variables that are assigned the &amp;#8220;local object&amp;#8221; references which is why it's possible to pull this off in-line rather than having to create a completely separate method.&lt;/P&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=72909"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=72909" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/72909.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2006/03/21/72909.aspx</guid>
            <pubDate>Tue, 21 Mar 2006 12:51:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/72909.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2006/03/21/72909.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/72909.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/72909.aspx</trackback:ping>
        </item>
    </channel>
</rss>