Click here to Skip to main content
15,916,951 members
Home / Discussions / C#
   

C#

 
QuestionIcon.ToBitmap() bug? Pin
Tsuda Kageyu19-May-10 0:45
Tsuda Kageyu19-May-10 0:45 
AnswerRe: Icon.ToBitmap() bug? Pin
#realJSOP19-May-10 1:23
professional#realJSOP19-May-10 1:23 
GeneralRe: Icon.ToBitmap() bug? Pin
Tsuda Kageyu19-May-10 1:48
Tsuda Kageyu19-May-10 1:48 
GeneralRe: Icon.ToBitmap() bug? Pin
Henry Minute19-May-10 1:59
Henry Minute19-May-10 1:59 
GeneralRe: Icon.ToBitmap() bug? Pin
Tsuda Kageyu19-May-10 2:37
Tsuda Kageyu19-May-10 2:37 
GeneralRe: Icon.ToBitmap() bug? Pin
Henry Minute19-May-10 2:48
Henry Minute19-May-10 2:48 
AnswerRe: Icon.ToBitmap() bug? Pin
KarstenK19-May-10 2:08
mveKarstenK19-May-10 2:08 
AnswerRe: Icon.ToBitmap() bug? Pin
The Man from U.N.C.L.E.19-May-10 3:12
The Man from U.N.C.L.E.19-May-10 3:12 
There is most definitely a bug in the .Net framework, as explained by Paulo Santos[^]. Sorry if the link breaks later, but it only seems to have survived in the Google cache.

The short of it is that the Icon class calls the Win API function CreateIconFromResourceEx to extract the appropriately sized image from the .ico file with the wrong parameters, resulting in it always loading the closest match to a 32x32 image it can find. Paulo does explain a way to force it to load a 256x256 vista icon image, however he also discovered that .png images incorrectly register their size in the .ico file as 0x0 pixels.

So, with only one .png in the .ico file it will always be loaded, but the size recorded in the Icon object will never match. Consequently a subsequent call to Icon.ToBitMap will attempt to re-load the wrong size image from the .ico file and will promptly crash with an ArgumentOutOfRangeException!

The solution is, don't use .png images in icons. Or if you do then make sure you also include a 32x32 pixel .bmp image.
Alternatively, wait for a bug fix from Microsoft, but don't hold your breath.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
[My Articles]  [My Website]

GeneralRe: Icon.ToBitmap() bug? Pin
Henry Minute19-May-10 3:26
Henry Minute19-May-10 3:26 
GeneralRe: Icon.ToBitmap() bug? Pin
Tsuda Kageyu19-May-10 3:57
Tsuda Kageyu19-May-10 3:57 
GeneralRe: Icon.ToBitmap() bug? Pin
The Man from U.N.C.L.E.19-May-10 4:03
The Man from U.N.C.L.E.19-May-10 4:03 
QuestionSorted collection Pin
Chiman119-May-10 0:42
Chiman119-May-10 0:42 
AnswerRe: Sorted collection Pin
Abhinav S19-May-10 0:59
Abhinav S19-May-10 0:59 
GeneralRe: Sorted collection Pin
Chiman119-May-10 2:08
Chiman119-May-10 2:08 
AnswerRe: Sorted collection Pin
Luc Pattyn19-May-10 1:50
sitebuilderLuc Pattyn19-May-10 1:50 
GeneralRe: Sorted collection Pin
mabo4219-May-10 5:04
mabo4219-May-10 5:04 
GeneralRe: Sorted collection Pin
Luc Pattyn19-May-10 5:41
sitebuilderLuc Pattyn19-May-10 5:41 
AnswerRe: Sorted collection Pin
riced19-May-10 3:59
riced19-May-10 3:59 
QuestionFlow layout grid control Pin
PorkyKat19-May-10 0:19
PorkyKat19-May-10 0:19 
AnswerRe: Flow layout grid control Pin
#realJSOP19-May-10 1:27
professional#realJSOP19-May-10 1:27 
GeneralRe: Flow layout grid control Pin
PorkyKat20-May-10 22:21
PorkyKat20-May-10 22:21 
Questionopen a window by clicking the button of another window. Pin
calminterlude18-May-10 23:26
calminterlude18-May-10 23:26 
AnswerRe: open a window by clicking the button of another window. Pin
Abhinav S18-May-10 23:33
Abhinav S18-May-10 23:33 
GeneralRe: open a window by clicking the button of another window. Pin
jun villena19-May-10 2:57
jun villena19-May-10 2:57 
QuestionDate Format Problem Pin
Dotnetkanna18-May-10 22:23
Dotnetkanna18-May-10 22:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.