Posted By: gaelhatchue | Mar 7th, 2008 @ 10:45 AM
page 1 of 1
Comments: 4 | Views: 2749

After installing IE8 Beta 1, WPF can no longer display images that have a web URI.

I un-installed IE8, it fixed the problem, re-installed it and the problem showed up again.

Here is a test program that illustrates the problem:

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.UriSource = new Uri(
                    "http://www.microsoft.com/presspass/images/gallery/logos/web/mslogo-1.jpg",
                    UriKind.Absolute);
                bitmap.EndInit();

                Image img = new Image();
                img.Source = bitmap;
                grid.Children.Add(img);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("{0}\r\n\r\n{1}", ex.Message, ex.StackTrace));
            }
        }



Here are some details on the exception that is thrown at bitmap.EndInit():

ex.Message
Value does not fall within the expected rage.

ex.StackTrace
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()

at WpfApplication5.Window1.Window_Loaded(Object sender, RoutedEventArgs e)



Here are a few "high level" things I tried to do to fix the problem:
- Changing the UriCachePolicy of the BitmapImage: none of the RequestCacheLevel enumeration values was able to fix the problem.
- Deleting the IE Cache: no luck here
- Running the test Program as Admin: no luck either


The next thing I did was setting up the .NET Framework Source Code Debugging (link):

I stepped into the code from the bitmap.EndInit() call to the MS.Win32.WinInet.get_InternetCacheFolder() call, I found that the problem occurs in the native calls to GetUrlCacheConfigInfo, which is located in wininet.dll. This DLL fails to return the internet cache folder properly.


    internal static Uri InternetCacheFolder
    {
        [SecurityCritical]
        get
        {
            // copied value 260 from orginal implementation in BitmapDownload.cs
            const int maxPathSize = 260;
            const UInt32 fieldControl = (UInt32)maxPathSize;
 
            NativeMethods.InternetCacheConfigInfo icci =
                new NativeMethods.InternetCacheConfigInfo();

            icci.CachePath = new string(new char[maxPathSize]);
            UInt32 size = (UInt32)Marshal.SizeOf(icci);
            bool passed = UnsafeNativeMethods.GetUrlCacheConfigInfo(
                ref icci,
                ref size,
                fieldControl);

            if (!passed)
            {
                int hr = Marshal.GetHRForLastWin32Error();

                if (hr != 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }
            }

            return new Uri(icci.CachePath);
        }
    }


I checked the version number of this DLL, and it matches IE8 Beta1's version number: 8.0.6001.17184


Now that I know the problem is not in WPF itself, I would like to know if XP users are having the same problem. You could simply create a simple wpf program like my test program, or xaml like this:

<Window x:Class="WpfApplication5.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300" Loaded="Window_Loaded">
    <Grid Name="grid">
        <Image Source="http://www.microsoft.com/presspass/images/gallery/logos/web/mslogo-1.jpg"/>
    </Grid>
</Window>

CannotResolveSymbol
CannotResolveSymbol
{insert caption here}
Reproducible on XP SP2 with IE 8 Beta 1 installed.

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; InfoPath.2; .NET CLR 3.5.21022; OfficeLiveConnector.1.0)
You guys should report this, probably to the IE8 Public Beta connect channel on Microsoft Connect. You'll have to log in to a passport to see the channel to apply for it. Not sure if there is any restriction to applying for that channel. However it is the best way to report bugs associated with a beta product.
CannotResolveSymbol
CannotResolveSymbol
{insert caption here}
Isshou wrote:
You guys should report this, probably to the IE8 Public Beta connect channel on Microsoft Connect. You'll have to log in to a passport to see the channel to apply for it. Not sure if there is any restriction to applying for that channel. However it is the best way to report bugs associated with a beta product.


You have to be a member of the private technical beta in order to actually post bug reports on the IE8 beta Connect site.

I'll report this to the IE beta newsgroup later tonight if it hasn't been reported there before then, though (that's the proper feedback mechanism for users of the public beta).
page 1 of 1
Comments: 4 | Views: 2749
Microsoft Communities