Jump to content

Recommended Posts

Posted

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: 9.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 something like this:

 

<font color="#0000ff" size=2><font color="#0000ff" size=2>

 

 

***

*******

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...