IE8 Beta 1 breaks Image Download in WPF applications

I ran into this issue when IE8 was first released and it doesn't seem to have gotten much visibility elsewhere. IE8 Beta 1 breaks image downloads for WPF applications when the image has a web uri. From the stack trace this seems to be caused by wininet.dll not returning the internet cache folder correctly. A typical call stack for the error message might look something like this (when the uri specified is a http uri, I haven't checked FTP)

A first chance exception of type 'System.ArgumentException' occurred in PresentationCore.dll
        System.ArgumentException: Value does not fall within the expected range.
        at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
        at MS.Win32.WinInet.get_InternetCacheFolder()
        at System.Windows.Media.Imaging.BitmapDownload.BeginDownload(BitmapDecoder decoder, Uri uri, RequestCachePolicy uriCachePolicy, Stream stream)
        at System.Windows.Media.Imaging.LateBoundBitmapDecoder..ctor
        (Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy requestCachePolicy)
        at System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream
        (Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy, Boolean insertInDecoderCache)
        at System.Windows.Media.Imaging.BitmapImage.FinalizeCreation()
        at System.Windows.Media.Imaging.BitmapImage.EndInit()
        

It seems that others have also noticed and reproduced this error on both XP and Vista. In general image downloading seems to be one of the more perilous operations for WPF to perform. I've seen a number of other process-terminating exceptions caused by images with invalid formats etc, so it is best to be cautious. For this problem caused by IE8 "manually" constructing a web request and downloading the image yourself, and then creating a BitmapImage from the downloaded stream works and does not cause the error.