<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" 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:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Bradleys DasBlog! - Technical</title>
    <link>http://www.bradleysblog.net/Blog/</link>
    <description>newtelligence powered</description>
    <language>en-us</language>
    <copyright>Chris Bradley, Andrea Bradley</copyright>
    <lastBuildDate>Fri, 30 Apr 2010 21:12:04 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>chrisb@pbssystems.com</managingEditor>
    <webMaster>chrisb@pbssystems.com</webMaster>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=2376c2ed-0b79-476d-8fa3-3861c93f00bc</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,2376c2ed-0b79-476d-8fa3-3861c93f00bc.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,2376c2ed-0b79-476d-8fa3-3861c93f00bc.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=2376c2ed-0b79-476d-8fa3-3861c93f00bc</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Had an issue all of a sudden today opening a vb6 project we use all the time. It gave
a cryptic message about a file format no longer being supported.
</p>
        <p>p.<img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=2376c2ed-0b79-476d-8fa3-3861c93f00bc" />
It turned out I had to go delete a corrupted oca file from teh vb6.exe folder. Best
thing to do is crack open process explorer to see what file it's blowing up on and
then go delete that OCA. Next time you add the reference it will get regenerated and
then things are great. Where were ya on this one google?
</p>
      </body>
      <title>VB6 - file format no longer supported</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,2376c2ed-0b79-476d-8fa3-3861c93f00bc.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2010/04/30/VB6FileFormatNoLongerSupported.aspx</link>
      <pubDate>Fri, 30 Apr 2010 21:12:04 GMT</pubDate>
      <description>&lt;p&gt;
Had an issue all of a sudden today opening a vb6 project we use all the time. It gave
a cryptic message about a file format no longer being supported.
&lt;/p&gt;
&lt;p&gt;p.&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=2376c2ed-0b79-476d-8fa3-3861c93f00bc"/&gt;It turned out I had to go delete a corrupted oca file from teh vb6.exe folder. Best thing to do is crack open process explorer to see what file it's blowing up on and then go delete that OCA. Next time you add the reference it will get regenerated and then things are great. Where were ya on this one google?</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,2376c2ed-0b79-476d-8fa3-3861c93f00bc.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=cba2da62-cb5e-4543-9dc4-6d7b358b9034</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,cba2da62-cb5e-4543-9dc4-6d7b358b9034.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,cba2da62-cb5e-4543-9dc4-6d7b358b9034.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=cba2da62-cb5e-4543-9dc4-6d7b358b9034</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
          <head>
            <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
            <meta name="ProgId" content="Word.Document" />
            <meta name="Generator" content="Microsoft Word 12" />
            <meta name="Originator" content="Microsoft Word 12" />
            <link rel="File-List" href="BlogBlah_files/filelist.xml" />
            <!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>Chris Bradley</o:Author>
  <o:Template>Normal</o:Template>
  <o:LastAuthor>Chris Bradley</o:LastAuthor>
  <o:Revision>1</o:Revision>
  <o:TotalTime>12</o:TotalTime>
  <o:Created>2010-04-05T21:15:00Z</o:Created>
  <o:LastSaved>2010-04-05T21:27:00Z</o:LastSaved>
  <o:Pages>3</o:Pages>
  <o:Words>641</o:Words>
  <o:Characters>3655</o:Characters>
  <o:Lines>30</o:Lines>
  <o:Paragraphs>8</o:Paragraphs>
  <o:CharactersWithSpaces>4288</o:CharactersWithSpaces>
  <o:Version>12.00</o:Version>
 </o:DocumentProperties>
</xml><![endif]-->
            <link rel="themeData" href="BlogBlah_files/themedata.thmx" />
            <link rel="colorSchemeMapping" href="BlogBlah_files/colorschememapping.xml" />
            <!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:SpellingState>Clean</w:SpellingState>
  <w:GrammarState>Clean</w:GrammarState>
  <w:TrackMoves>false</w:TrackMoves>
  <w:TrackFormatting/>
  <w:PunctuationKerning/>
  <w:DrawingGridHorizontalSpacing>5.5 pt</w:DrawingGridHorizontalSpacing>
  <w:DisplayHorizontalDrawingGridEvery>2</w:DisplayHorizontalDrawingGridEvery>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:DoNotPromoteQF/>
  <w:LidThemeOther>EN-US</w:LidThemeOther>
  <w:LidThemeAsian>X-NONE</w:LidThemeAsian>
  <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
  <w:Compatibility>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:DontGrowAutofit/>
   <w:SplitPgBreakAndParaMark/>
   <w:DontVertAlignCellWithSp/>
   <w:DontBreakConstrainedForcedTables/>
   <w:DontVertAlignInTxbx/>
   <w:Word11KerningPairs/>
   <w:CachedColBalance/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
  <m:mathPr>
   <m:mathFont m:val="Cambria Math"/>
   <m:brkBin m:val="before"/>
   <m:brkBinSub m:val="&#45;-"/>
   <m:smallFrac m:val="off"/>
   <m:dispDef/>
   <m:lMargin m:val="0"/>
   <m:rMargin m:val="0"/>
   <m:defJc m:val="centerGroup"/>
   <m:wrapIndent m:val="1440"/>
   <m:intLim m:val="subSup"/>
   <m:naryLim m:val="undOvr"/>
  </m:mathPr></w:WordDocument>
</xml><![endif]-->
            <!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
  DefSemiHidden="true" DefQFormat="false" DefPriority="99"
  LatentStyleCount="267">
  <w:LsdException Locked="false" Priority="0" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 1"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 2"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 3"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 4"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 5"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 6"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 7"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 8"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 9"/>
  <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
  <w:LsdException Locked="false" Priority="10" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Title"/>
  <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
  <w:LsdException Locked="false" Priority="11" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
  <w:LsdException Locked="false" Priority="22" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
  <w:LsdException Locked="false" Priority="20" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
  <w:LsdException Locked="false" Priority="59" SemiHidden="false"
   UnhideWhenUsed="false" Name="Table Grid"/>
  <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
  <w:LsdException Locked="false" Priority="1" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 1"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
  <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
  <w:LsdException Locked="false" Priority="34" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
  <w:LsdException Locked="false" Priority="29" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
  <w:LsdException Locked="false" Priority="30" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 1"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 2"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 2"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 3"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 3"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 4"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 4"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 5"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 5"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 6"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 6"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
  <w:LsdException Locked="false" Priority="19" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
  <w:LsdException Locked="false" Priority="21" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
  <w:LsdException Locked="false" Priority="31" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
  <w:LsdException Locked="false" Priority="32" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
  <w:LsdException Locked="false" Priority="33" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
  <w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
  <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
 </w:LatentStyles>
</xml><![endif]-->
            <style>
              <!--
 /* Font Definitions */
 @font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;
	mso-font-charset:1;
	mso-generic-font-family:roman;
	mso-font-format:other;
	mso-font-pitch:variable;
	mso-font-signature:0 0 0 0 0 0;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;
	mso-font-charset:0;
	mso-generic-font-family:swiss;
	mso-font-pitch:variable;
	mso-font-signature:-520092929 1073786111 9 0 415 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-parent:"";
	margin-top:0in;
	margin-right:0in;
	margin-bottom:10.0pt;
	margin-left:0in;
	line-height:115%;
	mso-pagination:widow-orphan;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:Calibri;
	mso-fareast-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";
	mso-bidi-theme-font:minor-bidi;}
span.SpellE
	{mso-style-name:"";
	mso-spl-e:yes;}
span.GramE
	{mso-style-name:"";
	mso-gram-e:yes;}
.MsoChpDefault
	{mso-style-type:export-only;
	mso-default-props:yes;
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:Calibri;
	mso-fareast-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";
	mso-bidi-theme-font:minor-bidi;}
.MsoPapDefault
	{mso-style-type:export-only;
	margin-bottom:10.0pt;
	line-height:115%;}
@page Section1
	{size:11.0in 8.5in;
	mso-page-orientation:landscape;
	margin:1.0in 1.0in 1.0in 1.0in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
-->
            </style>
            <!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-priority:99;
	mso-style-qformat:yes;
	mso-style-parent:"";
	mso-padding-alt:0in 5.4pt 0in 5.4pt;
	mso-para-margin-top:0in;
	mso-para-margin-right:0in;
	mso-para-margin-bottom:10.0pt;
	mso-para-margin-left:0in;
	line-height:115%;
	mso-pagination:widow-orphan;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";
	mso-bidi-theme-font:minor-bidi;}
</style>
<![endif]-->
            <!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="2050"/>
</xml><![endif]-->
            <!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml><![endif]-->
          </head>
          <body lang="EN-US" style="tab-interval:.5in">
            <div class="Section1">
              <p class="MsoNormal">
I recently downloaded a copy of a new tool from red-gage called Ant Memory Profiler.
Ant Memory Profiler is an application that allows you to do memory usage analysis
on dot net apps to uncover how your app consumes memory. 
</p>
              <p class="MsoNormal">
During the course of trying out this tool we uncovered an interesting memory leak
in the dot net framework <span class="SpellE">ToolStrip</span> control. Our symptom
of this was that one of our application forms was being held in memory long after
it should have been garbage collected. After a quick tour through <span class="SpellE">google</span> I
found <span class="GramE">a some</span> references on why this is occurring and how
to ensure things get cleaned up properly.
</p>
              <p class="MsoNormal">
Here’s how we add the cleanup code to the close event of the form…
</p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Protected</span>
                  <span style="color:blue">Overrides</span>
                  <span style="color:blue">Sub</span> OnClosed(<span style="color:blue">ByVal</span> e <span style="color:blue">As</span> System.EventArgs)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">MyBase</span>.OnClosed(e)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <o:p> </o:p>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:green">'note,
this call is still required as it cleans up one set of extra handlers<o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>reportViewer.Toolbar.Visible
= <span style="color:blue">False<o:p></o:p></span></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">
                  <o:p> </o:p>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:green">'this
is the really ugly stuff though, let our cleanup class take care of things<o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Dim</span> gc2 <span style="color:blue">As</span><span style="color:blue">New</span> ToolStripGarbageCollector<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>gc2.RemoveHandlers(reportViewer)<o:p></o:p></span>
              </p>
              <p class="MsoNormal">
                <span style="font-size:10.0pt;line-height:115%;font-family:&#xA;&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">End</span>
                  <span style="color:blue">Sub<o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal">
                <span class="GramE">And <span class="SpellE">heres</span> the meat behind the cleanup
class.</span> Don’t ask what this does, it’s pretty much a copy and paste I found
from some newsgroups. 
</p>
              <p class="MsoNormal">
                <o:p> </o:p>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Public</span>
                  <span style="color:blue">Class</span> ToolStripGarbageCollector<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Private</span>
                  <span style="color:blue">Const</span> EVENTHANDLER_ON_USER_PREFERENCE_CHANGED <span style="color:blue">As</span><span style="color:blue">String</span> = <span style="color:#A31515">"OnUserPreferenceChanged"<o:p></o:p></span></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Private</span>
                  <span style="color:blue">Const</span> LIST_HANDLERS <span style="color:blue">As</span><span style="color:blue">String</span> = <span style="color:#A31515">"_handlers"<o:p></o:p></span></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Private</span>
                  <span style="color:blue">Const</span> ON_USER_PREFERENCE_CHANGED_EVENT <span style="color:blue">As</span><span style="color:blue">String</span> = <span style="color:#A31515">"OnUserPreferenceChangedEvent"<o:p></o:p></span></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Private</span>
                  <span style="color:blue">Const</span> SYSTEM_EVENT_INVOKE_INFO <span style="color:blue">As</span><span style="color:blue">String</span> = <span style="color:#A31515">"SystemEventInvokeInfo"<o:p></o:p></span></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Private</span>
                  <span style="color:blue">Const</span> TARGET_DELEGATE <span style="color:blue">As</span><span style="color:blue">String</span> = <span style="color:#A31515">"_delegate"<o:p></o:p></span></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;color:#A31515;mso-no-proof:yes">
                  <o:p> </o:p>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;color:#A31515;mso-no-proof:yes">
                  <o:p> </o:p>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Public</span>
                  <span style="color:blue">Sub</span> RemoveHandlers(<span style="color:blue">ByVal</span> ctrl <span style="color:blue">As</span> Control)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>NavigateControls(ctrl)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">End</span>
                  <span style="color:blue">Sub<o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">
                  <o:p> </o:p>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">
                  <o:p> </o:p>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Public</span>
                  <span style="color:blue">Sub</span> NavigateControls(<span style="color:blue">ByVal</span> ctrl <span style="color:blue">As</span> Control)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>Console.WriteLine(ctrl.Name
&amp; <span style="color:#A31515">"-"</span> &amp; ctrl.GetType.FullName)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <o:p> </o:p>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">If</span> ctrl.GetType.FullName
= <span style="color:#A31515">"System.Windows.Forms.ToolStripTextBox+ToolStripTextBoxControl"</span><span style="color:blue">Then<o:p></o:p></span></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>RemoveUpcHandler(ctrl)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">ElseIf</span> ctrl.GetType.FullName
= <span style="color:#A31515">"System.Windows.Forms.ToolStrip"</span><span style="color:blue">Then<o:p></o:p></span></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>RemoveUpcHandler(ctrl)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">End</span>
                  <span style="color:blue">If<o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">
                  <o:p> </o:p>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">For</span>
                  <span style="color:blue">Each</span> c <span style="color:blue">As</span> Control <span style="color:blue">In</span> ctrl.Controls<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>NavigateControls(c)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Next<o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">End</span>
                  <span style="color:blue">Sub<o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">
                  <o:p> </o:p>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Private</span>
                  <span style="color:blue">Sub</span> RemoveUpcHandler(<span style="color:blue">ByVal</span> ctrl <span style="color:blue">As</span> Control)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:green">'create
the delegate to OnUserPreferenceChanged<span style="mso-spacerun:yes"></span><o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Dim</span> d <span style="color:blue">As</span> [Delegate]
= [Delegate].CreateDelegate(<span style="color:blue">GetType</span>(Microsoft.Win32.UserPreferenceChangedEventHandler),
ctrl, EVENTHANDLER_ON_USER_PREFERENCE_CHANGED)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <o:p> </o:p>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Dim</span> handlers <span style="color:blue">As</span><span style="color:blue">Object</span> = <span style="color:blue">GetType</span>(Microsoft.Win32.SystemEvents).GetField(<span style="color:#A31515">"_handlers"</span>,
Reflection.BindingFlags.NonPublic <span style="color:blue">Or</span> Reflection.BindingFlags.Static).GetValue(<span style="color:blue">Nothing</span>)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Dim</span> upcHandler <span style="color:blue">As</span><span style="color:blue">Object</span> = <span style="color:blue">GetType</span>(Microsoft.Win32.SystemEvents).GetField(ON_USER_PREFERENCE_CHANGED_EVENT,
Reflection.BindingFlags.NonPublic <span style="color:blue">Or</span> Reflection.BindingFlags.Static).GetValue(<span style="color:blue">Nothing</span>)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:green">'get
a SystemEventInvokeInfo type<span style="mso-spacerun:yes"></span><o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Dim</span> systemEventInvokeInfo <span style="color:blue">As</span><span style="color:blue">Object</span> = <span style="color:blue">GetType</span>(Microsoft.Win32.SystemEvents).GetNestedType(SYSTEM_EVENT_INVOKE_INFO,
Reflection.BindingFlags.NonPublic <span style="color:blue">Or</span> Reflection.BindingFlags.Instance)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:green">'get
the SystemEventInvokeInfo list for the UserPreferenceChangedEvent<span style="mso-spacerun:yes"></span><o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Dim</span> upcHandlerList <span style="color:blue">As</span> IList
= <span style="color:blue">CType</span>(<span style="color:blue">CType</span>(handlers,
IDictionary).Item(upcHandler), IList)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <o:p> </o:p>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:green">'initialize
a target count<span style="mso-spacerun:yes"></span><o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Dim</span> targetCount <span style="color:blue">As</span><span style="color:blue">Integer</span> =
0<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Dim</span> i <span style="color:blue">As</span><span style="color:blue">Integer</span> =
0<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:green">'loop<span style="mso-spacerun:yes"></span><o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">While</span> i
&lt; upcHandlerList.Count<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>systemEventInvokeInfo
= upcHandlerList(i)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:green">'get
the SystemEventInvokeInfo._delegate field<span style="mso-spacerun:yes"></span><o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Dim</span> target <span style="color:blue">As</span> [Delegate]
= <span style="color:blue">CType</span>(systemEventInvokeInfo.GetType().GetField(TARGET_DELEGATE,
Reflection.BindingFlags.NonPublic <span style="color:blue">Or</span> Reflection.BindingFlags.Instance).GetValue(systemEventInvokeInfo),
[Delegate])<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:green">'eval<span style="mso-spacerun:yes"></span><o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">If</span> target.Target <span style="color:blue">Is</span> d.Target <span style="color:blue">Then<o:p></o:p></span></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:green">'increment
on positive ID<span style="mso-spacerun:yes"></span><o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="mso-spacerun:yes">
                  </span>targetCount
+= 1<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">End</span>
                  <span style="color:blue">If<o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>i
+= 1<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">End</span>
                  <span style="color:blue">While<o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:green">'remove
the handlers<span style="mso-spacerun:yes"></span><o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">For</span> i
= 1 <span style="color:blue">To</span> targetCount<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">RemoveHandler</span> Microsoft.Win32.SystemEvents.UserPreferenceChanged, <span style="color:blue">CType</span>(d,
Microsoft.Win32.UserPreferenceChangedEventHandler)<o:p></o:p></span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">Next<o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="mso-spacerun:yes">
                  </span>
                  <span style="color:blue">End</span>
                  <span style="color:blue">Sub<o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">
                  <o:p> </o:p>
                </span>
              </p>
              <p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&#xA;normal;mso-layout-grid-align:none;text-autospace:none">
                <span style="font-size:&#xA;10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">End</span>
                <span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes">
                  <span style="color:blue">Class<o:p></o:p></span>
                </span>
              </p>
              <p class="MsoNormal">
                <o:p> </o:p>
              </p>
            </div>
          </body>
        </html>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=cba2da62-cb5e-4543-9dc4-6d7b358b9034" />
      </body>
      <title>ToolStripTextBox Memory Leaks</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,cba2da62-cb5e-4543-9dc4-6d7b358b9034.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2010/04/05/ToolStripTextBoxMemoryLeaks.aspx</link>
      <pubDate>Mon, 05 Apr 2010 21:28:57 GMT</pubDate>
      <description>&lt;html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"&gt;
&lt;head&gt;
&lt;meta http-equiv=Content-Type content="text/html; charset=windows-1252"&gt;
&lt;meta name=ProgId content=Word.Document&gt;
&lt;meta name=Generator content="Microsoft Word 12"&gt;
&lt;meta name=Originator content="Microsoft Word 12"&gt;
&lt;link rel=File-List href="BlogBlah_files/filelist.xml"&gt;
&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;o:DocumentProperties&gt;
  &lt;o:Author&gt;Chris Bradley&lt;/o:Author&gt;
  &lt;o:Template&gt;Normal&lt;/o:Template&gt;
  &lt;o:LastAuthor&gt;Chris Bradley&lt;/o:LastAuthor&gt;
  &lt;o:Revision&gt;1&lt;/o:Revision&gt;
  &lt;o:TotalTime&gt;12&lt;/o:TotalTime&gt;
  &lt;o:Created&gt;2010-04-05T21:15:00Z&lt;/o:Created&gt;
  &lt;o:LastSaved&gt;2010-04-05T21:27:00Z&lt;/o:LastSaved&gt;
  &lt;o:Pages&gt;3&lt;/o:Pages&gt;
  &lt;o:Words&gt;641&lt;/o:Words&gt;
  &lt;o:Characters&gt;3655&lt;/o:Characters&gt;
  &lt;o:Lines&gt;30&lt;/o:Lines&gt;
  &lt;o:Paragraphs&gt;8&lt;/o:Paragraphs&gt;
  &lt;o:CharactersWithSpaces&gt;4288&lt;/o:CharactersWithSpaces&gt;
  &lt;o:Version&gt;12.00&lt;/o:Version&gt;
 &lt;/o:DocumentProperties&gt;
&lt;/xml&gt;&lt;![endif]--&gt;
&lt;link rel=themeData href="BlogBlah_files/themedata.thmx"&gt;
&lt;link rel=colorSchemeMapping href="BlogBlah_files/colorschememapping.xml"&gt;
&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;w:WordDocument&gt;
  &lt;w:SpellingState&gt;Clean&lt;/w:SpellingState&gt;
  &lt;w:GrammarState&gt;Clean&lt;/w:GrammarState&gt;
  &lt;w:TrackMoves&gt;false&lt;/w:TrackMoves&gt;
  &lt;w:TrackFormatting/&gt;
  &lt;w:PunctuationKerning/&gt;
  &lt;w:DrawingGridHorizontalSpacing&gt;5.5 pt&lt;/w:DrawingGridHorizontalSpacing&gt;
  &lt;w:DisplayHorizontalDrawingGridEvery&gt;2&lt;/w:DisplayHorizontalDrawingGridEvery&gt;
  &lt;w:ValidateAgainstSchemas/&gt;
  &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
  &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
  &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
  &lt;w:DoNotPromoteQF/&gt;
  &lt;w:LidThemeOther&gt;EN-US&lt;/w:LidThemeOther&gt;
  &lt;w:LidThemeAsian&gt;X-NONE&lt;/w:LidThemeAsian&gt;
  &lt;w:LidThemeComplexScript&gt;X-NONE&lt;/w:LidThemeComplexScript&gt;
  &lt;w:Compatibility&gt;
   &lt;w:BreakWrappedTables/&gt;
   &lt;w:SnapToGridInCell/&gt;
   &lt;w:WrapTextWithPunct/&gt;
   &lt;w:UseAsianBreakRules/&gt;
   &lt;w:DontGrowAutofit/&gt;
   &lt;w:SplitPgBreakAndParaMark/&gt;
   &lt;w:DontVertAlignCellWithSp/&gt;
   &lt;w:DontBreakConstrainedForcedTables/&gt;
   &lt;w:DontVertAlignInTxbx/&gt;
   &lt;w:Word11KerningPairs/&gt;
   &lt;w:CachedColBalance/&gt;
  &lt;/w:Compatibility&gt;
  &lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
  &lt;m:mathPr&gt;
   &lt;m:mathFont m:val="Cambria Math"/&gt;
   &lt;m:brkBin m:val="before"/&gt;
   &lt;m:brkBinSub m:val="&amp;#45;-"/&gt;
   &lt;m:smallFrac m:val="off"/&gt;
   &lt;m:dispDef/&gt;
   &lt;m:lMargin m:val="0"/&gt;
   &lt;m:rMargin m:val="0"/&gt;
   &lt;m:defJc m:val="centerGroup"/&gt;
   &lt;m:wrapIndent m:val="1440"/&gt;
   &lt;m:intLim m:val="subSup"/&gt;
   &lt;m:naryLim m:val="undOvr"/&gt;
  &lt;/m:mathPr&gt;&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;
&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
  DefSemiHidden="true" DefQFormat="false" DefPriority="99"
  LatentStyleCount="267"&gt;
  &lt;w:LsdException Locked="false" Priority="0" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Normal"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="heading 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 7"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 8"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 9"/&gt;
  &lt;w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/&gt;
  &lt;w:LsdException Locked="false" Priority="10" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Title"/&gt;
  &lt;w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/&gt;
  &lt;w:LsdException Locked="false" Priority="11" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/&gt;
  &lt;w:LsdException Locked="false" Priority="22" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Strong"/&gt;
  &lt;w:LsdException Locked="false" Priority="20" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/&gt;
  &lt;w:LsdException Locked="false" Priority="59" SemiHidden="false"
   UnhideWhenUsed="false" Name="Table Grid"/&gt;
  &lt;w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/&gt;
  &lt;w:LsdException Locked="false" Priority="1" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/&gt;
  &lt;w:LsdException Locked="false" Priority="34" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/&gt;
  &lt;w:LsdException Locked="false" Priority="29" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Quote"/&gt;
  &lt;w:LsdException Locked="false" Priority="30" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="19" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/&gt;
  &lt;w:LsdException Locked="false" Priority="21" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/&gt;
  &lt;w:LsdException Locked="false" Priority="31" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/&gt;
  &lt;w:LsdException Locked="false" Priority="32" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/&gt;
  &lt;w:LsdException Locked="false" Priority="33" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Book Title"/&gt;
  &lt;w:LsdException Locked="false" Priority="37" Name="Bibliography"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/&gt;
 &lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;
&lt;style&gt;
&lt;!--
 /* Font Definitions */
 @font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;
	mso-font-charset:1;
	mso-generic-font-family:roman;
	mso-font-format:other;
	mso-font-pitch:variable;
	mso-font-signature:0 0 0 0 0 0;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;
	mso-font-charset:0;
	mso-generic-font-family:swiss;
	mso-font-pitch:variable;
	mso-font-signature:-520092929 1073786111 9 0 415 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-parent:"";
	margin-top:0in;
	margin-right:0in;
	margin-bottom:10.0pt;
	margin-left:0in;
	line-height:115%;
	mso-pagination:widow-orphan;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:Calibri;
	mso-fareast-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";
	mso-bidi-theme-font:minor-bidi;}
span.SpellE
	{mso-style-name:"";
	mso-spl-e:yes;}
span.GramE
	{mso-style-name:"";
	mso-gram-e:yes;}
.MsoChpDefault
	{mso-style-type:export-only;
	mso-default-props:yes;
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:Calibri;
	mso-fareast-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";
	mso-bidi-theme-font:minor-bidi;}
.MsoPapDefault
	{mso-style-type:export-only;
	margin-bottom:10.0pt;
	line-height:115%;}
@page Section1
	{size:11.0in 8.5in;
	mso-page-orientation:landscape;
	margin:1.0in 1.0in 1.0in 1.0in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;
&lt;/style&gt;
&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-priority:99;
	mso-style-qformat:yes;
	mso-style-parent:"";
	mso-padding-alt:0in 5.4pt 0in 5.4pt;
	mso-para-margin-top:0in;
	mso-para-margin-right:0in;
	mso-para-margin-bottom:10.0pt;
	mso-para-margin-left:0in;
	line-height:115%;
	mso-pagination:widow-orphan;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";
	mso-bidi-theme-font:minor-bidi;}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;o:shapedefaults v:ext="edit" spidmax="2050"/&gt;
&lt;/xml&gt;&lt;![endif]--&gt;
&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;o:shapelayout v:ext="edit"&gt;
  &lt;o:idmap v:ext="edit" data="1"/&gt;
 &lt;/o:shapelayout&gt;&lt;/xml&gt;&lt;![endif]--&gt;
&lt;/head&gt;
&lt;body lang=EN-US style='tab-interval:.5in'&gt;
&lt;div class=Section1&gt;
&lt;p class=MsoNormal&gt;
I recently downloaded a copy of a new tool from red-gage called Ant Memory Profiler.
Ant Memory Profiler is an application that allows you to do memory usage analysis
on dot net apps to uncover how your app consumes memory. 
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
During the course of trying out this tool we uncovered an interesting memory leak
in the dot net framework &lt;span class=SpellE&gt;ToolStrip&lt;/span&gt; control. Our symptom
of this was that one of our application forms was being held in memory long after
it should have been garbage collected. After a quick tour through &lt;span class=SpellE&gt;google&lt;/span&gt; I
found &lt;span class=GramE&gt;a some&lt;/span&gt; references on why this is occurring and how
to ensure things get cleaned up properly.
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
Here’s how we add the cleanup code to the close event of the form…
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Protected&lt;/span&gt; &lt;span style='color:blue'&gt;Overrides&lt;/span&gt; &lt;span style='color:blue'&gt;Sub&lt;/span&gt; OnClosed(&lt;span style='color:blue'&gt;ByVal&lt;/span&gt; e &lt;span style='color:blue'&gt;As&lt;/span&gt; System.EventArgs)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;MyBase&lt;/span&gt;.OnClosed(e)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:green'&gt;'note,
this call is still required as it cleans up one set of extra handlers&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;reportViewer.Toolbar.Visible
= &lt;span style='color:blue'&gt;False&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";color:blue;mso-no-proof:yes'&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:green'&gt;'this
is the really ugly stuff though, let our cleanup class take care of things&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Dim&lt;/span&gt; gc2 &lt;span style='color:blue'&gt;As&lt;/span&gt; &lt;span style='color:blue'&gt;New&lt;/span&gt; ToolStripGarbageCollector&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;gc2.RemoveHandlers(reportViewer)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style='font-size:10.0pt;line-height:115%;font-family:
"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;End&lt;/span&gt; &lt;span style='color:blue'&gt;Sub&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span class=GramE&gt;And &lt;span class=SpellE&gt;heres&lt;/span&gt; the meat behind the cleanup
class.&lt;/span&gt; Don’t ask what this does, it’s pretty much a copy and paste I found
from some newsgroups. 
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Public&lt;/span&gt; &lt;span style='color:blue'&gt;Class&lt;/span&gt; ToolStripGarbageCollector&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Private&lt;/span&gt; &lt;span style='color:blue'&gt;Const&lt;/span&gt; EVENTHANDLER_ON_USER_PREFERENCE_CHANGED &lt;span style='color:blue'&gt;As&lt;/span&gt; &lt;span style='color:blue'&gt;String&lt;/span&gt; = &lt;span style='color:#A31515'&gt;&amp;quot;OnUserPreferenceChanged&amp;quot;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Private&lt;/span&gt; &lt;span style='color:blue'&gt;Const&lt;/span&gt; LIST_HANDLERS &lt;span style='color:blue'&gt;As&lt;/span&gt; &lt;span style='color:blue'&gt;String&lt;/span&gt; = &lt;span style='color:#A31515'&gt;&amp;quot;_handlers&amp;quot;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Private&lt;/span&gt; &lt;span style='color:blue'&gt;Const&lt;/span&gt; ON_USER_PREFERENCE_CHANGED_EVENT &lt;span style='color:blue'&gt;As&lt;/span&gt; &lt;span style='color:blue'&gt;String&lt;/span&gt; = &lt;span style='color:#A31515'&gt;&amp;quot;OnUserPreferenceChangedEvent&amp;quot;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Private&lt;/span&gt; &lt;span style='color:blue'&gt;Const&lt;/span&gt; SYSTEM_EVENT_INVOKE_INFO &lt;span style='color:blue'&gt;As&lt;/span&gt; &lt;span style='color:blue'&gt;String&lt;/span&gt; = &lt;span style='color:#A31515'&gt;&amp;quot;SystemEventInvokeInfo&amp;quot;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Private&lt;/span&gt; &lt;span style='color:blue'&gt;Const&lt;/span&gt; TARGET_DELEGATE &lt;span style='color:blue'&gt;As&lt;/span&gt; &lt;span style='color:blue'&gt;String&lt;/span&gt; = &lt;span style='color:#A31515'&gt;&amp;quot;_delegate&amp;quot;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";color:#A31515;mso-no-proof:yes'&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";color:#A31515;mso-no-proof:yes'&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Public&lt;/span&gt; &lt;span style='color:blue'&gt;Sub&lt;/span&gt; RemoveHandlers(&lt;span style='color:blue'&gt;ByVal&lt;/span&gt; ctrl &lt;span style='color:blue'&gt;As&lt;/span&gt; Control)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;NavigateControls(ctrl)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;End&lt;/span&gt; &lt;span style='color:blue'&gt;Sub&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";color:blue;mso-no-proof:yes'&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";color:blue;mso-no-proof:yes'&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Public&lt;/span&gt; &lt;span style='color:blue'&gt;Sub&lt;/span&gt; NavigateControls(&lt;span style='color:blue'&gt;ByVal&lt;/span&gt; ctrl &lt;span style='color:blue'&gt;As&lt;/span&gt; Control)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;Console.WriteLine(ctrl.Name
&amp;amp; &lt;span style='color:#A31515'&gt;&amp;quot;-&amp;quot;&lt;/span&gt; &amp;amp; ctrl.GetType.FullName)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;If&lt;/span&gt; ctrl.GetType.FullName
= &lt;span style='color:#A31515'&gt;&amp;quot;System.Windows.Forms.ToolStripTextBox+ToolStripTextBoxControl&amp;quot;&lt;/span&gt; &lt;span style='color:blue'&gt;Then&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;RemoveUpcHandler(ctrl)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;ElseIf&lt;/span&gt; ctrl.GetType.FullName
= &lt;span style='color:#A31515'&gt;&amp;quot;System.Windows.Forms.ToolStrip&amp;quot;&lt;/span&gt; &lt;span style='color:blue'&gt;Then&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;RemoveUpcHandler(ctrl)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;End&lt;/span&gt; &lt;span style='color:blue'&gt;If&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";color:blue;mso-no-proof:yes'&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;For&lt;/span&gt; &lt;span style='color:blue'&gt;Each&lt;/span&gt; c &lt;span style='color:blue'&gt;As&lt;/span&gt; Control &lt;span style='color:blue'&gt;In&lt;/span&gt; ctrl.Controls&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;NavigateControls(c)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Next&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;End&lt;/span&gt; &lt;span style='color:blue'&gt;Sub&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";color:blue;mso-no-proof:yes'&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Private&lt;/span&gt; &lt;span style='color:blue'&gt;Sub&lt;/span&gt; RemoveUpcHandler(&lt;span style='color:blue'&gt;ByVal&lt;/span&gt; ctrl &lt;span style='color:blue'&gt;As&lt;/span&gt; Control)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:green'&gt;'create
the delegate to OnUserPreferenceChanged&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Dim&lt;/span&gt; d &lt;span style='color:blue'&gt;As&lt;/span&gt; [Delegate]
= [Delegate].CreateDelegate(&lt;span style='color:blue'&gt;GetType&lt;/span&gt;(Microsoft.Win32.UserPreferenceChangedEventHandler),
ctrl, EVENTHANDLER_ON_USER_PREFERENCE_CHANGED)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Dim&lt;/span&gt; handlers &lt;span style='color:blue'&gt;As&lt;/span&gt; &lt;span style='color:blue'&gt;Object&lt;/span&gt; = &lt;span style='color:blue'&gt;GetType&lt;/span&gt;(Microsoft.Win32.SystemEvents).GetField(&lt;span style='color:#A31515'&gt;&amp;quot;_handlers&amp;quot;&lt;/span&gt;,
Reflection.BindingFlags.NonPublic &lt;span style='color:blue'&gt;Or&lt;/span&gt; Reflection.BindingFlags.Static).GetValue(&lt;span style='color:blue'&gt;Nothing&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Dim&lt;/span&gt; upcHandler &lt;span style='color:blue'&gt;As&lt;/span&gt; &lt;span style='color:blue'&gt;Object&lt;/span&gt; = &lt;span style='color:blue'&gt;GetType&lt;/span&gt;(Microsoft.Win32.SystemEvents).GetField(ON_USER_PREFERENCE_CHANGED_EVENT,
Reflection.BindingFlags.NonPublic &lt;span style='color:blue'&gt;Or&lt;/span&gt; Reflection.BindingFlags.Static).GetValue(&lt;span style='color:blue'&gt;Nothing&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:green'&gt;'get
a SystemEventInvokeInfo type&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Dim&lt;/span&gt; systemEventInvokeInfo &lt;span style='color:blue'&gt;As&lt;/span&gt; &lt;span style='color:blue'&gt;Object&lt;/span&gt; = &lt;span style='color:blue'&gt;GetType&lt;/span&gt;(Microsoft.Win32.SystemEvents).GetNestedType(SYSTEM_EVENT_INVOKE_INFO,
Reflection.BindingFlags.NonPublic &lt;span style='color:blue'&gt;Or&lt;/span&gt; Reflection.BindingFlags.Instance)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:green'&gt;'get
the SystemEventInvokeInfo list for the UserPreferenceChangedEvent&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Dim&lt;/span&gt; upcHandlerList &lt;span style='color:blue'&gt;As&lt;/span&gt; IList
= &lt;span style='color:blue'&gt;CType&lt;/span&gt;(&lt;span style='color:blue'&gt;CType&lt;/span&gt;(handlers,
IDictionary).Item(upcHandler), IList)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:green'&gt;'initialize
a target count&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Dim&lt;/span&gt; targetCount &lt;span style='color:blue'&gt;As&lt;/span&gt; &lt;span style='color:blue'&gt;Integer&lt;/span&gt; =
0&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Dim&lt;/span&gt; i &lt;span style='color:blue'&gt;As&lt;/span&gt; &lt;span style='color:blue'&gt;Integer&lt;/span&gt; =
0&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:green'&gt;'loop&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;While&lt;/span&gt; i
&amp;lt; upcHandlerList.Count&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;systemEventInvokeInfo
= upcHandlerList(i)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:green'&gt;'get
the SystemEventInvokeInfo._delegate field&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Dim&lt;/span&gt; target &lt;span style='color:blue'&gt;As&lt;/span&gt; [Delegate]
= &lt;span style='color:blue'&gt;CType&lt;/span&gt;(systemEventInvokeInfo.GetType().GetField(TARGET_DELEGATE,
Reflection.BindingFlags.NonPublic &lt;span style='color:blue'&gt;Or&lt;/span&gt; Reflection.BindingFlags.Instance).GetValue(systemEventInvokeInfo),
[Delegate])&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:green'&gt;'eval&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;If&lt;/span&gt; target.Target &lt;span style='color:blue'&gt;Is&lt;/span&gt; d.Target &lt;span style='color:blue'&gt;Then&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:green'&gt;'increment
on positive ID&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;targetCount
+= 1&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;End&lt;/span&gt; &lt;span style='color:blue'&gt;If&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;i
+= 1&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;End&lt;/span&gt; &lt;span style='color:blue'&gt;While&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:green'&gt;'remove
the handlers&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;For&lt;/span&gt; i
= 1 &lt;span style='color:blue'&gt;To&lt;/span&gt; targetCount&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;RemoveHandler&lt;/span&gt; Microsoft.Win32.SystemEvents.UserPreferenceChanged, &lt;span style='color:blue'&gt;CType&lt;/span&gt;(d,
Microsoft.Win32.UserPreferenceChangedEventHandler)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;Next&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt;&lt;span style='mso-spacerun:yes'&gt; &lt;/span&gt;&lt;span style='color:blue'&gt;End&lt;/span&gt; &lt;span style='color:blue'&gt;Sub&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";color:blue;mso-no-proof:yes'&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'&gt;
&lt;span style='font-size:
10.0pt;font-family:"Courier New";color:blue;mso-no-proof:yes'&gt;End&lt;/span&gt;&lt;span style='font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes'&gt; &lt;span style='color:blue'&gt;Class&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=cba2da62-cb5e-4543-9dc4-6d7b358b9034" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,cba2da62-cb5e-4543-9dc4-6d7b358b9034.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=2e167928-3df0-4b4e-9f84-ab3b844956ea</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,2e167928-3df0-4b4e-9f84-ab3b844956ea.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,2e167928-3df0-4b4e-9f84-ab3b844956ea.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=2e167928-3df0-4b4e-9f84-ab3b844956ea</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've been meaning to write down something on this for a couple weeks now but have
been having a tough time formulating a nice message on this. The short version is
be very carefull doing this. I believe that somehow AppDomain's rely on something
out of the Windows User Profile, and over time in a Windows Service when you're loading
and unloading AppDomain's stuff MAY get screwed up.
</p>
        <p>
We had a scheduler app which basically used AppDomain's as an isolation mechanism
for controlling when and how each scheduled component was called and then disposed.
Code looked something like this...
</p>
        <p>
for each s as ScheduledComponent in myList<br />
Dim d as new AppDomain<br />
try<br />
dim i as IExecutableInstance = d.CreateInstance("LaunchPad")<br />
i.Execute<br />
finally<br />
AppDomain.Unload(d)<br />
end try<br />
next<br /></p>
        <p>
Over time we'd eventually get into a state where the entire scheduler service which
just cause a windows segmentation fault and shut down. No nice dot net exception or
anything. Like I said, our best guess is that something gets out of sync between the
windows profile and whatever exists in a dot net AppDomain.
</p>
        <p>
Anyway, our solution was to create a wrapper layer which basically called each scheduled
component as a process instead. This seems to be working very reliably ever since.
</p>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=2e167928-3df0-4b4e-9f84-ab3b844956ea" />
      </body>
      <title>AppDomains in Windows Services</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,2e167928-3df0-4b4e-9f84-ab3b844956ea.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2010/02/27/AppDomainsInWindowsServices.aspx</link>
      <pubDate>Sat, 27 Feb 2010 16:00:42 GMT</pubDate>
      <description>&lt;p&gt;
I've been meaning to write down something on this for a couple weeks now but have
been having a tough time formulating a nice message on this. The short version is
be very carefull doing this. I believe that somehow AppDomain's rely on something
out of the Windows User Profile, and over time in a Windows Service when you're loading
and unloading AppDomain's stuff MAY get screwed up.
&lt;/p&gt;
&lt;p&gt;
We had a scheduler app which basically used AppDomain's as an isolation mechanism
for controlling when and how each scheduled component was called and then disposed.
Code looked something like this...
&lt;/p&gt;
&lt;p&gt;
for each s as ScheduledComponent in myList&lt;br&gt;
Dim d as new AppDomain&lt;br&gt;
try&lt;br&gt;
dim i as IExecutableInstance = d.CreateInstance("LaunchPad")&lt;br&gt;
i.Execute&lt;br&gt;
finally&lt;br&gt;
AppDomain.Unload(d)&lt;br&gt;
end try&lt;br&gt;
next&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
Over time we'd eventually get into a state where the entire scheduler service which
just cause a windows segmentation fault and shut down. No nice dot net exception or
anything. Like I said, our best guess is that something gets out of sync between the
windows profile and whatever exists in a dot net AppDomain.
&lt;/p&gt;
&lt;p&gt;
Anyway, our solution was to create a wrapper layer which basically called each scheduled
component as a process instead. This seems to be working very reliably ever since.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=2e167928-3df0-4b4e-9f84-ab3b844956ea" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,2e167928-3df0-4b4e-9f84-ab3b844956ea.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=470370c8-d4fa-48a7-b4df-5298685d68a7</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,470370c8-d4fa-48a7-b4df-5298685d68a7.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,470370c8-d4fa-48a7-b4df-5298685d68a7.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=470370c8-d4fa-48a7-b4df-5298685d68a7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We were having some problems on our development machines at work as soon as we upgraded
to Windows 7 and IE8. The problem first manifested itself as a javascript "client
out of memory" error while using Outlook Web Access (OWA) but it seemed like randomly
we'd have javascript errors while navigating webpages.
</p>
        <p>
Our workaround was to switch over to Google Chrome but then you start finding all
the things that don't work with that so we just wanted to get this figured out.
</p>
        <p>
We ended up working microsoft support on this one and long story short, it looks like
one of our development tools is overwriting one of the IE classes. They had us re-register
a couple classes and now it's working awesome. Here's the registery changes required...
</p>
        <p>
[HKEY_CLASSES_ROOT\Interface\{79EAC9C5-BAF9-11CE-8C82-00AA004BA90B}]<br />
@="IHlinkFrame"<br /><br />
[HKEY_CLASSES_ROOT\Interface\{79EAC9C5-BAF9-11CE-8C82-00AA004BA90B}\NumMethods]<br />
@="8"<br /><br />
[HKEY_CLASSES_ROOT\Interface\{79EAC9C5-BAF9-11CE-8C82-00AA004BA90B}\ProxyStubClsid32]<br />
@="{A4A1A128-768F-41E0-BF75-E4FDDD701CBA}"<br /></p>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=470370c8-d4fa-48a7-b4df-5298685d68a7" />
      </body>
      <title>Windows 7 / Internet Explorer 8 Javascript</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,470370c8-d4fa-48a7-b4df-5298685d68a7.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2010/01/26/Windows7InternetExplorer8Javascript.aspx</link>
      <pubDate>Tue, 26 Jan 2010 15:39:45 GMT</pubDate>
      <description>&lt;p&gt;
We were having some problems on our development machines at work as soon as we upgraded
to Windows 7 and IE8. The problem first manifested itself as a javascript "client
out of memory" error while using Outlook Web Access (OWA) but it seemed like randomly
we'd have javascript errors while navigating webpages.
&lt;/p&gt;
&lt;p&gt;
Our workaround was to switch over to Google Chrome but then you start finding all
the things that don't work with that so we just wanted to get this figured out.
&lt;/p&gt;
&lt;p&gt;
We ended up working microsoft support on this one and long story short, it looks like
one of our development tools is overwriting one of the IE classes. They had us re-register
a couple classes and now it's working awesome. Here's the registery changes required...
&lt;/p&gt;
&lt;p&gt;
[HKEY_CLASSES_ROOT\Interface\{79EAC9C5-BAF9-11CE-8C82-00AA004BA90B}]&lt;br&gt;
@="IHlinkFrame"&lt;br&gt;
&lt;br&gt;
[HKEY_CLASSES_ROOT\Interface\{79EAC9C5-BAF9-11CE-8C82-00AA004BA90B}\NumMethods]&lt;br&gt;
@="8"&lt;br&gt;
&lt;br&gt;
[HKEY_CLASSES_ROOT\Interface\{79EAC9C5-BAF9-11CE-8C82-00AA004BA90B}\ProxyStubClsid32]&lt;br&gt;
@="{A4A1A128-768F-41E0-BF75-E4FDDD701CBA}"&lt;br&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=470370c8-d4fa-48a7-b4df-5298685d68a7" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,470370c8-d4fa-48a7-b4df-5298685d68a7.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=17ceec3d-04bf-4a83-9505-64242c05ae9b</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,17ceec3d-04bf-4a83-9505-64242c05ae9b.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,17ceec3d-04bf-4a83-9505-64242c05ae9b.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=17ceec3d-04bf-4a83-9505-64242c05ae9b</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We've had some problems with the Binding Source component in our Windows Forms development
and I wanted to jot down a note on here in case anyone else comes across this.
</p>
        <p>
The problem we were having was an IDE runtime error which looks like a NullReferenceException,
the specific message says "Object reference not set to an instance of an object".
</p>
        <p>
Apparently this has something to do with the .datasource files that are auto-generated
by visual studio for holding "default" values. You can remove these from the My Project
folder and then the error goes away. Not sure why these are even required since you
can still build without them.
</p>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=17ceec3d-04bf-4a83-9505-64242c05ae9b" />
      </body>
      <title>BindingSource "Object reference not set to an instance of an object"</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,17ceec3d-04bf-4a83-9505-64242c05ae9b.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2009/08/14/BindingSourceObjectReferenceNotSetToAnInstanceOfAnObject.aspx</link>
      <pubDate>Fri, 14 Aug 2009 15:35:42 GMT</pubDate>
      <description>&lt;p&gt;
We've had some problems with the Binding Source component in our Windows Forms development
and I wanted to jot down a note on here in case anyone else comes across this.
&lt;/p&gt;
&lt;p&gt;
The problem we were having was an IDE runtime error which looks like a NullReferenceException,
the specific message says "Object reference not set to an instance of an object".
&lt;/p&gt;
&lt;p&gt;
Apparently this has something to do with the .datasource files that are auto-generated
by visual studio for holding "default" values. You can remove these from the My Project
folder and then the error goes away. Not sure why these are even required since you
can still build without them.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=17ceec3d-04bf-4a83-9505-64242c05ae9b" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,17ceec3d-04bf-4a83-9505-64242c05ae9b.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=64883720-4895-4c43-a99e-66e98b0e2e3a</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,64883720-4895-4c43-a99e-66e98b0e2e3a.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,64883720-4895-4c43-a99e-66e98b0e2e3a.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=64883720-4895-4c43-a99e-66e98b0e2e3a</wfw:commentRss>
      <title>Active Reports Viewer IndexOutOfRangeException</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,64883720-4895-4c43-a99e-66e98b0e2e3a.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2009/05/07/ActiveReportsViewerIndexOutOfRangeException.aspx</link>
      <pubDate>Thu, 07 May 2009 02:10:29 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;span lang=EN-US style="mso-ansi-language: EN-US"&gt;&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;We’ve
been fighting an intermittent error with our report viewer for the last couple years
that’s been just terrible to track down and I think we finally made some progress
today. We use a reporting tool called Data Dynamics Active Reports to generate our
Screen and Paper reports. Their tool is basically a set of Dot Net assemblies that
allow you to design and code a component called an Active Report.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font color=#000000&gt;&lt;span lang=EN-US style="mso-ansi-language: EN-US"&gt;&lt;font face=Calibri size=3&gt;At
runtime, you execute this Active Report and then pass it into another component called
an Active Report Viewer for displaying to the user. We found occasionally our users
would get stuck in an infinite loop of error messages while displaying a report. Exceptions
would pop up looking like this…&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;/span&gt;&lt;span lang=EN-US style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Segoe UI','sans-serif'; mso-ansi-language: EN-US"&gt;(IndexOutOfRangeException)
Index was outside the bounds of the array.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal"&gt;
&lt;span lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 'Segoe UI','sans-serif'; mso-ansi-language: EN-US"&gt;
&lt;o:p&gt;
&lt;font color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/span&gt;&lt;span lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 'Segoe UI','sans-serif'; mso-ansi-language: EN-US"&gt;&lt;font color=#000000&gt;&amp;nbsp;
at DataDynamics.ActiveReports.Viewer.-0011.-3cbd()&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal"&gt;
&lt;span lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 'Segoe UI','sans-serif'; mso-ansi-language: EN-US"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;
at DataDynamics.ActiveReports.Viewer.-dabf.-31a1()&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;span lang=EN-US style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Segoe UI','sans-serif'; mso-ansi-language: EN-US"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;
at DataDynamics.ActiveReports.Viewer.-b212.-afcd()&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;span lang=EN-US style="mso-bidi-font-family: 'Segoe UI'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;We
could never recreate this on demand, but probably five times a month we would get
a hundred error messages coming in from a client site like this. Eventually the client
would give up pressing “OK” on our error handler, and kill the process.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;span lang=EN-US style="mso-bidi-font-family: 'Segoe UI'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;When
we’ve tried to troubleshoot this in the past it’s been extremely difficult because
Data Dynamics obfuscates their code so it can’t be decompiled. Obfuscation basically
takes design-time code, and mixes it up so that it’s unreadable, hence the funky function
names above. Unfortunately this gives you no sense of what’s actually happening in
their app.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;span lang=EN-US style="mso-bidi-font-family: 'Segoe UI'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;font face=Calibri color=#000000 size=3&gt;A
little bit of digging on their support forums today did find a link to a similar issue
by another user - &lt;/font&gt;&lt;a href="http://www.datadynamics.com/forums/85506/ShowPost.aspx"&gt;&lt;font face=Calibri size=3&gt;http://www.datadynamics.com/forums/85506/ShowPost.aspx&lt;/font&gt;&lt;/a&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;span lang=EN-US style="mso-bidi-font-family: 'Segoe UI'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;Basically
what they’d found was that in a Terminal Services environment, their users would click
their “Print” button multiple times – the old adage, keep pressing the button until
something happens. What this causes in some instances is for the second “click” to
get handled by the newly created Active Report Viewer, even though it’s just in the
process of being displayed. Now, if the Viewer is in a funny spot, it can try and
interact with this click event while loading the document – that’s what seems to cause
the issue.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;span lang=EN-US style="mso-bidi-font-family: 'Segoe UI'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;Once
we had a sense of what was causing the issue, it’s pretty simple to disable the ReportViewer
until the report has generated its first page and sure enough this causes the issue
to go away.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=64883720-4895-4c43-a99e-66e98b0e2e3a" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,64883720-4895-4c43-a99e-66e98b0e2e3a.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=4aeafaea-cf19-45b1-88fa-e18e79c39cbf</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,4aeafaea-cf19-45b1-88fa-e18e79c39cbf.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,4aeafaea-cf19-45b1-88fa-e18e79c39cbf.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=4aeafaea-cf19-45b1-88fa-e18e79c39cbf</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt">
          <font face="Calibri" color="#000000" size="3">One area of concern that I come up against
quite often is the issue of source code version control. At its most basic layer this
is nothing more than being able to control what a version of your software consists
of... version A versus version B, that sort of thing. This model works great and is
well documented on smaller isolated applications but tends to blur a little when working
with larger systems. Specifically we’ve had issues managing system dependencies, as
well as change requirements on a larger application consisting of about roughly 50
assemblies. I’ll spend just a few minutes here putting pen to paper on how we’ve structured
our development tree to accommodate this.</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt">
          <font face="Calibri" color="#000000" size="3">We’ll start at a pretty simple level;
each major release is placed in a named folder based on the version name. Our first
branch within that folder is named Major.Minor.Zero, Major and Minor are related to
the version name while the Zero indicated this is the opening development branch.
Here’s how that looks when we start a new major release... our friendly version name
is Jupiler and the Major.Minor associated with this is 5.1.</font>
        </p>
        <p>
        </p>
        <p>
          <img src="http://www.bradleysblog.net/blog/content/binary/SVC1.JPG" border="0" />
        </p>
        <p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt">
          <font face="Calibri" color="#000000" size="3">Notice that within the 5.1.0 folder
we have a number of sub-folders. These are what we call modules and basically relate
to a VS.Net solution; each one consists of roughly 5-6 projects and can be thought
of as a sub-system. These sub-systems collaborate to provide our applications functionality. </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt">
          <font size="3">
            <font color="#000000">
              <font face="Calibri">Now, when we release our
major version, Jupiler, we’ll typically LOCK the 5.1.0 folder so that no further changes
can be made. This code is set in stone and we want to force all new changes to be
done in an isolated environment until they’re tested and ready to go. Invariable though,
something critical comes up during rollout and we need to make code changes to address
those concerns. When this situation arises we BRANCH into a new folder called Major.Minor.One.
This code folder consists of all the new development changes required to add what
we call a Service Pack to the release. Here’s how this looks. <span style="mso-spacerun: yes"> </span></font>
            </font>
          </font>
        </p>
        <p>
          <img src="http://www.bradleysblog.net/blog/content/binary/SVC2.JPG" border="0" />
        </p>
        <p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt">
          <font face="Calibri" color="#000000" size="3">One interesting aspect of this layout
is that we only branch the modules that require changes. These Service Pack’s generally
don’t require a lot of wholesale change; they`re usually small isolated bugs/features
which can be addressed in a single module. You can see in the above diagram that our
5.1.1 only has changes for Accounting, all the other modules are identical to how
they were developed in 5.1.0. This gives us a few key benefits.</font>
        </p>
        <p class="MsoListParagraphCxSpFirst" style="MARGIN: 0cm 0cm 0pt 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1">
          <font color="#000000">
            <span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin">
              <span style="mso-list: Ignore">
                <font face="Calibri" size="3">1.</font>
                <span style="FONT: 7pt 'Times New Roman'">       </span>
              </span>
            </span>
            <font face="Calibri" size="3">It
limits the amount of open source code.</font>
          </font>
        </p>
        <p class="MsoListParagraphCxSpMiddle" style="MARGIN: 0cm 0cm 0pt 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1">
          <font color="#000000">
            <span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin">
              <span style="mso-list: Ignore">
                <font face="Calibri" size="3">2.</font>
                <span style="FONT: 7pt 'Times New Roman'">       </span>
              </span>
            </span>
            <font face="Calibri" size="3">It
makes it easier to identify what code is actively being changed for a service pack.</font>
          </font>
        </p>
        <p class="MsoListParagraphCxSpLast" style="MARGIN: 0cm 0cm 10pt 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1">
          <font color="#000000">
            <span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin">
              <span style="mso-list: Ignore">
                <font face="Calibri" size="3">3.</font>
                <span style="FONT: 7pt 'Times New Roman'">       </span>
              </span>
            </span>
            <font face="Calibri" size="3">It
leaves the original branch open so that it can be reviewed/modified for OTHER unanticipated
issues.</font>
          </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt">
          <font face="Calibri" color="#000000" size="3">Final rollout of the new changes is
done by releasing 5.1.1 of Accounting with all the previous versions of the other
modules.</font>
        </p>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=4aeafaea-cf19-45b1-88fa-e18e79c39cbf" />
      </body>
      <title>Source Code Version Control</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,4aeafaea-cf19-45b1-88fa-e18e79c39cbf.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2009/03/24/SourceCodeVersionControl.aspx</link>
      <pubDate>Tue, 24 Mar 2009 05:53:54 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;One area of concern that I come up against
quite often is the issue of source code version control. At its most basic layer this
is nothing more than being able to control what a version of your software consists
of... version A versus version B, that sort of thing. This model works great and is
well documented on smaller isolated applications but tends to blur a little when working
with larger systems. Specifically we’ve had issues managing system dependencies, as
well as change requirements on a larger application consisting of about roughly 50
assemblies. I’ll spend just a few minutes here putting pen to paper on how we’ve structured
our development tree to accommodate this.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;We’ll start at a pretty simple level; each
major release is placed in a named folder based on the version name. Our first branch
within that folder is named Major.Minor.Zero, Major and Minor are related to the version
name while the Zero indicated this is the opening development branch. Here’s how that
looks when we start a new major release... our friendly version name is Jupiler and
the&amp;nbsp;Major.Minor associated with this is 5.1.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/SVC1.JPG" border=0&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Notice that within the 5.1.0 folder we have
a number of sub-folders. These are what we call modules and basically relate to a
VS.Net solution; each one consists of roughly 5-6 projects and can be thought of as
a sub-system. These sub-systems collaborate to provide our applications functionality. &lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;Now, when we release our major
version, Jupiler, we’ll typically LOCK the 5.1.0 folder so that no further changes
can be made. This code is set in stone and we want to force all new changes to be
done in an isolated environment until they’re tested and ready to go. Invariable though,
something critical comes up during rollout and we need to make code changes to address
those concerns. When this situation arises we BRANCH into a new folder called Major.Minor.One.
This code folder consists of all the new development changes required to add what
we call a Service Pack to the release. Here’s how this looks. &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/SVC2.JPG" border=0&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;One interesting aspect of this layout is that
we only branch the modules that require changes. These Service Pack’s generally don’t
require a lot of wholesale change; they`re usually small isolated bugs/features which
can be addressed in a single module. You can see in the above diagram that our 5.1.1
only has changes for Accounting, all the other modules are identical to how they were
developed in 5.1.0. This gives us a few key benefits.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpFirst style="MARGIN: 0cm 0cm 0pt 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1"&gt;
&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font face=Calibri size=3&gt;1.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;It
limits the amount of open source code.&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpMiddle style="MARGIN: 0cm 0cm 0pt 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1"&gt;
&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font face=Calibri size=3&gt;2.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;It
makes it easier to identify what code is actively being changed for a service pack.&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpLast style="MARGIN: 0cm 0cm 10pt 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1"&gt;
&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font face=Calibri size=3&gt;3.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;It
leaves the original branch open so that it can be reviewed/modified for OTHER unanticipated
issues.&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Final rollout of the new changes is done by
releasing 5.1.1 of Accounting with all the previous versions of the other modules.&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=4aeafaea-cf19-45b1-88fa-e18e79c39cbf" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,4aeafaea-cf19-45b1-88fa-e18e79c39cbf.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=9b6bb97b-15d8-4959-a658-a7b5b3f8b88b</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,9b6bb97b-15d8-4959-a658-a7b5b3f8b88b.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,9b6bb97b-15d8-4959-a658-a7b5b3f8b88b.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=9b6bb97b-15d8-4959-a658-a7b5b3f8b88b</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Not that this is necessarily a good idea. But after way too much time googling this,
I think I'll clear up the fact that it IS possible call the Microsoft RDP client with
a username and password parameter.
</p>
        <p>
Now, everyone out there will say, yeah - we know that. You key in the username and
password and if you check off the "remember credentials" checkbox it will store that
data.
</p>
        <p>
Well the trick is that this data is stored in a place that's not easily accessed -Windows
Stored UserNames and Passwords. This area is basically a secured area of windows where
passwords are stored for remote connections. You can access this by going Control
Panel\User Accounts\Manager your network passwords. Here's a screen snap.
</p>
        <p>
          <img src="http://www.bradleysblog.net/blog/content/binary/blog-stored%20passwords.JPG" border="0" />
        </p>
        <p>
Our management infrastructure tracks this username and password in a seperate secured
database, and then when we call MSTSC.exe from our software we want to pass this information.
Now, a little more information on how you can pass parameters to MSTSC is in order.
When you call MSTSC you can pass as a parameter a .RDP file which contains information
about how you want to connect to the remote computer. Same idea as every other document
type in Windows, a .RDP file is associated with MSTSC and is used to contain information
for that application. Fortunately the .RDP files are basically key value pairs. Check
it out...
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <font color="#0000ff">screen
mode id:i:1<br />
desktopwidth:i:1024<br />
desktopheight:i:768<br />
session bpp:i:16<br />
winposstr:s:0,1,526,61,1566,865<br />
full address:s:SomeIpAddress<br />
compression:i:1<br />
keyboardhook:i:2<br />
audiomode:i:0<br />
redirectdrives:i:0<br />
redirectprinters:i:1<br />
redirectcomports:i:0<br />
redirectsmartcards:i:1<br />
displayconnectionbar:i:0<br />
autoreconnection enabled:i:1<br />
alternate <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">shell</span>:s:<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">shell</span> working
directory:s:<br />
disable wallpaper:i:0<br />
disable full window drag:i:1<br />
disable menu anims:i:1<br />
disable themes:i:0<br />
disable cursor setting:i:0<br />
bitmapcachepersistenable:i:1<br />
allow desktop composition:i:1<br />
allow font smoothing:i:0<br />
redirectclipboard:i:1<br />
redirectposdevices:i:0<br />
authentication level:i:2<br />
prompt <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">for</span> credentials:i:0<br />
negotiate security layer:i:1<br />
remoteapplicationmode:i:0<br />
gatewayhostname:s:<br />
gatewayusagemethod:i:4<br />
gatewaycredentialssource:i:4<br />
gatewayprofileusagemethod:i:0<br />
promptcredentialonce:i:1<br />
drivestoredirect:s:</font>
          </span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <font face="Verdana" size="2">The
imporant pieces here is the "full address" line... this points to the server we're
connecting to.</font>
          </span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <font face="Verdana" size="2">Well...
it turns out you can also pass parameters for domain, username, and password. You
just need to add them to the bottom of your .rdp file like this</font>
          </span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <font color="#0000ff">domain:s:MyDomain<br />
username:s:MyUserName<br />
password 51:b:MyPassword</font>
          </span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <font face="Verdana" size="2">But
wait a second, saving a password in plain text in a .rdp file sounds like just about
the worst security hole you could use! And you're right - you can't actually pass
the password parameter as straight text. It needs to be encrypted binary. </font>
          </span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <font face="Verdana" size="2">(As
an aside, that's what the second part of these key/value pairs is... the s, or b,
or i character. That indicates whether the data is String, Binary or Integer).</font>
          </span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <font face="Verdana" size="2">Well
it turns out that taking a straight text password and encrypting it ain't too bad.
I'm not going to take credit for this code but the following vb dot net code uses
the windows api to do just that.</font>
          </span>
        </p>
        <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Imports</span> System<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Imports</span> System.Text<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Imports</span> System.Runtime.InteropServices<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Imports</span> System.ComponentModel<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Imports</span> Microsoft.VisualBasic<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Class</span> DPAPI<br />
&lt;DllImport(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Crypt32.dll"</span>,
SetLastError:=<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">True</span>,
CharSet:=System.Runtime.InteropServices.CharSet.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Auto</span>)&gt; <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Shared</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span> CryptProtectData(
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByRef</span> pPlainText <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> DATA_BLOB,
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> szDescription <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span>,
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByRef</span> pEntropy <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> DATA_BLOB,
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> pReserved <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> IntPtr,
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByRef</span> pPrompt <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> CRYPTPROTECT_PROMPTSTRUCT,
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> dwFlags <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Integer</span>,
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByRef</span> pCipherText <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> DATA_BLOB
_<br />
) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Boolean</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span><br /><br />
&lt;DllImport(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Crypt32.dll"</span>,
SetLastError:=<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">True</span>,
CharSet:=System.Runtime.InteropServices.CharSet.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Auto</span>)&gt;
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Shared</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span> CryptUnprotectData(
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByRef</span> pCipherText <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> DATA_BLOB,
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByRef</span> pszDescription <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span>,
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByRef</span> pEntropy <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> DATA_BLOB,
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> pReserved <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> IntPtr,
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByRef</span> pPrompt <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> CRYPTPROTECT_PROMPTSTRUCT,
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> dwFlags <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Integer</span>,
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByRef</span> pPlainText <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> DATA_BLOB
_<br />
) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Boolean</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span><br /><br />
&lt;StructLayout(LayoutKind.Sequential, CharSet:=CharSet.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Unicode</span>)&gt;
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Friend</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Structure</span> DATA_BLOB<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span> cbData <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Integer</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span> pbData <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> IntPtr<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Structure</span><br /><br />
&lt;StructLayout(LayoutKind.Sequential, CharSet:=CharSet.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Unicode</span>)&gt;
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Friend</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Structure</span> CRYPTPROTECT_PROMPTSTRUCT<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span> cbSize <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Integer</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span> dwPromptFlags <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Integer</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span> hwndApp <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> IntPtr<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span> szPrompt <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Structure</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Const</span> CRYPTPROTECT_UI_FORBIDDEN <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Integer</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 1<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Const</span> CRYPTPROTECT_LOCAL_MACHINE <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Integer</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 4<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Shared</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> InitPrompt
_<br />
( _<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByRef</span> ps <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> CRYPTPROTECT_PROMPTSTRUCT
_<br />
)<br />
ps.cbSize <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Marshal.SizeOf(<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">GetType</span>(CRYPTPROTECT_PROMPTSTRUCT))<br />
ps.dwPromptFlags <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 0<br />
ps.hwndApp <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> IntPtr.Zero<br />
ps.szPrompt <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Shared</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> InitBLOB
_<br />
( _<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> data <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Byte</span>(),
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByRef</span> blob <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> DATA_BLOB
_<br />
)<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
Use empty array for null parameter.</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span> data <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Is</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Then</span><br />
data <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Byte</span>(0)
{}<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
Allocate memory for the BLOB data.</span><br />
blob.pbData <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Marshal.AllocHGlobal(data.Length)<br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
Make sure that memory allocation was successful.</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span> blob.pbData.Equals(IntPtr.Zero) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Then</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Throw</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> Exception(
_<br /><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Unable
to allocate data buffer for BLOB structure."</span>)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
Specify number of bytes in the BLOB.</span><br />
blob.cbData <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> data.Length<br />
Marshal.Copy(data, 0, blob.pbData, data.Length)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Enum</span> KeyType<br />
UserKey <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 1<br />
MachineKey<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Enum</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Shared</span> defaultKeyType <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> KeyType <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> KeyType.UserKey<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Shared</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span> Encrypt
_<br />
( _<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> keyType <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> KeyType,
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> plainText <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span>,
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> entropy <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span>,
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">description</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span> _<br />
) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span> plainText <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Is</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Then</span><br />
plainText <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span>.Empty<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span> entropy <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Is</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Then</span><br />
entropy <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span>.Empty<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> result <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Byte</span>()<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> encrypted <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">""</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> i <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Integer</span><br />
result <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Encrypt(keyType,
_<br />
Encoding.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Unicode</span>.GetBytes(plainText),
_<br />
Encoding.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Unicode</span>.GetBytes(entropy),
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">description</span>)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">For</span> i <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 0 <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">To</span> result.Length <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">-</span> 1<br />
encrypted <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> encrypted
&amp; Convert.ToString(result(i), 16).PadLeft(2, <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"0"</span>).ToUpper()<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Next</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Return</span> encrypted.ToString()<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Shared</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span> Encrypt
_<br />
( _<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> keyType <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> KeyType,
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> plainTextBytes <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Byte</span>(),
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> entropyBytes <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Byte</span>(),
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">description</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span> _<br />
) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Byte</span>()<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span> plainTextBytes <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Is</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Then</span><br />
plainTextBytes <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Byte</span>(0)
{}<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span> entropyBytes <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Is</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Then</span><br />
entropyBytes <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Byte</span>(0)
{}<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">description</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Is</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Then</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">description</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span>.Empty<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> plainTextBlob <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> DATA_BLOB <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> DATA_BLOB<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> cipherTextBlob <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> DATA_BLOB <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> DATA_BLOB<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> entropyBlob <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> DATA_BLOB <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> DATA_BLOB<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> prompt <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> _<br />
CRYPTPROTECT_PROMPTSTRUCT <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> CRYPTPROTECT_PROMPTSTRUCT<br />
InitPrompt(prompt)<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><br />
InitBLOB(plainTextBytes, plainTextBlob)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Catch</span> ex <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> Exception<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Throw</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> Exception(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Cannot
initialize plaintext BLOB."</span>, ex)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><br />
InitBLOB(entropyBytes, entropyBlob)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Catch</span> ex <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> Exception<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Throw</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> Exception(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Cannot
initialize entropy BLOB."</span>, ex)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> flags <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Integer</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> CRYPTPROTECT_UI_FORBIDDEN<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span> keyType <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> keyType.MachineKey <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Then</span><br />
flags <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> flags <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> (CRYPTPROTECT_LOCAL_MACHINE)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> success <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Boolean</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> CryptProtectData(
_<br />
plainTextBlob, _<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">description</span>,
_<br />
entropyBlob, _<br />
IntPtr.Zero, _<br />
prompt, _<br />
flags, _<br />
cipherTextBlob)<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Not</span> success <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Then</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> errCode <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Integer</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Marshal.GetLastWin32Error()<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Throw</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> Exception(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"CryptProtectData
failed."</span>, _<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> Win32Exception(errCode))<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> cipherTextBytes(cipherTextBlob.cbData) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Byte</span><br /><br />
Marshal.Copy(cipherTextBlob.pbData, cipherTextBytes, 0, _<br />
cipherTextBlob.cbData)<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Return</span> cipherTextBytes<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Catch</span> ex <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> Exception<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Throw</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> Exception(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"DPAPI
was unable to encrypt data."</span>, ex)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Finally</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Not</span> (plainTextBlob.pbData.Equals(IntPtr.Zero)) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Then</span><br />
Marshal.FreeHGlobal(plainTextBlob.pbData)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Not</span> (cipherTextBlob.pbData.Equals(IntPtr.Zero)) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Then</span><br />
Marshal.FreeHGlobal(cipherTextBlob.pbData)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Not</span> (entropyBlob.pbData.Equals(IntPtr.Zero)) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Then</span><br />
Marshal.FreeHGlobal(entropyBlob.pbData)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Class</span></span>
          </p>
          <br />
          <font face="Verdana" color="#000000" size="2">Then in our .RDP file generator we just
call out to our dot net encryptor like this.</font>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <font size="2">
                <p>
                  <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DPAPI.Encrypt(DPAPI.KeyType.MachineKey,
"MyPassword", <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span>, <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"psw"</span>)</span>
                </p>
                <p>
                  <font face="Verdana" color="#000000">Now, this is worth stressing again that exposing
passwords for RDP clients can be a very dangerous idea. Someone can grab ahold of
those and cause all sorts of havoc so your management of these security tools needs
to be very well understood. Storage, access, and management of this data is one of
the most critical components of your security strategy and anytime your exposing this
information you need to be aware of the ramifications of that action.</font>
                </p>
              </font>
            </span>
          </span>
        </span>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=9b6bb97b-15d8-4959-a658-a7b5b3f8b88b" />
      </body>
      <title>MSTSC Username/Password</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,9b6bb97b-15d8-4959-a658-a7b5b3f8b88b.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2009/03/06/MSTSCUsernamePassword.aspx</link>
      <pubDate>Fri, 06 Mar 2009 21:50:17 GMT</pubDate>
      <description>&lt;p&gt;
Not that this is necessarily a good idea. But after way too much time googling this,
I think I'll clear up the fact that it IS possible call the Microsoft RDP client with
a username and password parameter.
&lt;/p&gt;
&lt;p&gt;
Now, everyone out there will say, yeah - we know that. You key in the username and
password and if you check off the "remember credentials" checkbox it will store that
data.
&lt;/p&gt;
&lt;p&gt;
Well the trick is that this data is stored in a place that's not easily accessed -Windows
Stored UserNames and Passwords. This area is basically a secured area of windows where
passwords are stored for remote connections. You can access this by going Control
Panel\User Accounts\Manager your network passwords. Here's a screen snap.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/blog-stored%20passwords.JPG" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Our management infrastructure tracks this username and password in a seperate secured
database, and then when we call MSTSC.exe from our software we want to pass this information.
Now, a little more information on how you can pass parameters to MSTSC is in order.
When you call MSTSC you can pass as a parameter a .RDP file which contains information
about how you want to connect to the remote computer. Same idea as every other document
type in Windows, a .RDP file is associated with MSTSC and is used to contain information
for that application. Fortunately the .RDP files are basically key value pairs. Check
it out...
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font color=#0000ff&gt;screen
mode id:i:1&lt;br&gt;
desktopwidth:i:1024&lt;br&gt;
desktopheight:i:768&lt;br&gt;
session bpp:i:16&lt;br&gt;
winposstr:s:0,1,526,61,1566,865&lt;br&gt;
full address:s:SomeIpAddress&lt;br&gt;
compression:i:1&lt;br&gt;
keyboardhook:i:2&lt;br&gt;
audiomode:i:0&lt;br&gt;
redirectdrives:i:0&lt;br&gt;
redirectprinters:i:1&lt;br&gt;
redirectcomports:i:0&lt;br&gt;
redirectsmartcards:i:1&lt;br&gt;
displayconnectionbar:i:0&lt;br&gt;
autoreconnection enabled:i:1&lt;br&gt;
alternate &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;shell&lt;/span&gt;:s:&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;shell&lt;/span&gt; working
directory:s:&lt;br&gt;
disable wallpaper:i:0&lt;br&gt;
disable full window drag:i:1&lt;br&gt;
disable menu anims:i:1&lt;br&gt;
disable themes:i:0&lt;br&gt;
disable cursor setting:i:0&lt;br&gt;
bitmapcachepersistenable:i:1&lt;br&gt;
allow desktop composition:i:1&lt;br&gt;
allow font smoothing:i:0&lt;br&gt;
redirectclipboard:i:1&lt;br&gt;
redirectposdevices:i:0&lt;br&gt;
authentication level:i:2&lt;br&gt;
prompt &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;for&lt;/span&gt; credentials:i:0&lt;br&gt;
negotiate security layer:i:1&lt;br&gt;
remoteapplicationmode:i:0&lt;br&gt;
gatewayhostname:s:&lt;br&gt;
gatewayusagemethod:i:4&lt;br&gt;
gatewaycredentialssource:i:4&lt;br&gt;
gatewayprofileusagemethod:i:0&lt;br&gt;
promptcredentialonce:i:1&lt;br&gt;
drivestoredirect:s:&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt;The
imporant pieces here is the "full address" line... this points to the server we're
connecting to.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt;Well...
it turns out you can also pass parameters for domain, username, and password. You
just need to add them to the bottom of your .rdp file like this&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font color=#0000ff&gt;domain:s:MyDomain&lt;br&gt;
username:s:MyUserName&lt;br&gt;
password 51:b:MyPassword&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt;But
wait a second, saving a password in plain text in a .rdp file sounds like just about
the worst security hole you could use! And you're right - you can't actually pass
the password parameter as straight text. It needs to be encrypted binary. &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt;(As
an aside, that's what the second part of these key/value pairs is... the s, or b,
or i character. That indicates whether the data is String, Binary or Integer).&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt;Well
it turns out that taking a straight text password and encrypting it ain't too bad.
I'm not going to take credit for this code but the following vb dot net code uses
the windows api to do just that.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Imports&lt;/span&gt; System&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Imports&lt;/span&gt; System.Text&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Imports&lt;/span&gt; System.Runtime.InteropServices&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Imports&lt;/span&gt; System.ComponentModel&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Imports&lt;/span&gt; Microsoft.VisualBasic&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Class&lt;/span&gt; DPAPI&lt;br&gt;
&amp;lt;DllImport(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Crypt32.dll"&lt;/span&gt;,
SetLastError:=&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;True&lt;/span&gt;,
CharSet:=System.Runtime.InteropServices.CharSet.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Auto&lt;/span&gt;)&amp;gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Shared&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt; CryptProtectData(
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByRef&lt;/span&gt; pPlainText &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; DATA_BLOB,
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; szDescription &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt;,
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByRef&lt;/span&gt; pEntropy &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; DATA_BLOB,
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; pReserved &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; IntPtr,
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByRef&lt;/span&gt; pPrompt &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; CRYPTPROTECT_PROMPTSTRUCT,
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; dwFlags &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Integer&lt;/span&gt;,
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByRef&lt;/span&gt; pCipherText &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; DATA_BLOB
_&lt;br&gt;
) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Boolean&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&amp;lt;DllImport(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Crypt32.dll"&lt;/span&gt;,
SetLastError:=&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;True&lt;/span&gt;,
CharSet:=System.Runtime.InteropServices.CharSet.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Auto&lt;/span&gt;)&amp;gt;
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Shared&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt; CryptUnprotectData(
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByRef&lt;/span&gt; pCipherText &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; DATA_BLOB,
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByRef&lt;/span&gt; pszDescription &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt;,
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByRef&lt;/span&gt; pEntropy &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; DATA_BLOB,
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; pReserved &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; IntPtr,
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByRef&lt;/span&gt; pPrompt &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; CRYPTPROTECT_PROMPTSTRUCT,
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; dwFlags &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Integer&lt;/span&gt;,
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByRef&lt;/span&gt; pPlainText &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; DATA_BLOB
_&lt;br&gt;
) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Boolean&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&amp;lt;StructLayout(LayoutKind.Sequential, CharSet:=CharSet.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Unicode&lt;/span&gt;)&amp;gt;
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Friend&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Structure&lt;/span&gt; DATA_BLOB&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; cbData &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Integer&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; pbData &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; IntPtr&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Structure&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&amp;lt;StructLayout(LayoutKind.Sequential, CharSet:=CharSet.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Unicode&lt;/span&gt;)&amp;gt;
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Friend&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Structure&lt;/span&gt; CRYPTPROTECT_PROMPTSTRUCT&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; cbSize &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Integer&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; dwPromptFlags &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Integer&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; hwndApp &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; IntPtr&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; szPrompt &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Structure&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Const&lt;/span&gt; CRYPTPROTECT_UI_FORBIDDEN &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Integer&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 1&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Const&lt;/span&gt; CRYPTPROTECT_LOCAL_MACHINE &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Integer&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 4&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Shared&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; InitPrompt
_&lt;br&gt;
( _&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByRef&lt;/span&gt; ps &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; CRYPTPROTECT_PROMPTSTRUCT
_&lt;br&gt;
)&lt;br&gt;
ps.cbSize &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Marshal.SizeOf(&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;GetType&lt;/span&gt;(CRYPTPROTECT_PROMPTSTRUCT))&lt;br&gt;
ps.dwPromptFlags &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 0&lt;br&gt;
ps.hwndApp &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; IntPtr.Zero&lt;br&gt;
ps.szPrompt &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Shared&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; InitBLOB
_&lt;br&gt;
( _&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; data &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Byte&lt;/span&gt;(),
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByRef&lt;/span&gt; blob &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; DATA_BLOB
_&lt;br&gt;
)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
Use empty array for null parameter.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt; data &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Is&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Then&lt;/span&gt;
&lt;br&gt;
data &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Byte&lt;/span&gt;(0)
{}&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
Allocate memory for the BLOB data.&lt;/span&gt;
&lt;br&gt;
blob.pbData &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Marshal.AllocHGlobal(data.Length)&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
Make sure that memory allocation was successful.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt; blob.pbData.Equals(IntPtr.Zero) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Then&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Throw&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; Exception(
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Unable
to allocate data buffer for BLOB structure."&lt;/span&gt;)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
Specify number of bytes in the BLOB.&lt;/span&gt;
&lt;br&gt;
blob.cbData &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; data.Length&lt;br&gt;
Marshal.Copy(data, 0, blob.pbData, data.Length)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Enum&lt;/span&gt; KeyType&lt;br&gt;
UserKey &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 1&lt;br&gt;
MachineKey&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Enum&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Shared&lt;/span&gt; defaultKeyType &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; KeyType &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; KeyType.UserKey&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Shared&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt; Encrypt
_&lt;br&gt;
( _&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; keyType &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; KeyType,
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; plainText &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt;,
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; entropy &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt;,
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;description&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt; _&lt;br&gt;
) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt; plainText &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Is&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Then&lt;/span&gt;
&lt;br&gt;
plainText &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt;.Empty&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt; entropy &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Is&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Then&lt;/span&gt;
&lt;br&gt;
entropy &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt;.Empty&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; result &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Byte&lt;/span&gt;()&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; encrypted &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;""&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; i &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Integer&lt;/span&gt;
&lt;br&gt;
result &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Encrypt(keyType,
_&lt;br&gt;
Encoding.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Unicode&lt;/span&gt;.GetBytes(plainText),
_&lt;br&gt;
Encoding.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Unicode&lt;/span&gt;.GetBytes(entropy),
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;description&lt;/span&gt;)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;For&lt;/span&gt; i &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 0 &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;To&lt;/span&gt; result.Length &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;-&lt;/span&gt; 1&lt;br&gt;
encrypted &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; encrypted
&amp;amp; Convert.ToString(result(i), 16).PadLeft(2, &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"0"&lt;/span&gt;).ToUpper()&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Next&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Return&lt;/span&gt; encrypted.ToString()&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Shared&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt; Encrypt
_&lt;br&gt;
( _&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; keyType &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; KeyType,
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; plainTextBytes &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Byte&lt;/span&gt;(),
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; entropyBytes &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Byte&lt;/span&gt;(),
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;description&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt; _&lt;br&gt;
) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Byte&lt;/span&gt;()&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt; plainTextBytes &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Is&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Then&lt;/span&gt;
&lt;br&gt;
plainTextBytes &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Byte&lt;/span&gt;(0)
{}&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt; entropyBytes &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Is&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Then&lt;/span&gt;
&lt;br&gt;
entropyBytes &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Byte&lt;/span&gt;(0)
{}&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;description&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Is&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Then&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;description&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt;.Empty&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; plainTextBlob &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; DATA_BLOB &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; DATA_BLOB&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; cipherTextBlob &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; DATA_BLOB &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; DATA_BLOB&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; entropyBlob &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; DATA_BLOB &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; DATA_BLOB&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; prompt &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; _&lt;br&gt;
CRYPTPROTECT_PROMPTSTRUCT &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; CRYPTPROTECT_PROMPTSTRUCT&lt;br&gt;
InitPrompt(prompt)&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Try&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Try&lt;/span&gt;
&lt;br&gt;
InitBLOB(plainTextBytes, plainTextBlob)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Catch&lt;/span&gt; ex &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; Exception&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Throw&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; Exception(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Cannot
initialize plaintext BLOB."&lt;/span&gt;, ex)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Try&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Try&lt;/span&gt;
&lt;br&gt;
InitBLOB(entropyBytes, entropyBlob)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Catch&lt;/span&gt; ex &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; Exception&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Throw&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; Exception(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Cannot
initialize entropy BLOB."&lt;/span&gt;, ex)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Try&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; flags &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Integer&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; CRYPTPROTECT_UI_FORBIDDEN&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt; keyType &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; keyType.MachineKey &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Then&lt;/span&gt;
&lt;br&gt;
flags &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; flags &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; (CRYPTPROTECT_LOCAL_MACHINE)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; success &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Boolean&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; CryptProtectData(
_&lt;br&gt;
plainTextBlob, _&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;description&lt;/span&gt;,
_&lt;br&gt;
entropyBlob, _&lt;br&gt;
IntPtr.Zero, _&lt;br&gt;
prompt, _&lt;br&gt;
flags, _&lt;br&gt;
cipherTextBlob)&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Not&lt;/span&gt; success &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Then&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; errCode &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Integer&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Marshal.GetLastWin32Error()&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Throw&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; Exception(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"CryptProtectData
failed."&lt;/span&gt;, _&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; Win32Exception(errCode))&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; cipherTextBytes(cipherTextBlob.cbData) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Byte&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
Marshal.Copy(cipherTextBlob.pbData, cipherTextBytes, 0, _&lt;br&gt;
cipherTextBlob.cbData)&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Return&lt;/span&gt; cipherTextBytes&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Catch&lt;/span&gt; ex &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; Exception&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Throw&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; Exception(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"DPAPI
was unable to encrypt data."&lt;/span&gt;, ex)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Finally&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Not&lt;/span&gt; (plainTextBlob.pbData.Equals(IntPtr.Zero)) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Then&lt;/span&gt;
&lt;br&gt;
Marshal.FreeHGlobal(plainTextBlob.pbData)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Not&lt;/span&gt; (cipherTextBlob.pbData.Equals(IntPtr.Zero)) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Then&lt;/span&gt;
&lt;br&gt;
Marshal.FreeHGlobal(cipherTextBlob.pbData)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Not&lt;/span&gt; (entropyBlob.pbData.Equals(IntPtr.Zero)) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Then&lt;/span&gt;
&lt;br&gt;
Marshal.FreeHGlobal(entropyBlob.pbData)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Try&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Class&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;br&gt;
&lt;font face=Verdana color=#000000 size=2&gt;Then in our .RDP file generator we just call
out to our dot net encryptor like this.&lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font size=2&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DPAPI.Encrypt(DPAPI.KeyType.MachineKey,
"MyPassword", &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"psw"&lt;/span&gt;)&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Verdana color=#000000&gt;Now, this is worth stressing again that exposing
passwords for RDP clients can be a very dangerous idea. Someone can grab ahold of
those and cause all sorts of havoc so your management of these security tools needs
to be very well understood. Storage, access, and management of this data is one of
the most critical components of your security strategy and anytime your exposing this
information you need to be aware of the ramifications of that action.&lt;/font&gt;
&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&gt;
&lt;/span&gt;&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=9b6bb97b-15d8-4959-a658-a7b5b3f8b88b" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,9b6bb97b-15d8-4959-a658-a7b5b3f8b88b.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=73916bfa-3c08-4ff7-b2cd-31f8bba44019</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,73916bfa-3c08-4ff7-b2cd-31f8bba44019.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,73916bfa-3c08-4ff7-b2cd-31f8bba44019.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=73916bfa-3c08-4ff7-b2cd-31f8bba44019</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
When passing datasets around via webservices we've had some problems with the size
of the resulting xml. The following code will compress the dataset and turn it into
a byte(). Note that you need to close the streams after calling WriteXml otherwise
you'll get a "unexpected end of file" style exception when you try to load back into
your dataset<font size="2">.
</font></p>
        <p>
          <font color="#0000ff" size="2">
            <font color="#0000ff" size="2">
            </font>
          </font>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> ms <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> IO.MemoryStream<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> cs <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> IO.Compression.GZipStream(ms,
IO.Compression.CompressionMode.Compress, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">False</span>)<br />
results.WriteXml(cs)<br />
cs.Close()<br />
ms.Close()<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> bytes <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Byte</span>() <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> ms.ToArray</span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <font face="Verdana" size="2">Heres
the corresponding decompression code for the server component.</font>
          </span>
        </p>
        <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          <font face="Verdana" size="2">
            <p>
              <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> results <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> DataSet<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> ms <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> IO.MemoryStream(_Args.Results)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> cs <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> IO.Compression.GZipStream(ms,
IO.Compression.CompressionMode.Decompress, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">False</span>)<br />
results.ReadXml(cs)<br />
cs.Close()<br />
ms.Close()</span>
            </p>
          </font>
        </span>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=73916bfa-3c08-4ff7-b2cd-31f8bba44019" />
      </body>
      <title>Compressing DataSets</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,73916bfa-3c08-4ff7-b2cd-31f8bba44019.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2009/02/11/CompressingDataSets.aspx</link>
      <pubDate>Wed, 11 Feb 2009 18:20:41 GMT</pubDate>
      <description>&lt;p&gt;
When passing datasets around via webservices we've had some problems with the size
of the resulting xml. The following code will compress the dataset and turn it into
a byte(). Note that you need to close the streams after calling WriteXml otherwise
you'll get a "unexpected end of file" style exception when you try to load back into
your dataset&lt;font size=2&gt;.
&lt;/p&gt;
&lt;p&gt;
&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; ms &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; IO.MemoryStream&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; cs &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; IO.Compression.GZipStream(ms,
IO.Compression.CompressionMode.Compress, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;False&lt;/span&gt;)&lt;br&gt;
results.WriteXml(cs)&lt;br&gt;
cs.Close()&lt;br&gt;
ms.Close()&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; bytes &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Byte&lt;/span&gt;() &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; ms.ToArray&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt;Heres
the corresponding decompression code for the server component.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; results &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; DataSet&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; ms &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; IO.MemoryStream(_Args.Results)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; cs &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; IO.Compression.GZipStream(ms,
IO.Compression.CompressionMode.Decompress, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;False&lt;/span&gt;)&lt;br&gt;
results.ReadXml(cs)&lt;br&gt;
cs.Close()&lt;br&gt;
ms.Close()&lt;/span&gt;
&lt;/font&gt;&lt;/span&gt;&gt;&gt;&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=73916bfa-3c08-4ff7-b2cd-31f8bba44019" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,73916bfa-3c08-4ff7-b2cd-31f8bba44019.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=9444b5cc-ae32-4e66-a282-7fc043cff2d7</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,9444b5cc-ae32-4e66-a282-7fc043cff2d7.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,9444b5cc-ae32-4e66-a282-7fc043cff2d7.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=9444b5cc-ae32-4e66-a282-7fc043cff2d7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We have a huge bank of legacy code written in vb6 that we're slowly porting over to
dot net. One of these components that's getting shuffled over this week is our Invoice
Printing functionality.
</p>
        <p>
Previously this logic was written in Data Dynamics Active Reports 1.0 (COM based)
and we're looking to upgrade this to Active Reports 4.2 (Dot Net 2.0). A quick plug,
Active Reports is an absolutely awesome tool for designing and developing business
reports. Even their COM-based 1.0 model shows a ton of insight into HOW we should
be developing reporting applications.
</p>
        <p>
Anyway, we're going to have to re-write some code as part of this process but the
one component that would be nice to pull across is the "design" surface. This basically
consists of all the controls and layouts. If we have to re-design this from scratch
we're going to miss positions, fonts, etc so it's better to automate this piece if
we can. Here's what it looks like...
</p>
        <p>
          <img height="475" src="http://www.bradleysblog.net/blog/content/binary/ar-designer.JPG" width="599" border="0" />
        </p>
        <p>
Now, Active Reports supports a common design layout for AR2.0 to AR4.2, sort of a
XML-based layout language they call RPX. If you can save a report layout into an RPX
you can load it back later on. Trick is that our reports are AR1.0 and that old version
uses a different binary format for saving layouts. I need to somehow upgrade these
from AR1.0 to AR2.0 before I can save them into the common format.
</p>
        <p>
Turns out this is easier than you'd think. The vb6 report design files are seperated
into two components... a binary .DSX file and a text .DSR file. If you crack open
the DSR file the first bit of "code" specifies which tool "manages" the resource.
That's what the big ugly guid is. By changing this guid from AR1.0 to AR2.0 we can
fake VB6 into thinking it's dealing with an AR2.0 report.
</p>
        <p>
          <img src="http://www.bradleysblog.net/blog/content/binary/ar-vb6-com2.JPG" border="0" />   
</p>
        <p>
          <img src="http://www.bradleysblog.net/blog/content/binary/ar-vb6-com1a.JPG" border="0" />
        </p>
        <p>
Now, when we open up the designer in vb6, we have the option to save the report layout
by using the File, Save feature within the report designer. Likewise in dot net we
can use the Report menu item to Load a saved layout. We've managed to save ourselves
all the work in positioning, sizing, and configuring all the controls behind this
active report!<br /></p>
        <p>
          <img src="http://www.bradleysblog.net/blog/content/binary/ar-layout-save.JPG" border="0" />
        </p>
        <p>
          <img style="WIDTH: 548px; HEIGHT: 414px" height="424" src="http://www.bradleysblog.net/blog/content/binary/ar-layout-load.JPG" width="573" border="0" />
        </p>
        <p>
 
</p>
        <p>
Now, all this effort to avoid recreating some controls... worth it? To me it is. The
problem with me redesiging these reports is that...
</p>
        <p>
1. I'm not that great of a detail guy. Not bad, but not great. I'm positive I'd screw
something up. And it may not be a huge deal to the first 20 stores that get this upgrade
but at some point that change in field size would be a critical concern to some store.
If I can avoid the issue altogether that's a good thing.
</p>
        <p>
2. I get bored easy. I'd copy probably 5 controls before I'd get distracted and switched
over to something else. I'll bet you it would take me a week to get this one report
copied over. By converting the entire report in one pass I've moved the project to
the point where I can have someone else take over the loading of data.
</p>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=9444b5cc-ae32-4e66-a282-7fc043cff2d7" />
      </body>
      <title>Absolutely Awesome!</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,9444b5cc-ae32-4e66-a282-7fc043cff2d7.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2008/12/08/AbsolutelyAwesome.aspx</link>
      <pubDate>Mon, 08 Dec 2008 23:54:24 GMT</pubDate>
      <description>&lt;p&gt;
We have a huge bank of legacy code written in vb6 that we're slowly porting over to
dot net. One of these components that's getting shuffled over this week is our Invoice
Printing functionality.
&lt;/p&gt;
&lt;p&gt;
Previously this logic was written in Data Dynamics Active Reports 1.0 (COM based)
and we're looking to upgrade this to Active Reports 4.2 (Dot Net 2.0). A quick plug,
Active Reports is an absolutely awesome tool for designing and developing business
reports. Even their COM-based 1.0 model shows a ton of insight into HOW we should
be developing reporting applications.
&lt;/p&gt;
&lt;p&gt;
Anyway, we're going to have to re-write some code as part of this process but the
one component that would be nice to pull across is the "design" surface. This basically
consists of all the controls and layouts. If we have to re-design this from scratch
we're going to miss positions, fonts, etc so it's better to automate this piece if
we can. Here's what it looks like...
&lt;/p&gt;
&lt;p&gt;
&lt;img height=475 src="http://www.bradleysblog.net/blog/content/binary/ar-designer.JPG" width=599 border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Now, Active Reports supports a common design layout for AR2.0 to AR4.2, sort of a
XML-based layout language they call RPX. If you can save a report layout into an RPX
you can load it back later on. Trick is that our reports are AR1.0 and that old version
uses a different binary format for saving layouts. I need to somehow upgrade these
from AR1.0 to AR2.0 before I can save them into the common format.
&lt;/p&gt;
&lt;p&gt;
Turns out this is easier than you'd think. The vb6 report design files are seperated
into two components... a binary .DSX file and a text .DSR file. If you crack open
the DSR file the first bit of "code" specifies which tool "manages" the resource.
That's what the big ugly guid is. By changing this guid from AR1.0 to AR2.0 we can
fake VB6 into thinking it's dealing with an AR2.0 report.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/ar-vb6-com2.JPG" border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/ar-vb6-com1a.JPG" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Now, when we open up the designer in vb6, we have the option to save the report layout
by using the File, Save feature within the report designer. Likewise in dot net we
can use the Report menu item to Load a saved layout. We've managed to save ourselves
all the work in positioning, sizing, and configuring all the controls behind this
active report!&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/ar-layout-save.JPG" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img style="WIDTH: 548px; HEIGHT: 414px" height=424 src="http://www.bradleysblog.net/blog/content/binary/ar-layout-load.JPG" width=573 border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Now, all this effort to avoid recreating some controls... worth it? To me it is. The
problem with me redesiging these reports is that...
&lt;/p&gt;
&lt;p&gt;
1. I'm not that great of a detail guy. Not bad, but not great. I'm positive I'd screw
something up. And it may not be a huge deal to the first 20 stores that get this upgrade
but at some point that change in field size would be a critical concern to some store.
If I can avoid the issue altogether that's a good thing.
&lt;/p&gt;
&lt;p&gt;
2. I get bored easy. I'd copy probably 5 controls before I'd get distracted and switched
over to something else. I'll bet you it would take me a week to get this one report
copied over. By converting the entire report in one pass I've moved the project to
the point where I can have someone else take over the loading of data.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=9444b5cc-ae32-4e66-a282-7fc043cff2d7" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,9444b5cc-ae32-4e66-a282-7fc043cff2d7.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=b2068be0-1ac6-4940-922f-60b4face55eb</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,b2068be0-1ac6-4940-922f-60b4face55eb.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,b2068be0-1ac6-4940-922f-60b4face55eb.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=b2068be0-1ac6-4940-922f-60b4face55eb</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">We just added a cool new feature to
our aristo framework, embedded instant messaging! Pretty typical feature but here's
what our gui looks like.</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <img src="http://www.bradleysblog.net/blog/content/binary/im-converation.JPG" border="0" />
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
 
</p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">Now when we first heard requests for
this component I was a little skeptical. It's pretty much a given that at some point
ALL software applications get a request to add an instant messenger and email capability;
you could be programming a calculator and eventually you'll get this request. Our
I.M. does have a couple key differences.</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">   1. This is an internal
only application. Staff can't be chatting to their friends and family through this
messenger.</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">   2. This is an automatic
application. Users don't have to start another app to get the messenger going. It's
always on when they're in PBS.</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">   3. This is an embedded
component.  Because we're running in a Terminal window we have to work whithin
our existing UI space (aka the terminal window, no extra desktop apps allowed).</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">   4. Because we're embedded
there are some very cool extensions we can add for sending "information" in our software
between users. More on this in the next couple weeks.</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
 
</p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">Here's a quick primer on how this works.</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">Users now have a messenger icon in their
system tray whenever they start Aristo. At login this icon will notify users that
they are connected to the aristo messenger (this notification will also point out
the fact that there is something new in their software).</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <img src="http://www.bradleysblog.net/blog/content/binary/im-startup.JPG" border="0" />
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">Users can right click on this icon to
either send a message to a specific user or send a broadcast message. Message windows
are pretty much like any other I.M. solution and can be minimized while users are
doing actual work. New messages cause the conversation windows to highlight until
the user views them.</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <img src="http://www.bradleysblog.net/blog/content/binary/im-send.JPG" border="0" />
        </p>
        <p>
          <img src="http://www.bradleysblog.net/blog/content/binary/im-updated.JPG" border="0" />
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">The more interesting aspect of this
component will be HOW we can use it as a tool within our software but we've definitely
heard this request a lot and our users should be happy to see we've reacted. </font>
        </p>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=b2068be0-1ac6-4940-922f-60b4face55eb" />
      </body>
      <title>Aristo Instant Messenger</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,b2068be0-1ac6-4940-922f-60b4face55eb.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2008/10/29/AristoInstantMessenger.aspx</link>
      <pubDate>Wed, 29 Oct 2008 19:28:16 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;We just added a cool new feature to our aristo
framework, embedded instant messaging! Pretty typical feature but here's what our
gui looks like.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/im-converation.JPG" border=0&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Now when we first heard requests for this
component I was a little skeptical. It's pretty much a given that at some point ALL
software applications get a request to add an instant messenger and email capability;
you could be programming a calculator and eventually you'll get this request. Our
I.M. does have a couple key differences.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;1. This is an internal only
application. Staff can't be chatting to their friends and family through this messenger.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;2. This is an automatic
application. Users don't have to start another app to get the messenger going. It's
always on when they're in PBS.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;3. This is an embedded component.&amp;nbsp;
Because we're running in a Terminal window we have to work whithin our existing UI
space (aka the terminal window, no extra desktop apps allowed).&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;4. Because we're embedded
there are some very cool extensions we can add for sending "information" in our software
between users. More on this in the next couple weeks.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Here's a quick primer on how this works.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Users now have a messenger icon in their system
tray whenever they start Aristo. At login this icon will notify users that they are
connected to the aristo messenger (this notification will also point out the fact
that there is something new in their software).&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/im-startup.JPG" border=0&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Users can right click on this icon to either
send a message to a specific user or send a broadcast message. Message windows are
pretty much like any other I.M. solution and can be minimized while users are doing
actual work. New messages cause the conversation windows to highlight until the user
views them.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/im-send.JPG" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/im-updated.JPG" border=0&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;The more interesting aspect of this component
will be HOW we can use it as a tool within our software but we've definitely heard
this request a lot and our users should be happy to see we've reacted. &lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=b2068be0-1ac6-4940-922f-60b4face55eb" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,b2068be0-1ac6-4940-922f-60b4face55eb.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=eab500b5-dba8-4058-858f-37e5389fe635</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,eab500b5-dba8-4058-858f-37e5389fe635.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,eab500b5-dba8-4058-858f-37e5389fe635.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=eab500b5-dba8-4058-858f-37e5389fe635</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I came across the need to do some t-sql work prior to our annual dealer conference
next week. The short version is that we need to sanitize our customer data by replacing
customer pictures with some stock photos of people around PBS. I certainly didn't
want to have to manually change every customer record so I figured a gigantic t-sql
script to update everyone would be a huge help. 
</p>
        <p>
Now I gotta admit - this is not the kind of component I normally work on.  Database
administrators tear through these kinds of apps but when you're a bit more of a generalist
you need to be pretty good at googling the right kind of questions.
</p>
        <p>
Anyway, here's the requirements...
</p>
        <p>
1. Update every customer record with a new photo.<br />
2. Choose the photo from a subset of 10 or 12 stock pictures.<br />
3. Try to make sure that "consecutive" customer records don't have the same photo.
</p>
        <p>
The first thing that takes figuring out is how to load an image from a file into
a table. For some reason google-ing this didn't do too good. In the end it's pretty
easy. The following command loads an image file into a blob-style object for use in
t-sql...
</p>
        <font color="#0000ff">
          <font face="Courier New">
            <p>
              <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> * <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">OPENROWSET</span>(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BULK</span> N<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'c:\creek.jpg'</span>,
SINGLE_BLOB) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">as</span> i</span>
            </p>
          </font>
        </font>
        <p>
Note that you need the rowset descriptor "as i". Otherwise you'll receive some error
about corelations.
</p>
        <p>
Next I wanted to build a temporary table of customer id's and picture id's. Something
like...
</p>
        <p>
Customer1 Picture1<br />
Customer2 Picture2<br />
Customer3 Picture3<br />
Customer4 Picture1<br />
Customer5 Picture2<br />
...
</p>
        <p>
This would make a somewhat random picture list where at least adjacent customers wouldn't
have the same picture. I accomplished this using the ROW_NUMBER() function against
our customer code's.
</p>
        <font face="Courier New" color="#0000ff">
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">INSERT</span>
              <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">INTO</span> #Links
(ContactId, PictureId)<br />
    (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> fldId,
ROW_NUMBER() <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">OVER</span>(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ORDER</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BY</span> fldCode)
% @Image_Count<br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span> tblContacts)</span>
          </p>
        </font>
        <p>
Once we've got these two pieces together we can generate our test data pretty reliably.
Here's the final sql script ...<br /></p>
        <font color="#0000ff" size="2">
          <font face="Courier New">
            <p>
              <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @Image_Count <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span>    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SET</span> @Image_Count
= 2<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">CREATE</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">TABLE</span> #Links
(<br />
    ContactId <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">uniqueidentifier</span>,<br />
    PictureId <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span><br />
)<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">INSERT</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">INTO</span> #Links
(ContactId, PictureId)<br />
    (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> fldId,
ROW_NUMBER() <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">OVER</span>(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ORDER</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BY</span> fldCode)
% @Image_Count<br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span> tblContacts)<br /><br /><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">UPDATE</span> tblContacts <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SET</span> fldImage
= 
<br />
    (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> * <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">OPENROWSET</span>(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BULK</span> N<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'c:\creek.jpg'</span>,
SINGLE_BLOB) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">as</span> i)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WHERE</span> fldId <span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">IN</span> (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> ContactId <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span> #Links <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WHERE</span> PictureId
= 0)<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">UPDATE</span> tblContacts <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SET</span> fldImage
= 
<br />
    (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> * <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">OPENROWSET</span>(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BULK</span> N<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'c:\dock.jpg'</span>,
SINGLE_BLOB) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">as</span> i)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WHERE</span> fldId <span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">IN</span> (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> ContactId <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span> #Links <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WHERE</span> PictureId
= 1)<br /><br /><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DROP</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">TABLE</span> #Links</span>
            </p>
            <p>
            </p>
          </font>
        </font>
        <font face="Courier New">
          <font size="2">
          </font>
        </font>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=eab500b5-dba8-4058-858f-37e5389fe635" />
      </body>
      <title>Couple t-sql tricks</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,eab500b5-dba8-4058-858f-37e5389fe635.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2008/08/29/CoupleTsqlTricks.aspx</link>
      <pubDate>Fri, 29 Aug 2008 03:50:20 GMT</pubDate>
      <description>&lt;p&gt;
I came across the need to do some t-sql work prior to our annual dealer conference
next week. The short version is that we need to sanitize our customer data by replacing
customer pictures with some stock photos of people around PBS. I certainly didn't
want to have to manually change every customer record so I figured a gigantic t-sql
script to update everyone would be a huge help. 
&lt;/p&gt;
&lt;p&gt;
Now I gotta admit - this is not the kind of component I normally work on.&amp;nbsp; Database
administrators tear through these kinds of apps but when you're a bit more of a generalist
you need to be pretty good at googling the right kind of questions.
&lt;/p&gt;
&lt;p&gt;
Anyway, here's the requirements...
&lt;/p&gt;
&lt;p&gt;
1. Update every customer record with a new photo.&lt;br&gt;
2. Choose the photo from a subset of 10 or 12 stock pictures.&lt;br&gt;
3. Try to make sure that "consecutive" customer records don't have the same photo.
&lt;/p&gt;
&lt;p&gt;
The first thing&amp;nbsp;that takes figuring out is how to load an image from a file into
a table. For some reason google-ing this didn't do too good. In the end it's pretty
easy. The following command loads an image file into a blob-style object for use in
t-sql...
&lt;/p&gt;
&lt;font color=#0000ff&gt;&lt;font face="Courier New"&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; * &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;OPENROWSET&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BULK&lt;/span&gt; N&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'c:\creek.jpg'&lt;/span&gt;,
SINGLE_BLOB) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;as&lt;/span&gt; i&lt;/span&gt;
&lt;/p&gt;
&lt;/font&gt;&lt;/font&gt; 
&lt;p&gt;
Note that you need the rowset descriptor "as i". Otherwise you'll receive some error
about corelations.
&lt;/p&gt;
&lt;p&gt;
Next I wanted to build a temporary table of customer id's and picture id's. Something
like...
&lt;/p&gt;
&lt;p&gt;
Customer1&amp;nbsp;Picture1&lt;br&gt;
Customer2&amp;nbsp;Picture2&lt;br&gt;
Customer3&amp;nbsp;Picture3&lt;br&gt;
Customer4&amp;nbsp;Picture1&lt;br&gt;
Customer5&amp;nbsp;Picture2&lt;br&gt;
...
&lt;/p&gt;
&lt;p&gt;
This would make a somewhat random picture list where at least adjacent customers wouldn't
have the same picture. I accomplished this using the ROW_NUMBER() function against
our customer code's.
&lt;/p&gt;
&lt;font face="Courier New" color=#0000ff&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;INSERT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;INTO&lt;/span&gt; #Links
(ContactId, PictureId)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; fldId,
ROW_NUMBER() &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;OVER&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ORDER&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BY&lt;/span&gt; fldCode)
% @Image_Count&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; tblContacts)&lt;/span&gt;
&lt;/p&gt;
&lt;/font&gt; 
&lt;p&gt;
Once we've got these two pieces together we can generate our test data pretty reliably.
Here's the final sql script ...&lt;br&gt;
&lt;/p&gt;
&lt;font color=#0000ff size=2&gt;&lt;font face="Courier New"&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @Image_Count &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SET&lt;/span&gt; @Image_Count
= 2&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;CREATE&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;TABLE&lt;/span&gt; #Links
(&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ContactId &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;uniqueidentifier&lt;/span&gt;,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PictureId &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt;
&lt;br&gt;
)&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;INSERT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;INTO&lt;/span&gt; #Links
(ContactId, PictureId)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; fldId,
ROW_NUMBER() &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;OVER&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ORDER&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BY&lt;/span&gt; fldCode)
% @Image_Count&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; tblContacts)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;UPDATE&lt;/span&gt; tblContacts &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SET&lt;/span&gt; fldImage
= 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; * &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;OPENROWSET&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BULK&lt;/span&gt; N&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'c:\creek.jpg'&lt;/span&gt;,
SINGLE_BLOB) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;as&lt;/span&gt; i)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WHERE&lt;/span&gt; fldId &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;IN&lt;/span&gt; (&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; ContactId &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; #Links &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WHERE&lt;/span&gt; PictureId
= 0)&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;UPDATE&lt;/span&gt; tblContacts &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SET&lt;/span&gt; fldImage
= 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; * &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;OPENROWSET&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BULK&lt;/span&gt; N&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'c:\dock.jpg'&lt;/span&gt;,
SINGLE_BLOB) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;as&lt;/span&gt; i)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WHERE&lt;/span&gt; fldId &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;IN&lt;/span&gt; (&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; ContactId &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; #Links &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WHERE&lt;/span&gt; PictureId
= 1)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DROP&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;TABLE&lt;/span&gt; #Links&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&gt;
&lt;/font&gt;&lt;/font&gt;&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=eab500b5-dba8-4058-858f-37e5389fe635" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,eab500b5-dba8-4058-858f-37e5389fe635.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=64eb44db-cd8c-4221-99fa-2c3fdcb099f3</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,64eb44db-cd8c-4221-99fa-2c3fdcb099f3.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,64eb44db-cd8c-4221-99fa-2c3fdcb099f3.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=64eb44db-cd8c-4221-99fa-2c3fdcb099f3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We recently began using the Sourcegear Vault Enhanced Client for Visual Studio. <font face="Calibri" color="#000000" size="3">Intermittently
we would receive errors accessing our Vault Server. Something to the effect of...</font></p>
        <font face="Calibri" color="#000000" size="3">
          <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
"The Vault server could not be contacted to perform the operation."
</p>
          <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
You'd try the operation a couple more times and eventually it would go through. After
a bunch of digging I found a couple articles on the Sourcegear support forums that
pointed me in the direction of the default proxy settings.
</p>
          <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
            <a href="http://support.sourcegear.com/viewtopic.php?t=735">http://support.sourcegear.com/viewtopic.php?t=735</a>
          </p>
          <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
What was really interesting was that a&gt; this happened usually when working offsite
and b&gt; it happened p<span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">redominantly
through the Visual Studio IDE Client... the normal Vault GUI was fine.</span></p>
          <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
            <span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">It
turns out that this default proxy setting is stored in an app.config. When I compared
the VaultGuiClient.exe.config with the devenv.exe.config (Program files\Microsoft
VS 2008\Common7\IDE)  I found that the Vault GUI had specified to use the system
proxy settings while Visual Studio had specified that no proxy existed. </span>
          </p>
          <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
            <span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">Since
changing the devenv.exe.config to match the vault gui config the issue appears to
have disappeared. Here's what our new devenv config file looks like... note that the
defaultProxy section is the important bit.</span>
          </p>
        </font>
        <img src="http://www.bradleysblog.net/blog/content/binary/vaultProxy.JPG" border="0" />
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=64eb44db-cd8c-4221-99fa-2c3fdcb099f3" />
      </body>
      <title>Sourcegear Vault Issue</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,64eb44db-cd8c-4221-99fa-2c3fdcb099f3.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2008/05/25/SourcegearVaultIssue.aspx</link>
      <pubDate>Sun, 25 May 2008 04:56:21 GMT</pubDate>
      <description>&lt;p&gt;
We recently began using the Sourcegear Vault Enhanced Client for Visual Studio. &lt;font face=Calibri color=#000000 size=3&gt;Intermittently
we would receive errors accessing our Vault Server. Something to the effect of...&lt;/font&gt;
&lt;/p&gt;
&lt;font face=Calibri color=#000000 size=3&gt; 
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
"The Vault server could not be contacted to perform the operation."
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
You'd try the operation a couple more times and eventually it would go through. After
a bunch of digging I found a couple articles on the Sourcegear support forums that
pointed me in the direction of the default proxy settings.
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;a href="http://support.sourcegear.com/viewtopic.php?t=735"&gt;http://support.sourcegear.com/viewtopic.php?t=735&lt;/a&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
What was really interesting was that a&amp;gt; this happened usually when working offsite
and b&amp;gt; it happened p&lt;span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;redominantly
through the Visual Studio IDE Client... the normal Vault GUI was fine.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;It
turns out that this default proxy setting is stored in an app.config. When I compared
the VaultGuiClient.exe.config with the devenv.exe.config (Program files\Microsoft
VS 2008\Common7\IDE)&amp;nbsp; I found that the Vault GUI had specified to use the system
proxy settings while Visual Studio had specified that no proxy existed. &lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;Since
changing the devenv.exe.config to match the vault gui config the issue appears to
have disappeared. Here's what our new devenv config file looks like... note that the
defaultProxy section is the important bit.&lt;/span&gt;
&lt;/p&gt;
&lt;/font&gt;&lt;img src="http://www.bradleysblog.net/blog/content/binary/vaultProxy.JPG" border=0&gt;&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=64eb44db-cd8c-4221-99fa-2c3fdcb099f3" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,64eb44db-cd8c-4221-99fa-2c3fdcb099f3.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=3bff8914-13fd-4b23-a03a-02a2d6dc9a41</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,3bff8914-13fd-4b23-a03a-02a2d6dc9a41.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,3bff8914-13fd-4b23-a03a-02a2d6dc9a41.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=3bff8914-13fd-4b23-a03a-02a2d6dc9a41</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of the key ideals behind Electronic Document Management is that it's supposed
to save you money. The idea is that by eliminating some of the paper requirements
you can cut down on supply and maintenance costs. It's one of those arguments that
I've heard a number of times and to be honest I'd mostly ignored it.
</p>
        <p>
My thought was that KNOWING you had electronic copies of each service order was well
worth the investment and that the ongoing management and filing of these documents
had such a time savings that the financial ramifications weren't as big a deal. Turns
out I was wrong...
</p>
        <p>
 
</p>
        <p>
So here's the premise...
</p>
        <p>
Each work order written inside of a Dealer Management System typically consists of
6 copies.
</p>
        <p>
1 x Hard Copy approving the work.<br />
1 x Technician Copy, so the tech's can note their work.<br />
2 x Closing Copy, one for the customer, one for the dealership.<br />
1 x Warranty Copy for the the manufacturer (if applicable).<br />
1 x Accounting Copy, for the accounting system.
</p>
        <p>
          <br />
So, a store with 12 technicians doing 5 service orders per day would generate 360
documents per day.
</p>
        <p>
12 techs x 5 service orders x 6 documents per service order = 360 documents
</p>
        <p>
          <br />
The same store, over the course of a year would generate almost 100,000 service documents.
</p>
        <p>
360 documents per day x 5 days per week x 52 weeks per year = 93,600
</p>
        <p>
          <br />
Based on our experience each of these documents costs around 4 cents to print. When
you take into account paper, toner, and printer wear and tear this adds up pretty
quickly.
</p>
        <p>
4 cents per document x 93,600 documents = $3,744 per year.
</p>
        <p>
          <br />
And these numbers are for an average sized shop!
</p>
        <p>
I still believe that alot of the benefit behind electronic documents is the ability
to better manage and store your information, but these kinds of figures do make a
compelling financial argument. 
</p>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=3bff8914-13fd-4b23-a03a-02a2d6dc9a41" />
      </body>
      <title>The math behind Electronic Document Management</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,3bff8914-13fd-4b23-a03a-02a2d6dc9a41.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2008/04/14/TheMathBehindElectronicDocumentManagement.aspx</link>
      <pubDate>Mon, 14 Apr 2008 17:41:30 GMT</pubDate>
      <description>&lt;p&gt;
One of the key ideals behind Electronic Document Management is that it's supposed
to save you money. The idea is that by eliminating some of the paper requirements
you can cut down on supply and maintenance costs. It's one of those arguments that
I've heard a number of times and to be honest I'd mostly ignored it.
&lt;/p&gt;
&lt;p&gt;
My thought was that KNOWING you had electronic copies of each service order was well
worth the investment and that the ongoing management and filing of these documents
had such a time savings that the financial ramifications weren't as big a deal. Turns
out I was wrong...
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
So here's the premise...
&lt;/p&gt;
&lt;p&gt;
Each work order written inside of a Dealer Management System typically consists of
6 copies.
&lt;/p&gt;
&lt;p&gt;
1 x Hard Copy approving the work.&lt;br&gt;
1 x Technician Copy, so the tech's can note their work.&lt;br&gt;
2 x Closing Copy, one for the customer, one for the dealership.&lt;br&gt;
1 x Warranty Copy for the the manufacturer (if applicable).&lt;br&gt;
1 x Accounting Copy, for the accounting system.
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
So, a store with 12 technicians doing 5 service orders per day would generate 360
documents per day.
&lt;/p&gt;
&lt;p&gt;
12 techs x 5 service orders x 6 documents per service order = 360 documents
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
The same store, over the course of a year would generate almost 100,000 service documents.
&lt;/p&gt;
&lt;p&gt;
360 documents per day x 5 days per week x 52 weeks per year = 93,600
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
Based on our experience each of these documents costs around 4 cents to print. When
you take into account paper, toner, and printer wear and tear this adds up pretty
quickly.
&lt;/p&gt;
&lt;p&gt;
4 cents per document x 93,600 documents = $3,744 per year.
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
And these numbers are for an average sized shop!
&lt;/p&gt;
&lt;p&gt;
I still believe that alot of the benefit behind electronic documents is the ability
to better manage and store your information, but these kinds of figures do make a
compelling financial argument. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=3bff8914-13fd-4b23-a03a-02a2d6dc9a41" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,3bff8914-13fd-4b23-a03a-02a2d6dc9a41.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=2beacee2-5c3a-46de-843a-b757a8df18f6</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,2beacee2-5c3a-46de-843a-b757a8df18f6.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,2beacee2-5c3a-46de-843a-b757a8df18f6.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=2beacee2-5c3a-46de-843a-b757a8df18f6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">I’ll admit that I have a love/hate relationship
with Unit Testing.<span style="mso-spacerun: yes">  </span>Unit Testing has absolutely
saved my bacon a number of times where a seemingly inconsequential change would have
crippled our software. The reality is that the only way you can verify that those
tiny changes don’t wreck havoc is to script your testing for known results. By having
your build process validate those results you add a very strong safety net to your
development process.</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">But… in most software systems there’s
this pesky layer that throws a real wrench into the entire thing – it’s called the
database.</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">The problem is this… a Unit Test is
meant to be autonomous. It should be free standing and require no external dependencies.
In reality the code you’re executing typically interacts with an existing database
and performs INSERTS/UPDATES/DELETES to verify that certain functions still work.
What get’s awkward is that the “Unit Test” database is typically an external dependency
for your Unit Tests – it just has to be there be in the correct state or the Unit
Tests will crash hard. Things like database schema changes, new testing datasets,
and changing database locations really screw the unit tests up.</font>
        </p>
        <p>
          <span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">
            <font color="#000000">I’m
going to describe a solution to this problem that we’ve been using for the last couple
weeks. It’s worked extremely well by streamlining issues we had with databast style
unit tests and by increasing our code quality. Everything here is based on Visual
Studio 2005, nUnit, and nAnt but it’s more the concept that’s interesting.</font>
          </span>
        </p>
        <span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">
          <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
            <font color="#0000ff" size="5">How It Works!</font>
          </p>
          <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
            <font color="#000000">We started off by adding a special project as part of each module
called the Schema. Basically this is a simple class library with a bunch of embedded
SQL scripts. These SQL scripts are responsible for taking a database and putting it
into a known state for the Unit Tests. Execution of these scripts is done by a class
called the SchemaManager, it has three methods which will become obvious in a minute.</font>
          </p>
          <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
            <img src="http://www.bradleysblog.net/blog/content/binary/Schema-SchemaManager3.jpg" border="0" />
          </p>
        </span>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">The Unit Tests now add a reference to
the Schema project. As a nUnit Setup Method we'll call out to a special class called
the TestConfiguration. This TestConfiguration will be responsible for triggering the
SchemaManager. Here's what a typical Unit Test in our UnitTest project would look
like.</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <img src="http://www.bradleysblog.net/blog/content/binary/Schema-UnitTestInit.JPG" border="0" />
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">The TestConfiguration is a little more
interesting. It uses a singleton pattern to create a SchemaManager, tell it to
Drop the current Schema, and then Create it fresh. This executes the Drop Table/Procedure
commands to clear out our database, and then uses the Create Table commands to make
a fresh database.</font>
        </p>
        <p>
          <img src="http://www.bradleysblog.net/blog/content/binary/Schema-TestConfiguration3.JPG" border="0" />
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">Perfect! Now the database schema is
in a state that our Unit Tests can work with – table are there, stored procedures
are there, life’s good. </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">Now we need to create some canned data
before we start our tests. Things like maintenance objects, customer codes, etc. are
all expected to be in the database before our Unit Tests run so we need to create
scripts in our UnitTest database which setup this data. Something like this...</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">
          </font>
        </p>
        <p>
          <span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">
            <font color="#000000">
            </font>
          </span>
        </p>
        <p>
          <span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">
            <font color="#000000">
              <img src="http://www.bradleysblog.net/blog/content/binary/Schema-TestData3.JPG" border="0" />
            </font>
          </span>
        </p>
        <p>
          <span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">
            <font color="#000000">We’ll
embed this scripts into the UnitTest project and then change our TestConfiguration
so that it gets the SchemaManager to insert this data after calling CreateSchema. We'll
simply use the ExecuteResourceSql call we defined above and call it from our TestConfiguration.</font>
          </span>
        </p>
        <p>
          <span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">
            <img src="http://www.bradleysblog.net/blog/content/binary/Schema-InitTestData.JPG" border="0" />
          </span>
        </p>
        <p>
          <span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">And
that's pretty much it! I think the beauty of this SchemaManager is that is makes the
database a source-controlled resource. Instead of having some unknown dependency that
the unit tests must rely on, the unit tests actually create their environment using
scripts generated by the developer. If the developer breaks the Schema or the Business
Logic, the unit test will catch it right away and any failed unit tests are expected
to be logic errors instead of logistical problems between the development and unit
test environments.</span>
        </p>
        <p>
          <span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">If
you have any comments or suggestions on this area please drop me a line - it's a very
interesting (and often underused) development practice!</span>
        </p>
        <p>
          <span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">PS
- The foundation for a lot of this stuff is from a 4guysfromrolla posting, check
it out for more details...</span>
        </p>
        <p>
          <span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">
            <a href="http://aspnet.4guysfromrolla.com/articles/040605-1.2.aspx">http://aspnet.4guysfromrolla.com/articles/040605-1.2.aspx</a>
          </span>
        </p>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=2beacee2-5c3a-46de-843a-b757a8df18f6" />
      </body>
      <title>Unit Test / Data Generation</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,2beacee2-5c3a-46de-843a-b757a8df18f6.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2008/02/26/UnitTestDataGeneration.aspx</link>
      <pubDate>Tue, 26 Feb 2008 22:41:50 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;I’ll admit that I have a love/hate relationship
with Unit Testing.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Unit Testing has absolutely
saved my bacon a number of times where a seemingly inconsequential change would have
crippled our software. The reality is that the only way you can verify that those
tiny changes don’t wreck havoc is to script your testing for known results. By having
your build process validate those results you add a very strong safety net to your
development process.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;But… in most software systems there’s this
pesky layer that throws a real wrench into the entire thing – it’s called the database.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;The problem is this… a Unit Test is meant
to be autonomous. It should be free standing&amp;nbsp;and require no external dependencies.
In reality the code you’re executing typically interacts with an existing database
and performs INSERTS/UPDATES/DELETES to verify that certain functions still work.
What get’s awkward is that the “Unit Test” database is typically an external dependency
for your Unit Tests – it just has to be there be in the correct state or the Unit
Tests will crash hard. Things like database schema changes, new testing datasets,
and changing database locations really screw the unit tests up.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;font color=#000000&gt;I’m
going to describe a solution to this problem that we’ve been using for the last couple
weeks. It’s worked extremely well by streamlining issues we had with databast style
unit tests&amp;nbsp;and by increasing our code quality. Everything here is based on Visual
Studio 2005, nUnit, and nAnt but it’s more the concept that’s interesting.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt; 
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font color=#0000ff size=5&gt;How It Works!&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font color=#000000&gt;We started off by adding a special project as part of each module
called the Schema. Basically this is a simple class library with a bunch of embedded
SQL scripts. These SQL scripts are responsible for taking a database and putting it
into a known state for the Unit Tests. Execution of these scripts is done by a class
called the SchemaManager, it has three methods which will become obvious in a minute.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/Schema-SchemaManager3.jpg" border=0&gt;
&lt;/span&gt;&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;The Unit Tests now add a reference to the
Schema project. As a nUnit Setup Method we'll call out to a special class called the
TestConfiguration. This TestConfiguration will be responsible for triggering the SchemaManager.
Here's what a typical Unit Test in our UnitTest project would look like.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/Schema-UnitTestInit.JPG" border=0&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;The TestConfiguration is a little more interesting.
It uses a singleton pattern to create a SchemaManager,&amp;nbsp;tell it to Drop the current
Schema, and then Create it fresh. This executes the Drop Table/Procedure commands
to clear out our database, and then uses the Create Table commands to make a fresh
database.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/Schema-TestConfiguration3.JPG" border=0&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Perfect! Now the database schema is in a state
that our Unit Tests can work with – table are there, stored procedures are there,
life’s good. &lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Now we need to create some canned data before
we start our tests. Things like maintenance objects, customer codes, etc. are all
expected to be in the database before our Unit Tests run so we need to create scripts
in our UnitTest database which setup this data. Something like this...&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;font color=#000000&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;font color=#000000&gt;&lt;img src="http://www.bradleysblog.net/blog/content/binary/Schema-TestData3.JPG" border=0&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;font color=#000000&gt;We’ll
embed this scripts into the UnitTest project and then change our TestConfiguration
so that it gets the SchemaManager to insert this data after calling CreateSchema.&amp;nbsp;We'll
simply use the ExecuteResourceSql call we defined above and call it from our TestConfiguration.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;img src="http://www.bradleysblog.net/blog/content/binary/Schema-InitTestData.JPG" border=0&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;And
that's pretty much it! I think the beauty of this SchemaManager is that is makes the
database a source-controlled resource. Instead of having some unknown dependency that
the unit tests must rely on, the unit tests actually create their environment using
scripts generated by the developer. If the developer breaks the Schema or the Business
Logic, the unit test will catch it right away and any failed unit tests are expected
to be logic errors instead of logistical problems between the development and unit
test environments.&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;If
you have any comments or suggestions on this area please drop me a line - it's a very
interesting (and often underused) development practice!&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;PS
-&amp;nbsp;The foundation for a lot of this stuff is from a 4guysfromrolla posting, check
it out for more details...&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;a href="http://aspnet.4guysfromrolla.com/articles/040605-1.2.aspx"&gt;http://aspnet.4guysfromrolla.com/articles/040605-1.2.aspx&lt;/a&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=2beacee2-5c3a-46de-843a-b757a8df18f6" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,2beacee2-5c3a-46de-843a-b757a8df18f6.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=7a4dfdab-6567-49a6-b68f-1d2c1d1946e1</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,7a4dfdab-6567-49a6-b68f-1d2c1d1946e1.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,7a4dfdab-6567-49a6-b68f-1d2c1d1946e1.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=7a4dfdab-6567-49a6-b68f-1d2c1d1946e1</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I came across a great article a couple weeks back about the danger of little issues...
the foundation of this article was that every day we get interupted in ways that force
us to change what we're focused on, deal with an emergency, and then re-focus back
on the task at hand.
</p>
        <p>
This articule suggested that these "shifts" cause us to lose more time then if we
could just merrily work through one project at a time... makes sense, huh?  
</p>
        <p>
What's really interesting is that this article suggested that the LITTLE things actually
cause you more long-term grief than the big things. The reasoning was that when you
come across a big issue you learn in a big way... and subconsciously take action to
resolve it in the future. The problem with little issues is that they only take 1/2
an hour to resolve... and you become complacent in resolving them... twice a week...
for a year.
</p>
        <p>
 
</p>
        <p>
Why is this worth mentioning? Today while setting up for our NADA trade show (<a href="http://www.nada.org">www.nada.org</a>)
I ended up spending an hour trouble-shooting some file location issues on our demo
server. It's a stupid virtual-drive issue that only occurs in certain environments and
generally takes me about an hour to figure out. 
</p>
        <p>
The trouble is that we've grown complacent in spending an hour on this issue... instead
of focusing on why we need a virtual-drive in the first place. If we'd reworked our
pathing a year ago, I wouldn't get bothered by this every few weeks.
</p>
        <p>
 
</p>
        <p>
Once you identify the "Little Issue" it's all about committing yourself to resolving
it... we're in mad-panic trade show mode right now so let's see what we can do after
we get back from San Francisco... 
</p>
        <p>
To be continued...
</p>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=7a4dfdab-6567-49a6-b68f-1d2c1d1946e1" />
      </body>
      <title>The Danger of Little Issues...</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,7a4dfdab-6567-49a6-b68f-1d2c1d1946e1.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2008/02/09/TheDangerOfLittleIssues.aspx</link>
      <pubDate>Sat, 09 Feb 2008 07:37:44 GMT</pubDate>
      <description>&lt;p&gt;
I came across a great article a couple weeks back about the danger of little issues...
the foundation of this article was that every day we get interupted in ways that force
us to change what we're focused on, deal with an emergency, and then re-focus back
on the task at hand.
&lt;/p&gt;
&lt;p&gt;
This articule suggested that these "shifts" cause us to lose more time then if we
could just merrily work through one project at a time... makes sense, huh? &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
What's really interesting is that this article suggested that the LITTLE things actually
cause you more long-term grief than the big things. The reasoning was that when you
come across a big issue you learn in a big way... and subconsciously take action to
resolve it in the future. The problem with little issues is that they only take 1/2
an hour to resolve... and you become complacent in resolving them... twice a week...
for a year.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Why is this worth mentioning? Today while setting up for our NADA trade show (&lt;a href="http://www.nada.org"&gt;www.nada.org&lt;/a&gt;)
I ended up spending an hour trouble-shooting some file location issues on our demo
server. It's a stupid virtual-drive issue that only occurs in certain environments&amp;nbsp;and
generally takes me about an hour to figure out. 
&lt;/p&gt;
&lt;p&gt;
The trouble is that we've grown complacent in spending an hour on this issue... instead
of focusing on why we need a virtual-drive in the first place. If we'd reworked our
pathing a year ago, I wouldn't get bothered by this every few weeks.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Once you identify the "Little Issue" it's all about committing yourself to resolving
it... we're in mad-panic trade show mode right now so let's see what we can do after
we get back from San Francisco... 
&lt;/p&gt;
&lt;p&gt;
To be continued...
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=7a4dfdab-6567-49a6-b68f-1d2c1d1946e1" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,7a4dfdab-6567-49a6-b68f-1d2c1d1946e1.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=75327f08-0b76-4f7d-ac3b-cb8366a25862</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,75327f08-0b76-4f7d-ac3b-cb8366a25862.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,75327f08-0b76-4f7d-ac3b-cb8366a25862.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=75327f08-0b76-4f7d-ac3b-cb8366a25862</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I just found an outstanding configuration element inside of cruise control which allows
you to setup multiple projects to run in a queued environment. Basically it functions
as a mutex so that while one project is building all other projects go into a queue
until the first project is completed, and then another one is given control. The configuration
element is really easy, here's our ccnet.config...
</p>
        <p>
          <font size="1">&lt;cruisecontrol&gt;</font>
        </p>
        <p>
          <font size="1">  &lt;project name="Source Control" queue="ReleaseBuild"&gt;<br />
    &lt;workingDirectory&gt;C:\Projects\dvt-root&lt;/workingDirectory&gt;<br />
    &lt;triggers&gt;<br />
      &lt;intervalTrigger seconds="180" /&gt;<br />
    &lt;/triggers&gt;<br />
    &lt;modificationDelaySeconds&gt;10&lt;/modificationDelaySeconds&gt;<br />
    &lt;sourcecontrol type="vault" autoGetSource="true" applyLabel="false"&gt;<br />
      &lt;executable&gt;c:\program files\sourcegear\vault
client\vault.exe&lt;/executable&gt;<br />
      &lt;username&gt;BuildUserName&lt;/username&gt;<br />
      &lt;password&gt;BuildPassword&lt;/password&gt;<br />
      &lt;host&gt;myDevtServer&lt;/host&gt;<br />
      &lt;repository&gt;Evolution&lt;/repository&gt;<br />
      &lt;folder&gt;$/Dvt-Root&lt;/folder&gt;<br />
      &lt;useWorkingDirectory&gt;false&lt;/useWorkingDirectory&gt;<br />
      &lt;ssl&gt;False&lt;/ssl&gt;<br />
      &lt;setFileTime&gt;current&lt;/setFileTime&gt;<br />
    &lt;/sourcecontrol&gt;<br />
  &lt;/project&gt;</font>
        </p>
        <p>
          <font size="1">
          </font> 
</p>
        <p>
          <font size="1">  &lt;project name="Release Esenaar" queue="ReleaseBuild"&gt;<br />
    &lt;workingDirectory&gt;C:\Projects\dvt-root&lt;/workingDirectory&gt;<br />
    &lt;triggers&gt;<br />
      &lt;intervalTrigger seconds="180" /&gt;<br />
    &lt;/triggers&gt;<br />
    &lt;tasks&gt;<br />
       &lt;nant&gt;<br />
        &lt;baseDirectory&gt;&lt;/baseDirectory&gt;<br />
        &lt;buildArgs&gt;-D:debug=False&lt;/buildArgs&gt;<br />
        &lt;buildFile&gt;Release.Esenaar.Build&lt;/buildFile&gt;<br />
        &lt;buildTimeoutSeconds&gt;1200&lt;/buildTimeoutSeconds&gt;<br />
        &lt;targetList&gt;<br />
          &lt;target&gt;build&lt;/target&gt;<br />
        &lt;/targetList&gt;<br />
      &lt;/nant&gt;<br />
    &lt;/tasks&gt;<br />
  &lt;/project&gt;<br />
  
<br />
  &lt;project name="Release Duvel" queue="ReleaseBuild"&gt;<br />
    &lt;workingDirectory&gt;C:\Projects\dvt-root&lt;/workingDirectory&gt;<br />
    &lt;triggers&gt;<br />
      &lt;intervalTrigger seconds="180" /&gt;<br />
    &lt;/triggers&gt;<br />
    &lt;tasks&gt;<br />
       &lt;nant&gt;<br />
        &lt;baseDirectory&gt;&lt;/baseDirectory&gt;<br />
        &lt;buildArgs&gt;-D:debug=False&lt;/buildArgs&gt;<br />
        &lt;buildFile&gt;Release.Duvel.Build&lt;/buildFile&gt;<br />
        &lt;buildTimeoutSeconds&gt;1200&lt;/buildTimeoutSeconds&gt;<br />
        &lt;targetList&gt;<br />
          &lt;target&gt;build&lt;/target&gt;<br />
        &lt;/targetList&gt;<br />
      &lt;/nant&gt;<br />
    &lt;/tasks&gt;<br />
  &lt;/project&gt;</font>
        </p>
        <p>
          <font size="1">&lt;/cruisecontrol&gt;</font>
        </p>
        <p>
The first "project", called "Source Control" is actually responsible for downloading
all our code from SourceGear Vault. You can see that every 180 seconds it downloads
the source code from vault to a local folder called C:\Projects\dvt-root.
</p>
        <p>
The second and third projects, called "Duvel" and "Esenaar" (maintenance release names),
actually call out to our nant script and compile the appropriate release.
</p>
        <p>
Now, our primary goal with all this is to make sure that we don't pull down source
code while we're compiling a release (and vice versa) and that's where the queue property
on the project comes into play. By setting the queue on all three projects to be the
same thing, cruise control will not allow two projects to execute at the same time!
</p>
        <p>
          <a href="http://confluence.public.thoughtworks.org/display/CCNET/Project+Configuration+Block">http://confluence.public.thoughtworks.org/display/CCNET/Project+Configuration+Block</a>
        </p>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=75327f08-0b76-4f7d-ac3b-cb8366a25862" />
      </body>
      <title>Cruise Control .Net / Queued Building</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,75327f08-0b76-4f7d-ac3b-cb8366a25862.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2008/01/08/CruiseControlNetQueuedBuilding.aspx</link>
      <pubDate>Tue, 08 Jan 2008 01:40:02 GMT</pubDate>
      <description>&lt;p&gt;
I just found an outstanding configuration element inside of cruise control which allows
you to setup multiple projects to run in a queued environment. Basically it functions
as a mutex so that while one project is building all other projects go into a queue
until the first project is completed, and then another one is given control. The configuration
element is really easy, here's our ccnet.config...
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&amp;lt;cruisecontrol&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&amp;nbsp; &amp;lt;project name="Source Control" queue="ReleaseBuild"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;workingDirectory&amp;gt;C:\Projects\dvt-root&amp;lt;/workingDirectory&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;triggers&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;intervalTrigger seconds="180" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/triggers&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;modificationDelaySeconds&amp;gt;10&amp;lt;/modificationDelaySeconds&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sourcecontrol type="vault" autoGetSource="true" applyLabel="false"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;executable&amp;gt;c:\program files\sourcegear\vault
client\vault.exe&amp;lt;/executable&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;username&amp;gt;BuildUserName&amp;lt;/username&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;password&amp;gt;BuildPassword&amp;lt;/password&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;host&amp;gt;myDevtServer&amp;lt;/host&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;repository&amp;gt;Evolution&amp;lt;/repository&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;folder&amp;gt;$/Dvt-Root&amp;lt;/folder&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;useWorkingDirectory&amp;gt;false&amp;lt;/useWorkingDirectory&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ssl&amp;gt;False&amp;lt;/ssl&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;setFileTime&amp;gt;current&amp;lt;/setFileTime&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sourcecontrol&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/project&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&amp;nbsp; &amp;lt;project name="Release Esenaar" queue="ReleaseBuild"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;workingDirectory&amp;gt;C:\Projects\dvt-root&amp;lt;/workingDirectory&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;triggers&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;intervalTrigger seconds="180" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/triggers&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tasks&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;nant&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;baseDirectory&amp;gt;&amp;lt;/baseDirectory&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;buildArgs&amp;gt;-D:debug=False&amp;lt;/buildArgs&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;buildFile&amp;gt;Release.Esenaar.Build&amp;lt;/buildFile&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;buildTimeoutSeconds&amp;gt;1200&amp;lt;/buildTimeoutSeconds&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;targetList&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;target&amp;gt;build&amp;lt;/target&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/targetList&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/nant&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tasks&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/project&amp;gt;&lt;br&gt;
&amp;nbsp; 
&lt;br&gt;
&amp;nbsp; &amp;lt;project name="Release Duvel" queue="ReleaseBuild"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;workingDirectory&amp;gt;C:\Projects\dvt-root&amp;lt;/workingDirectory&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;triggers&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;intervalTrigger seconds="180" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/triggers&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tasks&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;nant&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;baseDirectory&amp;gt;&amp;lt;/baseDirectory&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;buildArgs&amp;gt;-D:debug=False&amp;lt;/buildArgs&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;buildFile&amp;gt;Release.Duvel.Build&amp;lt;/buildFile&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;buildTimeoutSeconds&amp;gt;1200&amp;lt;/buildTimeoutSeconds&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;targetList&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;target&amp;gt;build&amp;lt;/target&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/targetList&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/nant&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tasks&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/project&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&amp;lt;/cruisecontrol&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
The first "project", called "Source Control" is actually responsible for downloading
all our code from SourceGear Vault. You can see that every 180 seconds it downloads
the source code from vault to a local folder called C:\Projects\dvt-root.
&lt;/p&gt;
&lt;p&gt;
The second and third projects, called "Duvel" and "Esenaar" (maintenance release names),
actually call out to our nant script and compile the appropriate release.
&lt;/p&gt;
&lt;p&gt;
Now, our primary goal with all this is to make sure that we don't pull down source
code while we're compiling a release (and vice versa) and that's where the queue property
on the project comes into play. By setting the queue on all three projects to be the
same thing, cruise control will not allow two projects to execute at the same time!
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://confluence.public.thoughtworks.org/display/CCNET/Project+Configuration+Block"&gt;http://confluence.public.thoughtworks.org/display/CCNET/Project+Configuration+Block&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=75327f08-0b76-4f7d-ac3b-cb8366a25862" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,75327f08-0b76-4f7d-ac3b-cb8366a25862.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=ea1dea83-8300-4bb0-a04b-4a8a38265919</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,ea1dea83-8300-4bb0-a04b-4a8a38265919.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,ea1dea83-8300-4bb0-a04b-4a8a38265919.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=ea1dea83-8300-4bb0-a04b-4a8a38265919</wfw:commentRss>
      <slash:comments>8</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">As part of our ongoing eSignature rollout
we found that a smattering of client machines have issues when attempting to load
the SigPlusNet.dll. 
<p>
This dll is basically our interface to the signature pad itself and would fail with
a FileNotFoundException. What was really strange was that the exception contained
no information about the file it was trying to load. In addition, 95% of clients worked
fine the first time. On the remaining 5% as soon as we started troubleshooting by
installing Windows Updates or any other sample apps the error would simply go away.
</p><p>
After using a great little tool called FileMon (<a href="http://www.sysinternals.com">www.sysinternals.com</a>)
I found that the SigPlusNet.dll was failing on an attempt to find and load msvcr71.dll.
Apparently msvcr71.dll is basically a set of C style application methods that are
somehow used internally by SigPlusNet. Since this dll is pretty common it appears
that on most machines it's installed by something else and so that's why on 95% of
machines we had no issues.
</p><p>
Once I modified the install to include this dll, life is wonderful. A very strange
unexpected dependancy...
</p><p>
 
</p><img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=ea1dea83-8300-4bb0-a04b-4a8a38265919" /></body>
      <title>SigPlusNet Missing Module Exception</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,ea1dea83-8300-4bb0-a04b-4a8a38265919.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2007/12/31/SigPlusNetMissingModuleException.aspx</link>
      <pubDate>Mon, 31 Dec 2007 17:13:52 GMT</pubDate>
      <description>As part of our ongoing eSignature rollout we found that a smattering of client machines have issues when attempting to load the SigPlusNet.dll. 
&lt;p&gt;
This dll is basically our interface to the signature pad itself and would fail with
a FileNotFoundException. What was really strange was that the exception contained
no information about the file it was trying to load. In addition, 95% of clients worked
fine the first time. On the remaining 5% as soon as we started troubleshooting by
installing Windows Updates or any other sample apps the error would simply go away.
&lt;/p&gt;
&lt;p&gt;
After using a great little tool called FileMon (&lt;a href="http://www.sysinternals.com"&gt;www.sysinternals.com&lt;/a&gt;)
I found that the SigPlusNet.dll was failing on an attempt to find and load msvcr71.dll.
Apparently msvcr71.dll is basically a set of C style application methods that are
somehow used internally by SigPlusNet. Since this dll is pretty common it appears
that on most machines it's installed by something else and so that's why on 95% of
machines we had no issues.
&lt;/p&gt;
&lt;p&gt;
Once I modified the install to include this dll, life is wonderful. A very strange
unexpected dependancy...
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=ea1dea83-8300-4bb0-a04b-4a8a38265919" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,ea1dea83-8300-4bb0-a04b-4a8a38265919.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=778b838f-9269-4f7a-834c-379fa96ac243</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,778b838f-9269-4f7a-834c-379fa96ac243.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,778b838f-9269-4f7a-834c-379fa96ac243.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=778b838f-9269-4f7a-834c-379fa96ac243</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In our most recent release of Aristo Contact Management we've added support for a
USB Drivers License Scanner. The basis of this project is that we connect this scanner
to the local pc, integrate it into our customer screen, and then use the scanner to
read customer information.
</p>
        <p>
          <img src="http://www.bradleysblog.net/blog/content/binary/acm-license-scanner.jpg" border="0" />
        </p>
        <p>
We've tried to make this a very simple process... after the user selects the Scan
button the reader will whir and buzz as it attempts to pull information from the license.
The reader itself accomplishes this by taking a picture of the license and then using
text recognition (OCR) to separate the license into different fields we can populate
our customer record with. 
</p>
        <p>
Once we read this information it automatically updates into the appropriate fields
on our screen. In addition, because we're taking a picture of the license, we can
also attempt to save a picture of the customer IF the regional license supports it.
</p>
        <p>
          <img src="http://www.bradleysblog.net/blog/content/binary/acm-license-ui.jpg" border="0" />
        </p>
        <p>
At this point we support Canadian and US licenses and pull Name, Address, License
and expiry fields. 
</p>
        <p>
Now, as a promotion for the first 5 clients who email me (and use Aristo Accounting
and Contact Management) we're going to send you a drivers license scanner free! Quantities
are limited so drop me an email at <a href="mailto:freeScanner@pbssystems.com">freeScanner@pbssystems.com</a> and
we'll contact the winners.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=778b838f-9269-4f7a-834c-379fa96ac243" />
      </body>
      <title>Drivers License Scanner</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,778b838f-9269-4f7a-834c-379fa96ac243.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2007/11/09/DriversLicenseScanner.aspx</link>
      <pubDate>Fri, 09 Nov 2007 16:56:12 GMT</pubDate>
      <description>&lt;p&gt;
In our most recent release of Aristo Contact Management we've added support for a
USB Drivers License Scanner. The basis of this project is that we connect this scanner
to the local pc, integrate it into our customer screen, and then use the scanner to
read customer information.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/acm-license-scanner.jpg" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
We've tried to make this a very simple process... after the user selects the Scan
button the reader will whir and buzz as it attempts to pull information from the license.
The reader itself accomplishes this by taking a picture of the license and then using
text recognition (OCR) to separate the license into different fields we can populate
our customer record with. 
&lt;/p&gt;
&lt;p&gt;
Once we read this information it automatically updates into the appropriate fields
on our screen. In addition, because we're taking a picture of the license, we can
also attempt to save a picture of the customer IF the regional license supports it.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/acm-license-ui.jpg" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
At this point we support Canadian and US licenses and pull Name, Address, License
and expiry fields. 
&lt;/p&gt;
&lt;p&gt;
Now, as a promotion for the first 5 clients who email me (and use Aristo Accounting
and Contact Management) we're going to send you a drivers license scanner free! Quantities
are limited so drop me an email at &lt;a href="mailto:freeScanner@pbssystems.com"&gt;freeScanner@pbssystems.com&lt;/a&gt; and
we'll contact the winners.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=778b838f-9269-4f7a-834c-379fa96ac243" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,778b838f-9269-4f7a-834c-379fa96ac243.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=efafd3a8-4f39-4810-9a12-1848af74d07c</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,efafd3a8-4f39-4810-9a12-1848af74d07c.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,efafd3a8-4f39-4810-9a12-1848af74d07c.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=efafd3a8-4f39-4810-9a12-1848af74d07c</wfw:commentRss>
      <title>Enhanced eSignature Changes</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,efafd3a8-4f39-4810-9a12-1848af74d07c.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2007/09/18/EnhancedESignatureChanges.aspx</link>
      <pubDate>Tue, 18 Sep 2007 17:12:56 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;With eSignature rolling into larger beta it
was time to address some flexibility concerns that had come up at our second pilot&amp;nbsp;store.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Their chief problem was that when they took
a signature on a Hard Copy they wanted the software to automatically print two copies
at two different printers - one at the Service Counter (for the customer to take home)
and one at the back counter (for the technicians). With our first version of eSignature
this was awkward because the user was given one prompting screen and would need to
use the "print" dialog twice - pretty difficult in a fast paced retail environment.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;So... while we were out at our annual dealer
conference last week I bounced this idea around with a couple service managers. We
came up with the idea of "Document Actions". The idea is that eSignature already managed
the layout of the document, it's not that big a stretch to allow it to also manage
WHAT we do with the document once we have it. If we allow our document management
infrastructure to take care of this we can specify that this document should be printed
on Printer A, then printed on Printer B, and finally reviewed with Printer C. The
flexibility can all be managed in our Document Layout interface and tailored to the
dealerships processes.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/eSig-v2-foto.jpg" border=0&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Finally it's worth noting that all this new
Document Management is only kicked off if you "Enable Document Management" for that
specific document type. Once that checkbox is enabled the background, signature capture,
and printing is all handled by eSignature - the existing printing control in Service
is totally ignored.&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=efafd3a8-4f39-4810-9a12-1848af74d07c" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,efafd3a8-4f39-4810-9a12-1848af74d07c.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=c9071014-fcad-486a-976e-c1112b927e8a</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,c9071014-fcad-486a-976e-c1112b927e8a.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,c9071014-fcad-486a-976e-c1112b927e8a.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=c9071014-fcad-486a-976e-c1112b927e8a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Just overcome an extremely challenging problem we've been having. Our COM application
was calling out to a dot net assembly through COM Interop and when the dot net assembly
returned a response the process would get terminated... no friendly output, error
messages, or log entries - just dead.
</p>
        <p>
The solution was to totally REMOVE the Dot Net 2.0 framework and re-install. We tried
a REPAIR first but that didn't seem to do anything.
</p>
        <p>
It's worth mentioning that the problem didn't occur when calling into the dot net
assembly but rather when it returned something to VB6... very strange.
</p>
        <p>
Anyway, strike another issue off the project wall. Time to move back on to Prospecting!
</p>
        <p>
          <strong>Addendum&gt; Apparently this issue is caused by one of the Dot Net 2.0 Security
Updates from Windows Update! For now we're avoiding this patch.</strong>
        </p>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=c9071014-fcad-486a-976e-c1112b927e8a" />
      </body>
      <title>Dot Net / COM Interop Issues</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,c9071014-fcad-486a-976e-c1112b927e8a.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2007/08/15/DotNetCOMInteropIssues.aspx</link>
      <pubDate>Wed, 15 Aug 2007 02:19:33 GMT</pubDate>
      <description>&lt;p&gt;
Just overcome an extremely challenging problem we've been having. Our COM application
was calling out to a dot net assembly through COM Interop and when the dot net assembly
returned a response the process would get terminated... no friendly output, error
messages, or log entries - just dead.
&lt;/p&gt;
&lt;p&gt;
The solution was to totally REMOVE the Dot Net 2.0 framework and re-install. We tried
a REPAIR first but that didn't seem to do anything.
&lt;/p&gt;
&lt;p&gt;
It's worth mentioning that the problem didn't occur when calling into the dot net
assembly but rather when it returned something to VB6... very strange.
&lt;/p&gt;
&lt;p&gt;
Anyway, strike another issue off&amp;nbsp;the project wall. Time to move back on to Prospecting!
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Addendum&amp;gt; Apparently this issue is caused by one of the Dot Net 2.0 Security
Updates from Windows Update! For now we're avoiding this patch.&lt;/strong&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=c9071014-fcad-486a-976e-c1112b927e8a" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,c9071014-fcad-486a-976e-c1112b927e8a.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=8ba58156-de55-4758-8cc1-04db3fa332ea</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,8ba58156-de55-4758-8cc1-04db3fa332ea.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,8ba58156-de55-4758-8cc1-04db3fa332ea.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=8ba58156-de55-4758-8cc1-04db3fa332ea</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Yesterday we installed Aristo Vehicle Managment into Alpha at a dealership here in
Calgary. We'll be working with them over the next few weeks to iron out any wrinkles as
we continue to push forward on our Aristo Front End project. Couple highlights...
</p>
        <p>
A true common vehicle file (which provides for some extremely powerful and concise
search capabilities)...
</p>
        <p>
          <img src="http://www.bradleysblog.net/blog/content/binary/avm-search.jpg" border="0" />
        </p>
        <p>
The tree in the top-right corner allows searching by vehicle type according to Make,
Model, and Trim level. This search is hierarchical so you can search for any type
of unit. We also support search for specific unit types, options, pricing, or even
across vehicles that have been sold to customers for potential lease returns.
</p>
        <p>
 
</p>
        <p>
We've also completed an integrated vehicle screen accessible from all modules. This
screen allows all departments to have the same view of a vehicle complete with all
vehicle history.
</p>
        <p>
          <img src="http://www.bradleysblog.net/blog/content/binary/avm-mainUi.jpg" border="0" />
        </p>
        <p>
This common UI means that given the right security a user can review and edit any
information of a vehicle by selecting the correct View in the top right hand corner.
Vehicle history is reported down the right side of the screen and allows immediate
access to any "event" (such as a Repair Order or Sales Rep Hold) which has affected
this unit. 
</p>
        <p>
 
</p>
        <p>
This project will be the foundation for our further work on Front End and provides
a major step forward on the Aristo Front End project.
</p>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=8ba58156-de55-4758-8cc1-04db3fa332ea" />
      </body>
      <title>Aristo Vehicle Management (Alpha)</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,8ba58156-de55-4758-8cc1-04db3fa332ea.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2007/08/10/AristoVehicleManagementAlpha.aspx</link>
      <pubDate>Fri, 10 Aug 2007 22:53:18 GMT</pubDate>
      <description>&lt;p&gt;
Yesterday we installed Aristo Vehicle Managment into Alpha at a dealership here in
Calgary. We'll be working with them over the next few weeks to iron out any wrinkles&amp;nbsp;as
we continue to push forward on our Aristo Front End project. Couple highlights...
&lt;/p&gt;
&lt;p&gt;
A true common vehicle file (which provides for some extremely powerful and concise
search capabilities)...
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/avm-search.jpg" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
The tree in the top-right corner allows searching by vehicle type according to Make,
Model, and Trim level. This search is hierarchical so you can search for any type
of unit. We also support search for specific unit types, options, pricing, or even
across vehicles that have been sold to customers for potential lease returns.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
We've also completed an integrated vehicle screen accessible from all modules. This
screen allows all departments to have the same view of a vehicle complete with all
vehicle history.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.bradleysblog.net/blog/content/binary/avm-mainUi.jpg" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
This common UI means that given the right security a user can review and edit any
information of a vehicle by selecting the correct View in the top right hand corner.
Vehicle history is reported down the right side of the screen and allows immediate
access to any "event" (such as a Repair Order or Sales Rep Hold) which has affected
this unit. 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
This project will be the foundation for our further work on Front End and provides
a major step forward on the Aristo Front End project.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=8ba58156-de55-4758-8cc1-04db3fa332ea" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,8ba58156-de55-4758-8cc1-04db3fa332ea.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=bd2866a5-a0f4-4c79-a9a4-7989fc702acd</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,bd2866a5-a0f4-4c79-a9a4-7989fc702acd.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,bd2866a5-a0f4-4c79-a9a4-7989fc702acd.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=bd2866a5-a0f4-4c79-a9a4-7989fc702acd</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Our Front End Aristo project is going to be managed by what we call a Product Team.
A Product Team is basically three individuals who will make it their top priority
to achieve deployment of the Aristo Front End application. Each of these individuals
has an inherent goal for the project and by working together as a team will come to
a consensus on these goals. The Team is made up of the following...
</p>
        <p>
Strategic Product Manager (Dave)
</p>
        <p>
The Strategic Product Manager is responsible for understanding what the market demands
of the product. It is their responsibility to understand business cases, market requirements,
as well as scheduling demands.
</p>
        <p>
Technical Product Manager (Chris)
</p>
        <p>
The Technical Product Manager works to understand what can be built in what amount
of time to satisfy the market demands. Their responsibility is to help estimate project
timelines and to ensure project milestones are accomplished.
</p>
        <p>
Sales Product Manager (Pat C)
</p>
        <p>
The Sales Product Manager focuses on understanding how the product will be received
by the market. Their responsibility is to be THE product expert, to act as a sales
and installation resource, and to create excitement around the product.
</p>
        <p>
 
</p>
        <p>
Starting asap we're going to convene the Product Team daily for 1 hour - no longer
- to discuss the finer requirements for this project. Based on these meetings
we will create a project schedule defining which features will be implemented in which
iteration. Our schedule will be have five 1-week iterations with our Front End module
ready for install by the end of our final iteration.
</p>
        <p>
It's an exciting time for this project; by having three resources each focusing on
their specific "needs" for this project we should have faster completion, more complete
requirements, and a more exciting product release.
</p>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=bd2866a5-a0f4-4c79-a9a4-7989fc702acd" />
      </body>
      <title>Software Development Plan</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,bd2866a5-a0f4-4c79-a9a4-7989fc702acd.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2007/07/24/SoftwareDevelopmentPlan.aspx</link>
      <pubDate>Tue, 24 Jul 2007 04:28:20 GMT</pubDate>
      <description>&lt;p&gt;
Our Front End Aristo project is going to be managed by what we call a Product Team.
A Product Team is basically three individuals who will make it their top priority
to achieve deployment of the Aristo Front End application.&amp;nbsp;Each of these individuals
has an inherent goal for the project and by working together as a team will come to
a consensus on these goals. The Team is made up of the following...
&lt;/p&gt;
&lt;p&gt;
Strategic Product Manager (Dave)
&lt;/p&gt;
&lt;p&gt;
The Strategic Product Manager is responsible for understanding what the market demands
of the product. It is their responsibility to understand business cases, market requirements,
as well as scheduling demands.
&lt;/p&gt;
&lt;p&gt;
Technical Product Manager (Chris)
&lt;/p&gt;
&lt;p&gt;
The Technical Product Manager works to understand what can be built in what amount
of time to satisfy the market demands. Their responsibility is to help estimate project
timelines and to ensure project milestones are accomplished.
&lt;/p&gt;
&lt;p&gt;
Sales Product Manager (Pat C)
&lt;/p&gt;
&lt;p&gt;
The Sales Product Manager focuses on understanding how the product will be received
by the market. Their responsibility is to be THE product expert, to act as a&amp;nbsp;sales
and installation resource, and to create excitement around the product.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Starting asap we're going to convene the Product Team daily for 1 hour - no longer
- to discuss&amp;nbsp;the finer requirements for this project. Based on these meetings
we will create a project schedule defining which features will be implemented in which
iteration. Our schedule will be have five 1-week iterations with our Front End module
ready for install by the end of our final iteration.
&lt;/p&gt;
&lt;p&gt;
It's an exciting time for this project; by having three resources each focusing on
their specific "needs" for this project we should have faster completion, more complete
requirements, and a more exciting product release.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=bd2866a5-a0f4-4c79-a9a4-7989fc702acd" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,bd2866a5-a0f4-4c79-a9a4-7989fc702acd.aspx</comments>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.bradleysblog.net/Blog/Trackback.aspx?guid=da2930d7-2b57-4e4a-a627-604ede787fdf</trackback:ping>
      <pingback:server>http://www.bradleysblog.net/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.bradleysblog.net/Blog/PermaLink,guid,da2930d7-2b57-4e4a-a627-604ede787fdf.aspx</pingback:target>
      <dc:creator>chris.bradley</dc:creator>
      <wfw:comment>http://www.bradleysblog.net/Blog/CommentView,guid,da2930d7-2b57-4e4a-a627-604ede787fdf.aspx</wfw:comment>
      <wfw:commentRss>http://www.bradleysblog.net/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=da2930d7-2b57-4e4a-a627-604ede787fdf</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Over the past 6 months we've seen a certain emergence of application knowledge in
our framework that I'm not entirely sure I understand. Assemblies such as SOA
and TitaniumDataAccess provide extremely usefull functionality but are deeply
rooted in a number of applications which makes you wonder on how much they really
should be in framework... after all Framework is about more than adding
an assembly reference and having intellisense.
</p>
        <p>
One area that has shown promise is the factory-style interface structure used
in eSignature. We build our... ahem... ServiceContract assembly - which has no Framework
references - inside the module, then copy the pre-compiled assembly to our consumer
module, hard-referencing it. At runtime we create a module instruction which says,
register this interface ICustomer with this class.
</p>
        <p>
There are a couple of benefits to this style of communication. First, our current
message based soa is pretty procedural, an interface based soa is more Object-Oriented
which should make cross-module communication easier to use; think about the "conversationId"
parameters we've had to add to ContactServices. Secondly, because this feels more
Object-Oriented, it's easier to explain this type of communication to developers.
Finally, it's easier to create mock handlers for our unit tests.
</p>
        <p>
The only down-side is how do you introduce something like this without destroying
our current communication scheme and blowing away advent integration. The only real
feasible way is to attempt to use it in a "limited" mode with one module, maybe across
the sales module in our next service pack.
</p>
        <p>
 
</p>
        <p>
One other idea would be to have the modules define their own resource strings and
images with a similar "initialization" instruction. That way your globalization dll
could change very little and if an invalid resource is requested it could return a
"no smoking sign" and not break the module.
</p>
        <p>
 
</p>
        <p>
Couple big changes but worth looking at for future development.
</p>
        <img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=da2930d7-2b57-4e4a-a627-604ede787fdf" />
      </body>
      <title>Musings on Framework</title>
      <guid isPermaLink="false">http://www.bradleysblog.net/Blog/PermaLink,guid,da2930d7-2b57-4e4a-a627-604ede787fdf.aspx</guid>
      <link>http://www.bradleysblog.net/Blog/2007/05/08/MusingsOnFramework.aspx</link>
      <pubDate>Tue, 08 May 2007 09:53:14 GMT</pubDate>
      <description>&lt;p&gt;
Over the past 6 months we've seen a certain emergence of application knowledge in
our framework that I'm not entirely sure I understand.&amp;nbsp;Assemblies such as SOA
and TitaniumDataAccess provide extremely usefull&amp;nbsp;functionality but are deeply
rooted in a number of applications which makes you wonder on&amp;nbsp;how much they really
should be in framework... after all&amp;nbsp;Framework is about more than&amp;nbsp;adding
an assembly&amp;nbsp;reference and having intellisense.
&lt;/p&gt;
&lt;p&gt;
One area that has shown promise&amp;nbsp;is the factory-style interface structure used
in eSignature. We build our... ahem... ServiceContract assembly - which has no Framework
references - inside the module, then copy the pre-compiled assembly to our consumer
module, hard-referencing it. At runtime we create a module instruction which says,
register this interface ICustomer with this class.
&lt;/p&gt;
&lt;p&gt;
There are a couple of&amp;nbsp;benefits to this style of communication. First, our current
message based soa is pretty procedural, an interface based soa is more Object-Oriented
which should make cross-module communication easier to use; think about the "conversationId"
parameters we've had to add to ContactServices. Secondly, because this feels more
Object-Oriented, it's easier to explain this type of communication to developers.
Finally, it's easier to create mock handlers for our unit tests.
&lt;/p&gt;
&lt;p&gt;
The only down-side is how do you introduce something like this without destroying
our current communication scheme and blowing away advent integration. The only real
feasible way is to attempt to use it in a "limited" mode with one module, maybe across
the sales module in our next service pack.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
One other idea would be to have the modules define their own resource strings and
images with a similar "initialization" instruction. That way your globalization dll
could change very little and if an invalid resource is requested it could return a
"no smoking sign" and not break the module.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Couple big changes but worth looking at for future development.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.bradleysblog.net/Blog/aggbug.ashx?id=da2930d7-2b57-4e4a-a627-604ede787fdf" /&gt;</description>
      <comments>http://www.bradleysblog.net/Blog/CommentView,guid,da2930d7-2b57-4e4a-a627-604ede787fdf.aspx</comments>
      <category>Technical</category>
    </item>
  </channel>
</rss>