<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>Techie</title><link>http://blogs.vbcity.com/drydo/category/72.aspx</link><description>Anything IT related</description><managingEditor>Mark Dryden</managingEditor><dc:language>en-GB</dc:language><generator>.Text Version 0.95.2004.102</generator><item><dc:creator>Mark Dryden</dc:creator><title>Getting Expression Blend to open an Image in Fireworks / Photoshop, etc.</title><link>http://blogs.vbcity.com/drydo/archive/2008/04/23/9050.aspx</link><pubDate>Wed, 23 Apr 2008 13:34:00 GMT</pubDate><guid>http://blogs.vbcity.com/drydo/archive/2008/04/23/9050.aspx</guid><wfw:comment>http://blogs.vbcity.com/drydo/comments/9050.aspx</wfw:comment><comments>http://blogs.vbcity.com/drydo/archive/2008/04/23/9050.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.vbcity.com/drydo/comments/commentRss/9050.aspx</wfw:commentRss><trackback:ping>http://blogs.vbcity.com/drydo/services/trackbacks/9050.aspx</trackback:ping><description>&lt;p&gt;So firing up Expression Blend and getting into the whole WPF thing is always a refreshing change, especially getting away from mundane coding and alike.  However, the first thing to trip me up and my colleague up was using the "Edit Externally" command from the project view to edit an existing '.png' file and whipping into my favourite graphics editor.  Imagine my surprise when I was greeted with MSPaint!  How there are two things to consider here...&lt;/p&gt;

&lt;p&gt;
&lt;ol&gt;
&lt;li&gt;I used to be a design guy prior to becoming a programmer, so MSPaint is the last thing I need to see.&lt;/li&gt;
&lt;li&gt;Two - MSPaint is in no way anything like a sophisticated design application.  Just get used to it ;-)&lt;/li&gt;
&lt;/ol&gt;
&lt;/p&gt;

&lt;p&gt;Now the doomsayers and conspiracy freaks might consider that MS has done this on purpose, so I fired up Reflector to work out how the project items (such as image files) were actually being catagorised and executed.  What Blend does is by using the old .NET standby of Process.Start but explicitly passing through the 'Edit' string as the 'Verb' when making the call.  In short, they're letting explorer handle the file association.  Note: this works differently from explorer where if you double-click an existing and recognised dot extension it fires up the application with the selected file because its using the 'Open' verb and not the 'Edit' verb.&lt;/p&gt;

&lt;p&gt;Ideally, Blend should use the 'Open' verb rather than hardcoding the 'Edit' verb (well, selection that is then implemented in the EditExternalCommand object) into the 'DocumentType.PreferredExternalEditCommand' property.  Or even better - allow the user to specify those application they want for editing resources.  But hey, its version 1.&lt;/p&gt;

&lt;p&gt;So to get around this, a quick registry tweak will get things working.  Navigate to the key...&lt;/p&gt;

&lt;p&gt;HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit\command&lt;/p&gt;

&lt;p&gt;...and change the value of the '(Default)' value to your favourite package from...&lt;/p&gt;

&lt;p&gt;"%systemroot%\system32\mspaint.exe" "%1"&lt;/p&gt;

&lt;p&gt;...to &lt;your package name and argument&gt;, so in my case to Fireworks...&lt;/p&gt;

&lt;p&gt;"C:\Program Files\Macromedia\Fireworks 8\Fireworks.exe" "%1"&lt;/p&gt;

&lt;p&gt;...and job done + no need restart...&lt;/p&gt;

&lt;p&gt;HTH - And remember this fix / hack comes without warranty and will effect other instances where applications use this key as well.  In short, be careful and backup your registry before doing this.&lt;/p&gt;&lt;img src ="http://blogs.vbcity.com/drydo/aggbug/9050.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Mark Dryden</dc:creator><title>System.Net.Mail.SmtpClient not sending until the application exits</title><link>http://blogs.vbcity.com/drydo/archive/2008/03/26/9006.aspx</link><pubDate>Wed, 26 Mar 2008 16:07:00 GMT</pubDate><guid>http://blogs.vbcity.com/drydo/archive/2008/03/26/9006.aspx</guid><wfw:comment>http://blogs.vbcity.com/drydo/comments/9006.aspx</wfw:comment><comments>http://blogs.vbcity.com/drydo/archive/2008/03/26/9006.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.vbcity.com/drydo/comments/commentRss/9006.aspx</wfw:commentRss><trackback:ping>http://blogs.vbcity.com/drydo/services/trackbacks/9006.aspx</trackback:ping><description>&lt;p&gt;A very quick one.  Been playing with the above class for generating emails in .NET 2.0, embedding images within HTML views which is rather cool.  However, I noticed an unusual problem.  The emails I generated in my test project would not send until I had exited the application.  It was almost like it would only 'flush' the generated email once the application had unloaded.  Interestingly, if I attempted to send the email using the 'SendAsync' method, it would fire the SendCompleted event but still nothing would come through until the application had ended.&lt;/p&gt;

&lt;p&gt;The resolution?  Turning off Symantec Anti-Virus's 'Internet Email Auto-Protect' facility from the 'Configure' menu.  Once deselected, everything started behaving properly.  &lt;/p&gt;

&lt;p&gt;I cannot answer for any other AntiVirus packages - but its a good starting point if you're experiencing the above.&lt;/p&gt;

&lt;p&gt;M&lt;/p&gt;&lt;img src ="http://blogs.vbcity.com/drydo/aggbug/9006.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Mark Dryden</dc:creator><title>Disabling Flash (AxShockwaveFlash) Right-Click Context Menu</title><link>http://blogs.vbcity.com/drydo/archive/2008/03/03/8991.aspx</link><pubDate>Mon, 03 Mar 2008 16:42:00 GMT</pubDate><guid>http://blogs.vbcity.com/drydo/archive/2008/03/03/8991.aspx</guid><wfw:comment>http://blogs.vbcity.com/drydo/comments/8991.aspx</wfw:comment><comments>http://blogs.vbcity.com/drydo/archive/2008/03/03/8991.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.vbcity.com/drydo/comments/commentRss/8991.aspx</wfw:commentRss><trackback:ping>http://blogs.vbcity.com/drydo/services/trackbacks/8991.aspx</trackback:ping><description>&lt;p&gt;To be quite frank, after 3 months of ASP.NET development, the opportunity to do some down and dirty API programming really appealled to me today.  So, the question (as indicated by the title) involved a member wanting to disable the right-click context menu from the Flash ActiveX component when being used in a WinForms application.  (See previous blog entries for examples of Flash in VB.NET and communication between the two such as &lt;a href="http://blogs.vbcity.com/drydo/archive/2005/10/18/5586.aspx"&gt;http://blogs.vbcity.com/drydo/archive/2005/10/18/5586.aspx&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;The simple answer is to capture the right-click of the Flash Window itself and prevent it from being processed.  A little play with Spy++ quickly came up with the answers and the rest was all about good old fashioned subclassing.  I must admit it pinched the API declarations from Pinvoke.net and smartened them up a tad and that is pretty much it.&lt;/p&gt;

&lt;p&gt;For the record, this is something I've been meaning to do for a while + I can leave work not feeling like some CSS floozy :)&lt;/p&gt;

&lt;p&gt;Note: to recreate, create one form, one button and add one Flash Active X control.  Copy and Paste as necessary.  Tested in VS2005.  If you get the dreaded 'Failed to import the ActiveX control' message, check out this &lt;a href="http://blogs.vbcity.com/drydo/archive/2005/12/07/5731.aspx"&gt;workaround&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
&lt;style&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: Consolas, "Courier New", Courier, Monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}

.csharpcode pre { margin: 0em; }

.csharpcode .rem { color: #008000; }

.csharpcode .kwrd { color: #0000ff; }

.csharpcode .str { color: #006080; }

.csharpcode .op { color: #0000c0; }

.csharpcode .preproc { color: #cc6633; }

.csharpcode .asp { background-color: #ffff00; }

.csharpcode .html { color: #800000; }

.csharpcode .attr { color: #ff0000; }

.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}

.csharpcode .lnum { color: #606060; }

&lt;/style&gt;

&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
&lt;pre class="csharpcode"&gt;
&lt;span class="kwrd"&gt;Imports&lt;/span&gt; System.Runtime.InteropServices

&lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Class&lt;/span&gt; Form1

&lt;span class="preproc"&gt;#Region&lt;/span&gt; &lt;span class="str"&gt;"API Routines"&lt;/span&gt;

    &amp;lt;DllImport(&lt;span class="str"&gt;"User32.dll"&lt;/span&gt;)&amp;gt; _
   &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Shared&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt; EnumChildWindows _
       (&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; WindowHandle &lt;span class="kwrd"&gt;As&lt;/span&gt; IntPtr, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; Callback &lt;span class="kwrd"&gt;As&lt;/span&gt; EnumWindowProcess, _
       &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; lParam &lt;span class="kwrd"&gt;As&lt;/span&gt; IntPtr) &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt;

    &amp;lt;DllImport(&lt;span class="str"&gt;"user32.dll"&lt;/span&gt;, CharSet:=CharSet.&lt;span class="kwrd"&gt;Auto&lt;/span&gt;)&amp;gt; _
&lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Shared&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; GetClassName(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; hWnd &lt;span class="kwrd"&gt;As&lt;/span&gt; System.IntPtr, _
   &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; lpClassName &lt;span class="kwrd"&gt;As&lt;/span&gt; System.Text.StringBuilder, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; nMaxCount &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;)
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;

    &amp;lt;DllImport(&lt;span class="str"&gt;"user32.dll"&lt;/span&gt;, CharSet:=CharSet.&lt;span class="kwrd"&gt;Auto&lt;/span&gt;)&amp;gt; _
    &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Overloads&lt;/span&gt; &lt;span class="kwrd"&gt;Shared&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt; SetWindowLong(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; hWnd &lt;span class="kwrd"&gt;As&lt;/span&gt; IntPtr, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt;&lt;br /&gt; nIndex &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; dwNewLong &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;) &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt;

    &amp;lt;DllImport(&lt;span class="str"&gt;"user32.dll"&lt;/span&gt;, CharSet:=CharSet.&lt;span class="kwrd"&gt;Auto&lt;/span&gt;)&amp;gt; _
    &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Overloads&lt;/span&gt; &lt;span class="kwrd"&gt;Shared&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt; SetWindowLong(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; hWnd &lt;span class="kwrd"&gt;As&lt;/span&gt; IntPtr, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt;&lt;br /&gt; nIndex &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; dwNewLong &lt;span class="kwrd"&gt;As&lt;/span&gt; FlashCaptureRoutine) &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt;

    &amp;lt;DllImport(&lt;span class="str"&gt;"user32.dll"&lt;/span&gt;, CharSet:=CharSet.&lt;span class="kwrd"&gt;Auto&lt;/span&gt;)&amp;gt; _
     &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Shared&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt; CallWindowProc(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; lpPrevWndFunc &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt;&lt;br /&gt; hWnd &lt;span class="kwrd"&gt;As&lt;/span&gt; IntPtr, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; Msg &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; wParam &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; lParam &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;) &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt;

&lt;span class="preproc"&gt;#End Region&lt;/span&gt;

&lt;span class="preproc"&gt;#Region&lt;/span&gt; &lt;span class="str"&gt;"Delegates"&lt;/span&gt;

    &lt;span class="rem"&gt;' Used for processing Flash Window messages&lt;/span&gt;
    &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Delegate&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt; FlashCaptureRoutine(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; hwnd &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt;&lt;br /&gt; Msg &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; wParam &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; lParam &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;) &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;

    &lt;span class="rem"&gt;' Used for enumerating child windows&lt;/span&gt;
    &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Delegate&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt; EnumWindowProcess(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; Handle &lt;span class="kwrd"&gt;As&lt;/span&gt; IntPtr, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; Parameter &lt;span class="kwrd"&gt;As&lt;/span&gt; IntPtr) &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;

&lt;span class="preproc"&gt;#End Region&lt;/span&gt;

    &lt;span class="rem"&gt;' Constants&lt;/span&gt;
    &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Const&lt;/span&gt; GWL_WNDPROC &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt; = (-4)
    &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Const&lt;/span&gt; WM_ENTERMENULOOP &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt; = &amp;amp;H211
    &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Const&lt;/span&gt; WM_RBUTTONDOWN &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt; = &amp;amp;H204
    &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Const&lt;/span&gt; WM_INITMENU = &amp;amp;H116

    &lt;span class="rem"&gt;' Private vars&lt;/span&gt;
    &lt;span class="kwrd"&gt;Private&lt;/span&gt; mFlashWindowHandle &lt;span class="kwrd"&gt;As&lt;/span&gt; IntPtr
    &lt;span class="kwrd"&gt;Private&lt;/span&gt; mPreviousHandle &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;
    &lt;span class="kwrd"&gt;Private&lt;/span&gt; isCapturing &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;

    &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; Form1_FormClosing(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; sender &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Object&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; &lt;br /&gt;e &lt;span class="kwrd"&gt;As&lt;/span&gt; System.Windows.Forms.FormClosingEventArgs) &lt;span class="kwrd"&gt;Handles&lt;/span&gt; &lt;span class="kwrd"&gt;Me&lt;/span&gt;.FormClosing
        &lt;span class="rem"&gt;' Cleanup if appropriate&lt;/span&gt;
        &lt;span class="kwrd"&gt;If&lt;/span&gt; isCapturing &lt;span class="kwrd"&gt;Then&lt;/span&gt; CleanupCapture()
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;

    &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; Form1_Load(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; sender &lt;span class="kwrd"&gt;As&lt;/span&gt; System.&lt;span class="kwrd"&gt;Object&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; &lt;br /&gt;e &lt;span class="kwrd"&gt;As&lt;/span&gt; System.EventArgs) &lt;span class="kwrd"&gt;Handles&lt;/span&gt; &lt;span class="kwrd"&gt;MyBase&lt;/span&gt;.Load
        &lt;span class="rem"&gt;' Load the test movie...&lt;/span&gt;
        &lt;span class="kwrd"&gt;Me&lt;/span&gt;.AxShockwaveFlash1.Movie = &lt;span class="str"&gt;"MyTestMovie.swf"&lt;/span&gt;
        &lt;span class="kwrd"&gt;Me&lt;/span&gt;.AxShockwaveFlash1.Menu = &lt;span class="kwrd"&gt;True&lt;/span&gt;
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;

    &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; Button1_Click(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; sender &lt;span class="kwrd"&gt;As&lt;/span&gt; System.&lt;span class="kwrd"&gt;Object&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; &lt;br /&gt;e &lt;span class="kwrd"&gt;As&lt;/span&gt; System.EventArgs) &lt;span class="kwrd"&gt;Handles&lt;/span&gt; Button1.Click
        &lt;span class="rem"&gt;' Capture / Reset Flash Window Processing as appropriate&lt;/span&gt;

        &lt;span class="rem"&gt;' React as approrpiate&lt;/span&gt;
        &lt;span class="kwrd"&gt;If&lt;/span&gt; isCapturing &lt;span class="kwrd"&gt;Then&lt;/span&gt;
            &lt;span class="rem"&gt;' Resume&lt;/span&gt;
            CleanupCapture()
        &lt;span class="kwrd"&gt;Else&lt;/span&gt;
            &lt;span class="rem"&gt;' Capture events&lt;/span&gt;
            CaptureRightClick()
        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;
        &lt;span class="rem"&gt;' Switch over the flag&lt;/span&gt;
        isCapturing = &lt;span class="kwrd"&gt;Not&lt;/span&gt; isCapturing
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;

    &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; CaptureRightClick()
        &lt;span class="rem"&gt;' Attempt to obtain the Flash Window&lt;/span&gt;
        EnumChildWindows(&lt;span class="kwrd"&gt;Me&lt;/span&gt;.Handle, &lt;br /&gt;&lt;span class="kwrd"&gt;AddressOf&lt;/span&gt; EnumWindow, IntPtr.Zero)
        &lt;span class="rem"&gt;' Subclass using new routine storing the old result&lt;/span&gt;
        mPreviousHandle = SetWindowLong(mFlashWindowHandle, GWL_WNDPROC, &lt;span class="kwrd"&gt;AddressOf&lt;/span&gt; FlashWindowCapture)
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;

    &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; CleanupCapture()
        &lt;span class="rem"&gt;' Reset back to the original handle...&lt;/span&gt;
        SetWindowLong(mFlashWindowHandle, GWL_WNDPROC, mPreviousHandle)
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;

    &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt; FlashWindowCapture(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; hwnd &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; Msg &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;, &lt;br /&gt;&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; wParam &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; lParam &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;) &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;

        &lt;span class="rem"&gt;' Capture the appropriate message and prevent it from being processed&lt;/span&gt;
        &lt;span class="kwrd"&gt;Select&lt;/span&gt; &lt;span class="kwrd"&gt;Case&lt;/span&gt; Msg
            &lt;span class="kwrd"&gt;Case&lt;/span&gt; WM_RBUTTONDOWN
                &lt;span class="rem"&gt;' Exit&lt;/span&gt;
                &lt;span class="kwrd"&gt;Exit&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt;            
        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Select&lt;/span&gt;

        &lt;span class="rem"&gt;' Carry on...&lt;/span&gt;
        &lt;span class="kwrd"&gt;Return&lt;/span&gt; CallWindowProc(mPreviousHandle, hwnd, Msg, wParam, lParam)
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt;

    &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt; EnumWindow(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; Handle &lt;span class="kwrd"&gt;As&lt;/span&gt; IntPtr, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; Parameter &lt;span class="kwrd"&gt;As&lt;/span&gt; IntPtr) &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;
        &lt;span class="rem"&gt;' Obtain the class name of the child window&lt;/span&gt;
        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; ClassName &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt; System.Text.StringBuilder(&lt;span class="str"&gt;""&lt;/span&gt;, 255)
        GetClassName(Handle, ClassName, ClassName.MaxCapacity)

        &lt;span class="rem"&gt;' Is this the Flash Window?&lt;/span&gt;
        &lt;span class="kwrd"&gt;If&lt;/span&gt; ClassName.ToString = &lt;span class="str"&gt;"MacromediaFlashPlayerActiveX"&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt;
            mFlashWindowHandle = Handle
        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;
        &lt;span class="kwrd"&gt;Return&lt;/span&gt; &lt;span class="kwrd"&gt;True&lt;/span&gt;
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt;

&lt;span class="kwrd"&gt;End&lt;/span&gt; Class&lt;/pre&gt;
&lt;/p&gt;&lt;img src ="http://blogs.vbcity.com/drydo/aggbug/8991.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Mark Dryden</dc:creator><title>Strongly Typed Datasets (.NET 2.0) - Course Notes</title><link>http://blogs.vbcity.com/drydo/archive/2008/01/24/8960.aspx</link><pubDate>Thu, 24 Jan 2008 09:55:00 GMT</pubDate><guid>http://blogs.vbcity.com/drydo/archive/2008/01/24/8960.aspx</guid><wfw:comment>http://blogs.vbcity.com/drydo/comments/8960.aspx</wfw:comment><comments>http://blogs.vbcity.com/drydo/archive/2008/01/24/8960.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.vbcity.com/drydo/comments/commentRss/8960.aspx</wfw:commentRss><trackback:ping>http://blogs.vbcity.com/drydo/services/trackbacks/8960.aspx</trackback:ping><description>&lt;p&gt;This course was created for the VBCity Academy where you can take online courses for free.  Unfortunately, the material I wrote is something I constantly want to keep linking to - so I've decided to place the course up as a flat article.&lt;/p&gt;

&lt;p&gt;I fully recommend that the take the course through the Academy where the structure and flow of the course should make a little more sense - however, if big long documents are your thing - check out the article at &lt;a href="http://blogs.vbcity.com/drydo/articles/8959.aspx"&gt;http://blogs.vbcity.com/drydo/articles/8959.aspx&lt;/a&gt;.&lt;/p&gt;&lt;img src ="http://blogs.vbcity.com/drydo/aggbug/8960.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Mark Dryden</dc:creator><title>CD, DVD and USB Key Insertion and Removal Detection</title><link>http://blogs.vbcity.com/drydo/archive/2007/10/10/8780.aspx</link><pubDate>Wed, 10 Oct 2007 16:28:00 GMT</pubDate><guid>http://blogs.vbcity.com/drydo/archive/2007/10/10/8780.aspx</guid><wfw:comment>http://blogs.vbcity.com/drydo/comments/8780.aspx</wfw:comment><comments>http://blogs.vbcity.com/drydo/archive/2007/10/10/8780.aspx#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://blogs.vbcity.com/drydo/comments/commentRss/8780.aspx</wfw:commentRss><trackback:ping>http://blogs.vbcity.com/drydo/services/trackbacks/8780.aspx</trackback:ping><description>&lt;p&gt;
Just an old code snippet that I've dug out for a new project from an old VB6 project and thought it would be beneficial to post up but I start doing my VooDoo.  In short, the following will detect the insertion and detection of USB key devices, CDs and DVDs.  It doesn't detect the insertion of specific USB devices (at least not the devices arrayed in front of me) - but feel free to play with the code and the Hdr.devicetype parameter.
&lt;/p&gt;
&lt;p&gt;
Anyhoo, create a new form and paste the following in...
&lt;/p&gt;
&lt;p&gt;
&lt;!-- --Start of code block
--&gt;&lt;DIV Style=" Margin-Left=10pt; Margin-Right=2pt;"&gt;&lt;DIV Style=" overflow='auto';"&gt;&lt;FONT Color=#0000ff&gt;Private&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Const&lt;/FONT&gt; WM_DEVICECHANGE &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Integer&lt;/FONT&gt; = &amp;ampH219&lt;br&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:20pt"&gt;' Media Insertion parameters&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Private&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Const&lt;/FONT&gt; DBT_DEVICEARRIVAL &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Integer&lt;/FONT&gt; = &amp;ampH8000&lt;FONT Color=#0000ff&gt;&lt;br&gt;Private&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Const&lt;/FONT&gt; DBT_DEVICEREMOVECOMPLETE &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Integer&lt;/FONT&gt; = &amp;ampH8004&amp;amp&lt;FONT Color=#0000ff&gt;&lt;br&gt;Private&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Const&lt;/FONT&gt; DBT_DEVTYP_VOLUME &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Integer&lt;/FONT&gt; = 2&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:20pt"&gt;' Media Insertion structures&lt;/FONT&gt;&lt;br&gt;&amp;ltStructLayout(LayoutKind.Sequential)&amp;gt _&lt;/div&gt; &lt;FONT Color=#0000ff&gt;Private&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Structure&lt;/FONT&gt; DEV_BROADCAST_HDR&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:40pt"&gt;Public&lt;/FONT&gt; size &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Integer&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Public&lt;/FONT&gt; devicetype &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Integer&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Public&lt;/FONT&gt; reserved &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Integer&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;/div&gt;&lt;div style="margin-left:20pt"&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Structure&lt;/div&gt;&lt;/FONT&gt;&lt;div style="margin-left:20pt"&gt;&amp;ltStructLayout(LayoutKind.Sequential)&amp;gt _&lt;FONT Color=#0000ff&gt;&lt;br&gt;Private&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Structure&lt;/FONT&gt; DEV_BROADCAST_VOLUME&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:20pt"&gt;Public&lt;/FONT&gt; Header &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; DEV_BROADCAST_HDR&lt;FONT Color=#0000ff&gt;&lt;br&gt;Public&lt;/FONT&gt; UnitMask &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Integer&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Public&lt;/FONT&gt; Flags &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Short&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;/div&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Structure&lt;/div&gt;&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:20pt"&gt;Protected&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Overrides&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Sub&lt;/FONT&gt; WndProc(&lt;FONT Color=#0000ff&gt;ByRef&lt;/FONT&gt; m &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; System.Windows.Forms.Message)&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Capture the appropriate messages&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Select&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Case&lt;/FONT&gt; m.Msg&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:20pt"&gt;Case&lt;/FONT&gt; WM_DEVICECHANGE&lt;/div&gt;&lt;/div&gt;&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:80pt"&gt;Dim&lt;/FONT&gt; Hdr &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; DEV_BROADCAST_HDR&lt;FONT Color=#0000ff&gt;&lt;br&gt;Dim&lt;/FONT&gt; Volume &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; DEV_BROADCAST_VOLUME&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:80pt"&gt;' Perform conversion&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Try&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:20pt"&gt;' Convert into the struct&lt;/FONT&gt;&lt;br&gt;Hdr = &lt;FONT Color=#0000ff&gt;DirectCast&lt;/FONT&gt;( _&lt;div style="margin-left:20pt"&gt;Marshal.PtrToStructure(m.LParam, Hdr.GetType), _&lt;br&gt;DEV_BROADCAST_HDR)&lt;FONT Color=#008000&gt;&lt;/div&gt;' If its an appropriate device, convert the volume type&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;If&lt;/FONT&gt; Hdr.devicetype = DBT_DEVTYP_VOLUME &lt;FONT Color=#0000ff&gt;Then&lt;/FONT&gt;&lt;div style="margin-left:20pt"&gt;Volume = &lt;FONT Color=#0000ff&gt;DirectCast&lt;/FONT&gt;( _&lt;br&gt;&amp;nbsp&amp;nbsp&amp;nbspMarshal.PtrToStructure(m.LParam, Volume.GetType), _&lt;br&gt;&amp;nbsp&amp;nbsp&amp;nbspDEV_BROADCAST_VOLUME)&lt;FONT Color=#0000ff&gt;&lt;/div&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;If&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;/div&gt;Catch&lt;/FONT&gt; ex &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; Exception&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:20pt"&gt;Exit&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Sub&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;/div&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Try&lt;/div&gt;&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:80pt"&gt;' Determine the event&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Select&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Case&lt;/FONT&gt; m.WParam.ToInt32&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:20pt"&gt;Case&lt;/FONT&gt; DBT_DEVICEARRIVAL&lt;div style="margin-left:20pt"&gt;MessageBox.Show(&lt;FONT Color=#a31515&gt;&amp;quotInserted and ready on drive: &amp;quot&lt;/FONT&gt; &amp;amp GetVolumeLetter(Volume.UnitMask))&lt;FONT Color=#0000ff&gt;&lt;/div&gt;Case&lt;/FONT&gt; DBT_DEVICEREMOVECOMPLETE&lt;div style="margin-left:20pt"&gt;MessageBox.Show(&lt;FONT Color=#a31515&gt;&amp;quotRemoved from drive: &amp;quot&lt;/FONT&gt; &amp;amp GetVolumeLetter(Volume.UnitMask))&lt;FONT Color=#0000ff&gt;&lt;/div&gt;&lt;/div&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Select&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;/div&gt;&lt;div style="margin-left:40pt"&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Select&lt;/div&gt;&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Call the base routine&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;MyBase&lt;/FONT&gt;.WndProc(m)&lt;FONT Color=#0000ff&gt;&lt;/div&gt;&lt;div style="margin-left:20pt"&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Sub&lt;/div&gt;&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:20pt"&gt;Private&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Function&lt;/FONT&gt; GetVolumeLetter(&lt;FONT Color=#0000ff&gt;ByVal&lt;/FONT&gt; Mask &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Integer&lt;/FONT&gt;) &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Char&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:20pt"&gt;' This function takes the integer value passed through and determine the volume&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;br&gt;' type that has been inserted/removed&lt;/div&gt;&lt;/div&gt;&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:40pt"&gt;Dim&lt;/FONT&gt; CharCode &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Integer&lt;/FONT&gt; = 65&lt;FONT Color=#0000ff&gt;&lt;br&gt;Do&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Until&lt;/FONT&gt; (Mask &lt;FONT Color=#0000ff&gt;And&lt;/FONT&gt; 1) = 1&lt;FONT Color=#008000&gt;&lt;div style="margin-left:20pt"&gt;' Used instead of c# syntax of &amp;gt&amp;gt=&lt;/FONT&gt;&lt;br&gt;Mask = &lt;FONT Color=#0000ff&gt;CType&lt;/FONT&gt;(Fix(&lt;FONT Color=#0000ff&gt;CType&lt;/FONT&gt;(Mask, &lt;FONT Color=#0000ff&gt;Double&lt;/FONT&gt;) / 2), &lt;FONT Color=#0000ff&gt;Integer&lt;/FONT&gt;)&lt;br&gt;CharCode += 1&lt;FONT Color=#0000ff&gt;&lt;/div&gt;Loop&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;br&gt;' Return the char val&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Return&lt;/FONT&gt; Chr(CharCode)&lt;FONT Color=#0000ff&gt;&lt;/div&gt;&lt;div style="margin-left:20pt"&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Function&lt;/FONT&gt;&lt;/div&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;!-- 
End of code block----&gt;
&lt;/p&gt;
&lt;p&gt;
This code comes without warranty so if it blows up, wipes your machine or becomes the key node in the birth of &lt;a href="http://en.wikipedia.org/wiki/Skynet_%28fictional%29" target="_blank"&gt;SkyNet&lt;/a&gt; - feel free to post a comment so I can laugh like a drain.  Note: it does work but remember to include it within your testing phase...
&lt;/p&gt;&lt;img src ="http://blogs.vbcity.com/drydo/aggbug/8780.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Mark Dryden</dc:creator><title>Global Exception Handler for VB.NET</title><link>http://blogs.vbcity.com/drydo/archive/2007/10/02/8752.aspx</link><pubDate>Tue, 02 Oct 2007 10:03:00 GMT</pubDate><guid>http://blogs.vbcity.com/drydo/archive/2007/10/02/8752.aspx</guid><wfw:comment>http://blogs.vbcity.com/drydo/comments/8752.aspx</wfw:comment><comments>http://blogs.vbcity.com/drydo/archive/2007/10/02/8752.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.vbcity.com/drydo/comments/commentRss/8752.aspx</wfw:commentRss><trackback:ping>http://blogs.vbcity.com/drydo/services/trackbacks/8752.aspx</trackback:ping><description>&lt;p&gt;
I've been involved in an interesting post where a member wanted to create a Global Exception Handler.  As an absolute purist of course, I recommend that an adequate testing phase should eradicate virtually all errors, barring those that are effected by outside elements, e.g. FileSystem, Database(s), Networking, etc.
&lt;/p&gt;
&lt;p&gt;
Anyhoo, we initially started off utilising the 'AppDomain.UnhandledException' event and whilst this certainly worked in the Development Environment, if it was ran as a normal executable as either the Debug or Release build - the CLR Error Handler would appear.  After some research, I came across ex-MVP's Daniel Moth's &lt;a href="http://www.danielmoth.com/Blog/2004/08/global-exception-handling-net-v11-part.html"&gt;Blog entry&lt;/a&gt; on the subject where the ThreadException event of the Application should also be captured along with a Try..Catch statement wrapped around the 'Application.Run' statement.
&lt;/p&gt;
&lt;p&gt;
Anyhoo - the good news is that it worked (tested for Framework 2.0) and here's the code for those who are interested...
&lt;/p&gt;
&lt;!-- --Start of code block
--&gt;&lt;DIV Style=" Margin-Left=10pt; Margin-Right=2pt;"&gt;&lt;DIV Style=" overflow='auto';"&gt;&lt;FONT Color=#0000ff&gt;Module&lt;/FONT&gt; Startup&lt;br&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:20pt"&gt;' Main display form&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Private&lt;/FONT&gt; myStartupForm &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; Form1&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:20pt"&gt;' Delegate used to marshal back to the main UI thread&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Private&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Delegate&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Sub&lt;/FONT&gt; SafeApplicationThreadException(&lt;FONT Color=#0000ff&gt;ByVal&lt;/FONT&gt; sender &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Object&lt;/FONT&gt;, &lt;FONT Color=#0000ff&gt;ByVal&lt;/FONT&gt; e &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; Threading.ThreadExceptionEventArgs)&lt;/div&gt;&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:20pt"&gt;Sub&lt;/FONT&gt; Main()&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Initialise the startup form&lt;/FONT&gt;&lt;br&gt;myStartupForm = &lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; Form1&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Configure the form...&lt;/div&gt;&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Configure AppDomain &lt;/div&gt;&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:40pt"&gt;Dim&lt;/FONT&gt; currentDomain &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; AppDomain = AppDomain.CurrentDomain&lt;FONT Color=#0000ff&gt;&lt;br&gt;AddHandler&lt;/FONT&gt; currentDomain.UnhandledException, &lt;FONT Color=#0000ff&gt;AddressOf&lt;/FONT&gt; AppDomain_UnhandledException&lt;FONT Color=#0000ff&gt;&lt;br&gt;AddHandler&lt;/FONT&gt; Application.ThreadException, &lt;FONT Color=#0000ff&gt;AddressOf&lt;/FONT&gt; Application_ThreadException&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Start the main form&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Try&lt;/FONT&gt;&lt;div style="margin-left:20pt"&gt;Application.Run(myStartupForm)&lt;FONT Color=#0000ff&gt;&lt;/div&gt;Catch&lt;/FONT&gt; ex &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; Exception&lt;FONT Color=#008000&gt;&lt;div style="margin-left:20pt"&gt;' Custom handling logic&lt;/FONT&gt;&lt;br&gt;DisplayCustomErrorLogic(ex)&lt;FONT Color=#0000ff&gt;&lt;/div&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Try&lt;/div&gt;&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:20pt"&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Sub&lt;/div&gt;&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:20pt"&gt;Private&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Sub&lt;/FONT&gt; DisplayCustomErrorLogic(&lt;FONT Color=#0000ff&gt;ByVal&lt;/FONT&gt; sourceException &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; Exception)&lt;FONT Color=#008000&gt;&lt;div style="margin-left:20pt"&gt;' Hide the current form&lt;/FONT&gt;&lt;br&gt;myStartupForm.Hide()&lt;/div&gt;&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Display the message&lt;/FONT&gt;&lt;br&gt;MsgBox(sourceException.Message.ToString)&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Exit the application (you don't have to though)&lt;/FONT&gt;&lt;br&gt;Application.Exit()&lt;FONT Color=#0000ff&gt;&lt;/div&gt;&lt;div style="margin-left:20pt"&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Sub&lt;/div&gt;&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:20pt"&gt;Private&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Sub&lt;/FONT&gt; Application_ThreadException(&lt;FONT Color=#0000ff&gt;ByVal&lt;/FONT&gt; sender &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Object&lt;/FONT&gt;, &lt;FONT Color=#0000ff&gt;ByVal&lt;/FONT&gt; e &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; Threading.ThreadExceptionEventArgs)&lt;FONT Color=#008000&gt;&lt;div style="margin-left:20pt"&gt;' Pass to the safe exception handler&lt;/FONT&gt;&lt;br&gt;SafeApplication_ThreadException(sender, e)&lt;FONT Color=#0000ff&gt;&lt;/div&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Sub&lt;/div&gt;&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:20pt"&gt;Private&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Sub&lt;/FONT&gt; SafeApplication_ThreadException(&lt;FONT Color=#0000ff&gt;ByVal&lt;/FONT&gt; sender &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Object&lt;/FONT&gt;, &lt;FONT Color=#0000ff&gt;ByVal&lt;/FONT&gt; e &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; Threading.ThreadExceptionEventArgs)&lt;FONT Color=#008000&gt;&lt;div style="margin-left:20pt"&gt;' Are we running on the correct thread?&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;If&lt;/FONT&gt; myStartupForm.InvokeRequired &lt;FONT Color=#0000ff&gt;Then&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:20pt"&gt;' Invoke back to the main thread&lt;/FONT&gt;&lt;br&gt;myStartupForm.Invoke(&lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; SafeApplicationThreadException(&lt;FONT Color=#0000ff&gt;AddressOf&lt;/FONT&gt; SafeApplication_ThreadException), &lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Object&lt;/FONT&gt;() {sender, e})&lt;FONT Color=#0000ff&gt;&lt;/div&gt;Else&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:20pt"&gt;' Custom handling logic&lt;/FONT&gt;&lt;br&gt;DisplayCustomErrorLogic(e.Exception)&lt;FONT Color=#0000ff&gt;&lt;/div&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;If&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;/div&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Sub&lt;/div&gt;&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:20pt"&gt;Private&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Sub&lt;/FONT&gt; AppDomain_UnhandledException(&lt;FONT Color=#0000ff&gt;ByVal&lt;/FONT&gt; sender &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Object&lt;/FONT&gt;, &lt;FONT Color=#0000ff&gt;ByVal&lt;/FONT&gt; e &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; UnhandledExceptionEventArgs)&lt;FONT Color=#008000&gt;&lt;div style="margin-left:20pt"&gt;' Custom handling logic&lt;/FONT&gt;&lt;br&gt;DisplayCustomErrorLogic(&lt;FONT Color=#0000ff&gt;DirectCast&lt;/FONT&gt;(e.ExceptionObject, Exception))&lt;FONT Color=#0000ff&gt;&lt;/div&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Sub&lt;/div&gt;&lt;br&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Module&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;br&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;!-- 
End of code block----&gt;
&lt;p&gt;
Note: the ThreadingException event is marshalled back to the main GUI thread, this allows any specific GUI manipulation with the original starting form if so desired.
Note 2: in order to utilise the above code, create a new module called Startup and paste the above in.  When completed, open the Project Properties up and select the 'Application' tab.  Ensure that the 'Enable Application Framework' checkbox is unticked and then select 'Sub Main' from the Combobox titled 'Startup Object'.
&lt;/p&gt;
&lt;p&gt;
M
&lt;/p&gt;&lt;img src ="http://blogs.vbcity.com/drydo/aggbug/8752.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Mark Dryden</dc:creator><title>Importing a TextFile into a Database using a Dataset</title><link>http://blogs.vbcity.com/drydo/archive/2007/09/28/8733.aspx</link><pubDate>Fri, 28 Sep 2007 14:25:00 GMT</pubDate><guid>http://blogs.vbcity.com/drydo/archive/2007/09/28/8733.aspx</guid><wfw:comment>http://blogs.vbcity.com/drydo/comments/8733.aspx</wfw:comment><comments>http://blogs.vbcity.com/drydo/archive/2007/09/28/8733.aspx#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://blogs.vbcity.com/drydo/comments/commentRss/8733.aspx</wfw:commentRss><trackback:ping>http://blogs.vbcity.com/drydo/services/trackbacks/8733.aspx</trackback:ping><description>Importing a TextFile into a Database using a Dataset

&lt;p&gt;This question comes up a bit on the forums (twice today already) where the user wants to import data from one Datasource (such as a TextFile) into a database (SQL Server / Access / Whatever).  Now in the case of SQL Server my natural reaction would be to suggest DTS for SQL 2000 or check out some of the new cool features of SQL 2005 (which I've yet to experience).  However, there are occasions - especially if some processing needs to be performing during the import, where it would be a lot easier if the import was done in .NET.&lt;/p&gt;

&lt;p&gt;Now sure, if you want to read in your text file using a text reader - throw it into an array then utilise a DataCommand object and ExecuteNonQuery then go for it.  However, if you like your coding a bit easier and find the DataTable a versatile object to store your data and perform various routine upon it before you upload, well, gather closer children...&lt;/p&gt;

&lt;p&gt;OK - at my local pub they run a Bonus Ball thing.  Basically, everyone has a number and pays one pound per week for privilege of that number.  If the said number comes out in the National UK Lotto as the Bonus Ball on a Saturday, then you win the lot (up to £49).  Now there's a lot of banter about who keeps winning (or seems to keep winning) and those with sob stories about how they haven't won in 'x' number of years.  So on occasion I grab all the results from a website (&lt;a href="http://lottery.merseyworld.com/Winning_index.html"&gt;Lottery Results&lt;/a&gt;) throw it into SQL and run a quick GROUP BY query to work out exactly when people have won.&lt;/p&gt;

&lt;p&gt;So - for this post I've taken the results of the page and saved it as a text file.  Got rid of the 'UK National Lotto Winning Numbers' and the 'All lotteries below have exceeded the 180 days expiry date' strings and second set of field titles just below this (maintaining the first line with the field names) and there's my text file for import.&lt;/p&gt;

&lt;p&gt;I place the text file into an appropriate directory, create my table in a test Database, structure as is...&lt;/p&gt;

&lt;p&gt;
&lt;!-- --Start of code block
--&gt;&lt;DIV Style=" Margin-Left=10pt; Margin-Right=2pt;"&gt;&lt;DIV Style=" overflow='auto';"&gt;&lt;FONT Color=#0000ff&gt;CREATE TABLE [dbo].[tblLottery] (&lt;div style="margin-left:20pt"&gt;[EntryId] [int] IDENTITY (1, 1) NOT NULL ,&lt;br&gt;[LotteryId] [int] NOT NULL ,&lt;br&gt;[BonusBall] [int] NOT NULL ,&lt;br&gt;[WeekDay] [nvarchar] (3) COLLATE Latin1_General_CI_AS NOT NULL ,&lt;br&gt;[DrawDay] [int] NOT NULL ,&lt;br&gt;[DrawMonth] [nvarchar] (10) COLLATE Latin1_General_CI_AS NOT NULL ,&lt;br&gt;[DrawYear] [int] NOT NULL &lt;/div&gt;) ON [PRIMARY]&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;!-- 
End of code block----&gt;
GO
&lt;/p&gt;

&lt;p&gt;and then utilise my code...&lt;/p&gt;

&lt;p&gt;
&lt;!-- --Start of code block
--&gt;&lt;DIV Style=" Margin-Left=10pt; Margin-Right=2pt;"&gt;&lt;DIV Style=" overflow='auto';"&gt;&lt;FONT Color=#008000&gt;' Dataset&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:40pt"&gt;Dim&lt;/FONT&gt; ds &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; DataSet&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Text File connection&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Dim&lt;/FONT&gt; oleTextConn &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; OleDbConnection&lt;FONT Color=#008000&gt;&lt;br&gt;' Set the connection string&lt;/FONT&gt;&lt;br&gt;oleTextConn.ConnectionString = &lt;FONT Color=#a31515&gt;&amp;quotProvider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\MyImportDirectory\;Extended Properties=&amp;quot&amp;quottext;HDR=Yes;FMT=Delimited&amp;quot;&amp;quot;&amp;quot&lt;/div&gt;&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Configure a dataadapter to load in the text data into my dataset&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Dim&lt;/FONT&gt; daTextFile &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; OleDbDataAdapter&lt;FONT Color=#008000&gt;&lt;br&gt;' Generate the Select Command&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Dim&lt;/FONT&gt; selCommand &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; OleDbCommand&lt;FONT Color=#008000&gt;&lt;br&gt;' Configure&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;With&lt;/FONT&gt; selCommand&lt;div style="margin-left:20pt"&gt;.CommandText = &lt;FONT Color=#a31515&gt;&amp;quotSELECT * FROM [Lottery.txt]&amp;quot&lt;/FONT&gt;&lt;br&gt;.CommandType = CommandType.Text&lt;br&gt;.Connection = oleTextConn&lt;FONT Color=#0000ff&gt;&lt;/div&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;With&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;br&gt;' Add to the dataadapter&lt;/FONT&gt;&lt;br&gt;daTextFile.SelectCommand = selCommand&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Fill the dataset&lt;/FONT&gt;&lt;br&gt;oleTextConn.Open()&lt;br&gt;daTextFile.Fill(ds)&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Cleanup our text connections&lt;/FONT&gt;&lt;br&gt;oleTextConn.Close()&lt;br&gt;daTextFile.Dispose()&lt;br&gt;daTextFile = &lt;FONT Color=#0000ff&gt;Nothing&lt;/FONT&gt;&lt;br&gt;oleTextConn.Dispose()&lt;br&gt;oleTextConn = &lt;FONT Color=#0000ff&gt;Nothing&lt;/div&gt;&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Create the SQL Connection&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Dim&lt;/FONT&gt; sqlConn &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; SqlConnection&lt;br&gt;sqlConn.ConnectionString = &lt;FONT Color=#a31515&gt;&amp;quotData Source=ARNIE;Initial Catalog=MyLotteryDB;Integrated Security=SSPI;&amp;quot&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;br&gt;' Create a new SQL DataAdapter&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Dim&lt;/FONT&gt; daSQL &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; SqlDataAdapter&lt;FONT Color=#008000&gt;&lt;br&gt;' Generate the Insert Command&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Dim&lt;/FONT&gt; insCommand &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; SqlCommand&lt;FONT Color=#0000ff&gt;&lt;br&gt;With&lt;/FONT&gt; insCommand&lt;div style="margin-left:20pt"&gt;.CommandText = &lt;FONT Color=#a31515&gt;&amp;quotINSERT INTO tblLottery ( [LotteryId] , [BonusBall] , [WeekDay] , [DrawDay] , [DrawMonth] , [DrawYear] ) VALUES ( @LotteryId , @BonusBall , @WeekDay, @DrawDay , @DrawMonth, @DrawYear )&amp;quot&lt;/FONT&gt;&lt;br&gt;.CommandType = CommandType.Text&lt;br&gt;.Connection = sqlConn&lt;/div&gt;&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:60pt"&gt;' Configure the insert parameters&lt;/FONT&gt;&lt;br&gt;.Parameters.Add(&lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; SqlParameter(&lt;FONT Color=#a31515&gt;&amp;quot@LotteryId&amp;quot;&lt;/FONT&gt;, SqlDbType.Int, 0, &lt;FONT Color=#a31515&gt;&amp;quotNo#&amp;quot&lt;/FONT&gt;))&lt;br&gt;.Parameters.Add(&lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; SqlParameter(&lt;FONT Color=#a31515&gt;&amp;quot@BonusBall&amp;quot;&lt;/FONT&gt;, SqlDbType.Int, 0, &lt;FONT Color=#a31515&gt;&amp;quotBN&amp;quot;&lt;/FONT&gt;))&lt;br&gt;.Parameters.Add(&lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; SqlParameter(&lt;FONT Color=#a31515&gt;&amp;quot@WeekDay&amp;quot;&lt;/FONT&gt;, SqlDbType.NVarChar, 3, &lt;FONT Color=#a31515&gt;&amp;quotDay&amp;quot;&lt;/FONT&gt;))&lt;br&gt;.Parameters.Add(&lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; SqlParameter(&lt;FONT Color=#a31515&gt;&amp;quot@DrawDay&amp;quot;&lt;/FONT&gt;, SqlDbType.Int, 0, &lt;FONT Color=#a31515&gt;&amp;quotDD&amp;quot;&lt;/FONT&gt;))&lt;br&gt;.Parameters.Add(&lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; SqlParameter(&lt;FONT Color=#a31515&gt;&amp;quot@DrawMonth&amp;quot;&lt;/FONT&gt;, SqlDbType.NVarChar, 10, &lt;FONT Color=#a31515&gt;&amp;quotMMM&amp;quot;&lt;/FONT&gt;))&lt;br&gt;.Parameters.Add(&lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; SqlParameter(&lt;FONT Color=#a31515&gt;&amp;quot@DrawYear&amp;quot;&lt;/FONT&gt;, SqlDbType.Int, 0, &lt;FONT Color=#a31515&gt;&amp;quotYYYY&amp;quot;&lt;/FONT&gt;))&lt;/div&gt;&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:40pt"&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;With&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;br&gt;' Add to the dataadapter&lt;/FONT&gt;&lt;br&gt;daSQL.InsertCommand = insCommand&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Loop through each row and set its rowstate to added&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;br&gt;' This will cause the dataadapter to think every row is new and needs inserting...&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;For&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Each&lt;/FONT&gt; dr &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; DataRow &lt;FONT Color=#0000ff&gt;In&lt;/FONT&gt; ds.Tables(0).Rows&lt;div style="margin-left:20pt"&gt;dr.SetAdded()&lt;FONT Color=#0000ff&gt;&lt;/div&gt;Next&lt;/div&gt;&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Open the SQL Connection and Update&lt;/FONT&gt;&lt;br&gt;sqlConn.Open()&lt;br&gt;daSQL.Update(ds.Tables(0))&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Cleanup&lt;/FONT&gt;&lt;br&gt;sqlConn.Close()&lt;br&gt;daSQL.Dispose()&lt;br&gt;daSQL = &lt;FONT Color=#0000ff&gt;Nothing&lt;/FONT&gt;&lt;br&gt;sqlConn.Dispose()&lt;br&gt;sqlConn = &lt;FONT Color=#0000ff&gt;Nothing&lt;/FONT&gt;&lt;/div&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;!-- 
End of code block----&gt;
&lt;/p&gt;

&lt;p&gt;...and job done.  Takes around 3 seconds to process on my machine which is pretty slick huh?&lt;/p&gt;

&lt;p&gt;Design Notes:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;If you are not familiar with the Text File OleDb Driver, you specify the directory only in the connection string then the actual filename in the SELECT statement.  In other words, each text file should be classed as its own data entity.&lt;/li&gt;
	&lt;li&gt;When a datarow is loaded into a dataset, it rowstate will be set with the 'Unchanged' flag.  If we then run our SQLDataAdapter nothing will happen as the dataset knows that the records have not been altered.  In order for them to be inserted we reset this flag to 'Added' that will invoke the 'InsertCommand' when the 'Update' routine is called.&lt;/li&gt;
	&lt;li&gt;Note: I use the 'SetAdded' method of the DataRow object to set the DataRow's RowState.  This is a Framework 2.0 method only.  But this can be worked around for Framework 1.*, e.g. create a duplicate DataTable and 'Add' the records from the sourcetable to new table - this should set the RowState flag.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;HTH - M&lt;/p&gt;&lt;img src ="http://blogs.vbcity.com/drydo/aggbug/8733.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Mark Dryden</dc:creator><title>ASP.NET 2.0, Custom Role assignment without a 'Role Provider'</title><link>http://blogs.vbcity.com/drydo/archive/2007/09/19/8717.aspx</link><pubDate>Wed, 19 Sep 2007 11:18:00 GMT</pubDate><guid>http://blogs.vbcity.com/drydo/archive/2007/09/19/8717.aspx</guid><wfw:comment>http://blogs.vbcity.com/drydo/comments/8717.aspx</wfw:comment><comments>http://blogs.vbcity.com/drydo/archive/2007/09/19/8717.aspx#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://blogs.vbcity.com/drydo/comments/commentRss/8717.aspx</wfw:commentRss><trackback:ping>http://blogs.vbcity.com/drydo/services/trackbacks/8717.aspx</trackback:ping><description>&lt;p&gt;I love starting new projects with a new technology and recently the requirement for an ASP.NET 2.0 custom reporting module landed on my desk.  I have some ASP.NET 1.1 experience having created a couple of sites about two years ago but that was it.&lt;/p&gt;

&lt;p&gt;Keen to implement some of ASP.NET 2.0's cool features I came across the Membership, Roles and Profiles features @ http://www.4guysfromrolla.com and was impressed by how easy it was to generate a robust authentication system from scratch utilising Roles and various other niceities.  However, out of all these articles there didn't seem to be anything that covered the scenario where the developer had already got a database and structure for storage and a library that could handle the authentication, role assignment and various other tasks.&lt;/p&gt;

&lt;p&gt;Digging a little deeper it seemed that I could still utilise the login control then capture the 'authenticate' event and then employ my custom logic to authenticate the user.  However, I wanted an easy way to identify whether the user was part of a specific role or not.  &lt;/p&gt;

&lt;p&gt;Now I must admit I checked out creating my own custom 'Role Provider' and whilst this might have been a better approach (especially if I wanted to expose routines to Add, Remove, Amend roles from a user) in the scenario where I'm handling this elsewhere - it seemed to be overkill.&lt;/p&gt;

&lt;p&gt;Anyhoo, here's how I did it...&lt;/p&gt;

&lt;p&gt;In my 'Authenticate' event of the login control I instantiate my custom authentication class.  In my case, this class exposes a method to authenticate the user (returning a boolean value) and a property exposing the role of the user (which is a numerical value).
&lt;/p&gt;
&lt;p&gt;Note: it is possible of utilise multiple roles, my scenario precluded that option...&lt;/p&gt;

&lt;p&gt;Here's the psuedo-code....&lt;/p&gt;

&lt;p&gt;
&lt;!-- --Start of code block
--&gt;&lt;DIV Style=" Margin-Left=10pt; Margin-Right=2pt;"&gt;&lt;DIV Style=" overflow='auto';"&gt; &lt;FONT Color=#008000&gt;' Custom authentication class&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:40pt"&gt;Dim&lt;/FONT&gt; myAuthentication &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; UserAuthentication&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Call custom authentication routine (where: conLogin is the Login control)&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;br&gt;' and pass the username and password over&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;If&lt;/FONT&gt; myAuthentication.AuthenticateUser(conLogin.UserName, conLogin.Password) &lt;FONT Color=#0000ff&gt;Then&lt;/div&gt;&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:60pt"&gt;' If sucessful, generate the authentication ticket&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Dim&lt;/FONT&gt; ticket &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; FormsAuthenticationTicket( _&lt;div style="margin-left:20pt"&gt;1, _&lt;FONT Color=#a31515&gt;&lt;br&gt;&amp;quotuserName&amp;quot&lt;/FONT&gt;, _&lt;br&gt;DateTime.Now, _&lt;br&gt;DateTime.Now.AddMinutes(20), _&lt;FONT Color=#0000ff&gt;&lt;br&gt;False&lt;/FONT&gt;, _&lt;br&gt;myAuthentication.RoleId, _ &lt;FONT Color=#008000&gt;' Retreive the RoleId from the authentication class&lt;/FONT&gt;&lt;br&gt;FormsAuthentication.FormsCookiePath)&lt;/div&gt;&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:60pt"&gt;' Encrypt&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Dim&lt;/FONT&gt; encTicket &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;String&lt;/FONT&gt; = FormsAuthentication.Encrypt(ticket)&lt;FONT Color=#0000ff&gt;&lt;br&gt;Dim&lt;/FONT&gt; authCookie &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; HttpCookie(FormsAuthentication.FormsCookieName, encTicket)&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:60pt"&gt;' Add to the cookies&lt;/FONT&gt;&lt;br&gt;Response.Cookies.Add(authCookie)&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:60pt"&gt;' Perform any appropriate navigation from the login page&lt;/FONT&gt;&lt;br&gt;Response.Redirect(&lt;FONT Color=#a31515&gt;&amp;quotNextPage.aspx&amp;quot&lt;/FONT&gt;)&lt;/div&gt;&lt;FONT Color=#0000ff&gt;&lt;div style="margin-left:40pt"&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;If&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;/FONT&gt;&lt;/div&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;!-- 
End of code block----&gt;
&lt;/p&gt;
&lt;p&gt;
As you can see when I instantiate my AuthenticationTicket I pass the RoleId into the 'userData' argument.  Once in there, I can now utilise that value elsewhere, namely the HttpApplication.AuthenticateRequest event where I can parse the current FormsIdentity, obtain the appropriate RoleId from the 'userData' property and add that to the 'roles' for the current user.
&lt;/p&gt;
&lt;p&gt;
So, if you haven't created a Global.asax file, do so.  Within here you need to capture the 'AuthenticateRequest' event of the Application object and then utilise the following code...
&lt;/p&gt;
&lt;p&gt;
&lt;!-- --Start of code block
--&gt;&lt;DIV Style=" Margin-Left=10pt; Margin-Right=2pt;"&gt;&lt;DIV Style=" overflow='auto';"&gt;&lt;FONT Color=#0000ff&gt;Protected&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Sub&lt;/FONT&gt; Application_AuthenticateRequest(&lt;FONT Color=#0000ff&gt;ByVal&lt;/FONT&gt; sender &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Object&lt;/FONT&gt;, &lt;FONT Color=#0000ff&gt;ByVal&lt;/FONT&gt; e &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; System.EventArgs)&lt;FONT Color=#008000&gt;&lt;div style="margin-left:40pt"&gt;' Does the object exist and is the user instantiate?&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;If&lt;/FONT&gt; (((&lt;FONT Color=#0000ff&gt;Not&lt;/FONT&gt; HttpContext.Current.User &lt;FONT Color=#0000ff&gt;Is&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Nothing&lt;/FONT&gt;) &lt;FONT Color=#0000ff&gt;AndAlso&lt;/FONT&gt; HttpContext.Current.User.Identity.IsAuthenticated) &lt;FONT Color=#0000ff&gt;AndAlso&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;TypeOf&lt;/FONT&gt; HttpContext.Current.User.Identity &lt;FONT Color=#0000ff&gt;Is&lt;/FONT&gt; FormsIdentity) &lt;FONT Color=#0000ff&gt;Then&lt;/FONT&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:20pt"&gt;' Retreive the current identity&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;Dim&lt;/FONT&gt; id &lt;FONT Color=#0000ff&gt;As&lt;/FONT&gt; FormsIdentity = &lt;FONT Color=#0000ff&gt;CType&lt;/FONT&gt;(HttpContext.Current.User.Identity, FormsIdentity)&lt;FONT Color=#008000&gt;&lt;br&gt;' Reset the User object and incorporate the new roles&lt;/FONT&gt;&lt;br&gt;HttpContext.Current.User = &lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; System.Security.Principal.GenericPrincipal(id, &lt;FONT Color=#0000ff&gt;New&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;String&lt;/FONT&gt;() {id.Ticket.UserData})&lt;FONT Color=#0000ff&gt;&lt;/div&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;If&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;/div&gt;&lt;div style="margin-left:20pt"&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;Sub&lt;/FONT&gt;&lt;/div&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;!-- 
End of code block----&gt;
&lt;/p&gt;
&lt;p&gt;
So the User object is reset with the appropriate role.  Note: that the 'roles()' argument of instantiation of 'GenericPrincipal' object does accept an array of string to support multiple roles.
&lt;/p&gt;
&lt;p&gt;
Now, it is possible to utilise the base 'User.IsInRole' method and pass the appropriate RoleId over.  However, I tend to make my job slightly easier by employing an Enum and utilising that, e.g.
&lt;/p&gt;
&lt;p&gt;
&lt;!-- --Start of code block
--&gt;&lt;DIV Style=" Margin-Left=10pt; Margin-Right=2pt;"&gt;&lt;DIV Style=" overflow='auto';"&gt;&lt;FONT Color=#0000ff&gt;If&lt;/FONT&gt; User.IsInRole(Constants.UserRoles.Administrator) &lt;FONT Color=#0000ff&gt;Then&lt;/FONT&gt;&lt;div style="margin-left:60pt"&gt;Response.Write(&lt;FONT Color=#a31515&gt;&amp;quotYou're an Administrator!&amp;quot&lt;/FONT&gt;)&lt;FONT Color=#0000ff&gt;&lt;/div&gt;&lt;div style="margin-left:40pt"&gt;Else&lt;/FONT&gt;&lt;div style="margin-left:20pt"&gt;Response.Write(&lt;FONT Color=#a31515&gt;&amp;quotYou're a nobody.&amp;quot&lt;/FONT&gt;)&lt;FONT Color=#0000ff&gt;&lt;/div&gt;End&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;If&lt;/FONT&gt;&lt;/div&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;!-- 
End of code block----&gt;
&lt;/p&gt;
&lt;p&gt;
And that's it.  One block of code in the Global.asasx and one Enum to make coding slightly easily (admittedly without Option Strict On) and everything is up and running!
&lt;/p&gt;
&lt;p&gt;
HTH - M
&lt;/p&gt;&lt;img src ="http://blogs.vbcity.com/drydo/aggbug/8717.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Mark Dryden</dc:creator><title>Deleting Files using Array.ForEach (My Generics Enlightenment)</title><link>http://blogs.vbcity.com/drydo/archive/2007/07/25/8553.aspx</link><pubDate>Wed, 25 Jul 2007 14:11:00 GMT</pubDate><guid>http://blogs.vbcity.com/drydo/archive/2007/07/25/8553.aspx</guid><wfw:comment>http://blogs.vbcity.com/drydo/comments/8553.aspx</wfw:comment><comments>http://blogs.vbcity.com/drydo/archive/2007/07/25/8553.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.vbcity.com/drydo/comments/commentRss/8553.aspx</wfw:commentRss><trackback:ping>http://blogs.vbcity.com/drydo/services/trackbacks/8553.aspx</trackback:ping><description>&lt;P&gt;Just a tiny post after another break of sorting out the house selling junk on eBay.  
&lt;/P&gt;
&lt;P&gt;Today I saw a post on the VbCity Forums where the ORPO wanted to delete a portion of files from a directory using a search pattern.  The answer was to utilise the 'IO.Directory' or 'IO.DirectoryInfo' class's 'GetFiles' method then loop through the result deleting the appropriate 'IO.File' or 'IO.FileInfo' object.  However, ORPO's being ORPO's wanted to perform this action in one line.
&lt;/P&gt;
&lt;P&gt;Anyhoo, after coming to the end of my lunch I decided to trawl the intellisense to see if anything jumped out at me.  And it did :-)
&lt;/P&gt;
&lt;P&gt;Now I have to admit that I thought that Generics (introducing with .NET 2.0) was merely a matter of strongly typing Arraylists - however, introductions to the likes of anonymous methods have left me thinking that it can a bigger and more impactive part of the framework that originally thought (at least from a coding perspective).
&lt;/P&gt;
&lt;P&gt;So - back to the chase.  The 'Array' object has a shared method called 'ForEach' that will loop through the array performing the specified function upon each object (identified using a delegate).  So - all I had to do was get the list of files and pass the hard work over to the 'IO.File.Delete' method....&lt;/P&gt;
&lt;P&gt;
&lt;!-- --Start of code block
--&gt;&lt;DIV Style=" Margin-Left=10pt; Margin-Right=2pt;"&gt;&lt;DIV Style=" overflow='auto';"&gt;&lt;FONT Color=#008000&gt;' Deletes all files with the extension of '.doc' under the 'MyDirectory' directory.&lt;/FONT&gt;&lt;br&gt;Array.ForEach(&lt;FONT Color=#0000ff&gt;Of&lt;/FONT&gt; &lt;FONT Color=#0000ff&gt;String&lt;/FONT&gt;)(IO.Directory.GetFiles(&lt;FONT Color=#a31515&gt;&amp;quotC:\MyDirectory\&amp;quot&lt;/FONT&gt;, &lt;FONT Color=#a31515&gt;&amp;quot*.doc&amp;quot&lt;/FONT&gt;), &lt;FONT Color=#0000ff&gt;AddressOf&lt;/FONT&gt; IO.File.Delete)&lt;/DIV&gt;&lt;/DIV&gt;&lt;!-- 
End of code block----&gt;
&lt;/P&gt;
&lt;P&gt;Cool huh?&lt;/P&gt;
&lt;img src ="http://blogs.vbcity.com/drydo/aggbug/8553.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Mark Dryden</dc:creator><title>.NET Micro Framework - Further thoughts...</title><link>http://blogs.vbcity.com/drydo/archive/2007/05/24/8310.aspx</link><pubDate>Thu, 24 May 2007 10:48:00 GMT</pubDate><guid>http://blogs.vbcity.com/drydo/archive/2007/05/24/8310.aspx</guid><wfw:comment>http://blogs.vbcity.com/drydo/comments/8310.aspx</wfw:comment><comments>http://blogs.vbcity.com/drydo/archive/2007/05/24/8310.aspx#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://blogs.vbcity.com/drydo/comments/commentRss/8310.aspx</wfw:commentRss><trackback:ping>http://blogs.vbcity.com/drydo/services/trackbacks/8310.aspx</trackback:ping><description>&lt;p&gt;Well, it's been a fun couple of days messing with the Micro Framework and overall I'm impressed.  Sure - the .NET Micro Framework doesn't have the XML namespace, but it is a *Micro* framework people.&lt;/p&gt;

&lt;p&gt;Anyhoo, I've managed to code up some simple applications such as an image viewer that could move between image, which I then improved so it moved between images and used an alpha transition between each one.  And I've also been messing the SerialPort class to just send some simple commands to our RS232 relay board - the plan is to get an RS232 IR transmitter so we can communicate with Kevin our RoboSapien2 so fingers crossed.&lt;/p&gt;

&lt;p&gt;From all that playing around, here are a couple of titbits...&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Debugging live from the actual board.  Sussed out that this wasn't a limitation but rather that Visual Studio SP1 had 'lost' the configuration manager from the Project Properties and Dropdown combo from the Build menu bar.  Anyhoo, to get it back simply goto 'Tools', 'Options', navigate to 'Projects and Solutions' and ensure that 'Show advanced build configurations' is checked!  Then it was a matter of setting the configuration manager to 'Build' and 'Deploy'!&lt;/li&gt;

&lt;li&gt;&lt;p&gt;For some reason the Tahoe board completely crapped out on me big time.  Basically, my application would start up but then overwrite on the display with 'ABORT data' and output the some various debug data / registers (that could be navigated using the 'Up' and 'Down' buttons).  Not a problem you would think?  Well, it seems that the 'ABORT data' left the board is a non-interruptible state and therefore I could no longer deploy again to the device.&lt;/p&gt;

&lt;p&gt;OK - I panicked.  I tried everything to get the board back up and running and the only way I got it (after an hour messing with the board, swapping out and installing the USB drivers) was to reset the actual board at the moment when the deploy actually took place.  Whether this actually solved the problem remains to be seen - I couldn't tell through the blurred tears.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Finally, a little bit of code on resizing an image and displaying it (in this case to the dimensions of the screen).  My first natural instinct was to ensure that the bitmap object had an appropriate routine (there called 'Bitmap.StretchImage') - however, it came with the 'Remark' that the method was for backward compatibility, etc.  So, here's my attempt at demonstrating the old technique (StretchImage) and one new technique.  Enjoy...&lt;/p&gt;

&lt;p&gt;(Note: and remember to remove the 'System.Drawing' namespace from your assembly when adding images as resources!)&lt;/p&gt;

&lt;p&gt;
&lt;strong&gt;Utilising an Image Brush and Rectangle&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;
&lt;!-- --Start of code block
--&gt;&lt;DIV Style=" Margin-Left=10pt; Margin-Right=2pt;"&gt;&lt;DIV Style=" overflow='auto';"&gt;&lt;FONT Color=#808080&gt;&lt;div style="margin-left:40pt"&gt;///&lt;/FONT&gt;&lt;FONT Color=#008000&gt; &lt;/FONT&gt;&lt;FONT Color=#808080&gt;&amp;ltsummary&amp;gt&lt;/FONT&gt;&lt;FONT Color=#008000&gt; Constructor for the window&lt;/FONT&gt;&lt;FONT Color=#808080&gt;&amp;lt/summary&amp;gt&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;public&lt;/FONT&gt; MainViewWindow()&lt;br&gt;{&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:60pt"&gt;// panel control to fill the window client area&lt;/FONT&gt;&lt;FONT Color=#2b91af&gt;&lt;br&gt;Panel&lt;/FONT&gt; panel = &lt;FONT Color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT Color=#2b91af&gt;Panel&lt;/FONT&gt;();&lt;br&gt;panel.HorizontalAlignment = &lt;FONT Color=#2b91af&gt;HorizontalAlignment&lt;/FONT&gt;.Stretch;&lt;br&gt;panel.VerticalAlignment = &lt;FONT Color=#2b91af&gt;VerticalAlignment&lt;/FONT&gt;.Stretch;&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:60pt"&gt;// Generate a bitmap and obtain from the resource&lt;/FONT&gt;&lt;FONT Color=#2b91af&gt;&lt;br&gt;Bitmap&lt;/FONT&gt; bOriginal = &lt;FONT Color=#2b91af&gt;Resources&lt;/FONT&gt;.GetBitmap(&lt;FONT Color=#2b91af&gt;Resources&lt;/FONT&gt;.&lt;FONT Color=#2b91af&gt;BitmapResources&lt;/FONT&gt;.MyResourceImage);&lt;FONT Color=#2b91af&gt;&lt;br&gt;Bitmap&lt;/FONT&gt; bResized = &lt;FONT Color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT Color=#2b91af&gt;Bitmap&lt;/FONT&gt;(&lt;FONT Color=#2b91af&gt;SystemMetrics&lt;/FONT&gt;.ScreenWidth, &lt;FONT Color=#2b91af&gt;SystemMetrics&lt;/FONT&gt;.ScreenHeight);&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:60pt"&gt;// Resize the image&lt;/FONT&gt;&lt;br&gt;bResized.StretchImage(0, 0, bOriginal, bResized.Width, bResized.Height, 255);&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:60pt"&gt;// Generate an image control and set with the resized image&lt;/FONT&gt;&lt;FONT Color=#2b91af&gt;&lt;br&gt;Image&lt;/FONT&gt; img = &lt;FONT Color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT Color=#2b91af&gt;Image&lt;/FONT&gt;(bResized);&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:60pt"&gt;// Add the image to the main panel&lt;/FONT&gt;&lt;br&gt;panel.Children.Add(img);&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:60pt"&gt;// The window has exactly one child&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;this&lt;/FONT&gt;.Child = panel;&lt;/div&gt;&lt;div style="margin-left:40pt"&gt;}&lt;/div&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;!-- 
End of code block----&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;strong&gt;Utilising an Image Brush and Rectangle&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;
&lt;!-- --Start of code block
--&gt;&lt;DIV Style=" Margin-Left=10pt; Margin-Right=2pt;"&gt;&lt;DIV Style=" overflow='auto';"&gt;&lt;FONT Color=#808080&gt;&lt;div style="margin-left:40pt"&gt;///&lt;/FONT&gt;&lt;FONT Color=#008000&gt; &lt;/FONT&gt;&lt;FONT Color=#808080&gt;&amp;ltsummary&amp;gt&lt;/FONT&gt;&lt;FONT Color=#008000&gt; Constructor for the window&lt;/FONT&gt;&lt;FONT Color=#808080&gt;&amp;lt/summary&amp;gt&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;public&lt;/FONT&gt; MainViewWindow()&lt;br&gt;{&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:60pt"&gt;// panel control to fill the window client area&lt;/FONT&gt;&lt;FONT Color=#2b91af&gt;&lt;br&gt;Panel&lt;/FONT&gt; panel = &lt;FONT Color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT Color=#2b91af&gt;Panel&lt;/FONT&gt;();&lt;br&gt;panel.HorizontalAlignment = &lt;FONT Color=#2b91af&gt;HorizontalAlignment&lt;/FONT&gt;.Stretch;&lt;br&gt;panel.VerticalAlignment = &lt;FONT Color=#2b91af&gt;VerticalAlignment&lt;/FONT&gt;.Stretch;&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:60pt"&gt;// Create an image brush with the bitmap from resource&lt;/FONT&gt;&lt;FONT Color=#2b91af&gt;&lt;br&gt;ImageBrush&lt;/FONT&gt; imgBrush = &lt;FONT Color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT Color=#2b91af&gt;ImageBrush&lt;/FONT&gt;(&lt;FONT Color=#2b91af&gt;Resources&lt;/FONT&gt;.GetBitmap(&lt;FONT Color=#2b91af&gt;Resources&lt;/FONT&gt;.&lt;FONT Color=#2b91af&gt;BitmapResources&lt;/FONT&gt;.MyResourceImage));&lt;FONT Color=#008000&gt;&lt;br&gt;// Ensure it will fill the parent&lt;/FONT&gt;&lt;br&gt;imgBrush.Stretch = &lt;FONT Color=#2b91af&gt;Stretch&lt;/FONT&gt;.Fill;&lt;FONT Color=#008000&gt;&lt;br&gt;// Generate a rectangle&lt;/FONT&gt;&lt;br&gt;Microsoft.SPOT.Presentation.Shapes.&lt;FONT Color=#2b91af&gt;Rectangle&lt;/FONT&gt; rect = &lt;FONT Color=#0000ff&gt;new&lt;/FONT&gt; Microsoft.SPOT.Presentation.Shapes.&lt;FONT Color=#2b91af&gt;Rectangle&lt;/FONT&gt;();&lt;FONT Color=#008000&gt;&lt;br&gt;// Configure (e.g. lose the stroke border)&lt;/FONT&gt;&lt;br&gt;rect.Stroke = &lt;FONT Color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT Color=#2b91af&gt;Pen&lt;/FONT&gt;( &lt;FONT Color=#2b91af&gt;Color&lt;/FONT&gt;.White , 0);&lt;br&gt;rect.Fill = imgBrush;&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:60pt"&gt;// Add the image to the main panel&lt;/FONT&gt;&lt;br&gt;panel.Children.Add(rect);&lt;/div&gt;&lt;FONT Color=#008000&gt;&lt;div style="margin-left:60pt"&gt;// The window has exactly one child&lt;/FONT&gt;&lt;FONT Color=#0000ff&gt;&lt;br&gt;this&lt;/FONT&gt;.Child = panel;&lt;/div&gt;&lt;div style="margin-left:40pt"&gt;}&lt;FONT Color=#0000ff&gt;&lt;/FONT&gt;&lt;/div&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;!-- 
End of code block----&gt;
&lt;/p&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;p&gt;Note: the above code is just test / development code - no picking through my clumsy C# :p&lt;/p&gt;
&lt;p&gt;Have fun - M&lt;/p&gt;&lt;img src ="http://blogs.vbcity.com/drydo/aggbug/8310.aspx" width = "1" height = "1" /&gt;</description></item></channel></rss>