While working on the favicon support for RSS Bandit I've been seeing some weird errors where a favicon for a particular website (e.g. Jamie Zawinski's favicon) cause a weird out of memory exception to be thrown when trying to load the image using the FromFile() method of the System.Drawing.Image class

It turns out the problem is spelled out in KB 810109: You receive a "System.OutOfMemoryException" error message when you try to use the Bitmap.FromFile method in the .NET Framework 1.0 which reads

When you try to load an image by using the Bitmap.FromFile method in the Microsoft .NET Framework 1.0, you receive the following error message:
    An unhandle exception of type 'System.OutOfMemoryException' occurred in system.drawing.dll

This problem may occur when you use the Bitmap.FromFile method and one of the following conditions is true:
•    The image file is corrupted.
•    The image file is incomplete.

Note You may experience this problem if your application is trying to use the Bitmap.FromFile method on a file stream that is not finished writing to a file.
•    The image file does not have a valid image format or GDI+ does not support the pixel format of the file.
•    The program does not have permissions to access the image file.
•    The BackgroundImage propery is set directly from the Bitmap.FromFile method.

I'm posting this here so I have a handy pointer to it once I start getting bug reports about this feature not working correctly once we ship Jubilee. This feature definitely does jazz up the look of the application, so far my favorite favicon has been from the Dead 2.0 weblog.


Friday, September 8, 2006 12:12:38 AM (GMT Daylight Time, UTC+01:00)
I have noticed this too. Well, not the exception. I use .NET 2.0 and I guess it's fixed there. But I do occasionally get favicons that the Bitmap class can't render. Both Internet Explorer and Firefox don't seem to have any problem with them however.
I also noted that some sites don't serve a .ico file, but a .jpg, .png or even a .bmp file.
And another thing I ran into was with the Apple site. They serve their icon file as text/plain.

I wrote somethign about this on my blog: http://www.digiwar.com/archives/2006/08/14/164/
Friday, September 8, 2006 8:08:04 AM (GMT Daylight Time, UTC+01:00)
How would you know your favicon was ok?
Comments are closed.