![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have an app that runs in the system tray. It takes an icon from the programs resources then draws two rectangles on it and numbers... the wierd thing is its crashing... here is the exception I am getting System.ArgumentException: Parameter is not valid. at System.Drawing.Biutmap..ctor(Int32 width, Int32 height, PixelFormat format) at System.Drawing.Icon.ToBitmap() snip Using bmp As Bitmap = New Drawing.Icon(My.Resources.star_yellow, New Size(16, 16)).ToBitmap snip |
#3
| |||
| |||
|
|
Smokey Grindel wrote: I have an app that runs in the system tray. It takes an icon from the programs resources then draws two rectangles on it and numbers... the wierd thing is its crashing... here is the exception I am getting System.ArgumentException: Parameter is not valid. at System.Drawing.Biutmap..ctor(Int32 width, Int32 height, PixelFormat format) at System.Drawing.Icon.ToBitmap() snip Using bmp As Bitmap = New Drawing.Icon(My.Resources.star_yellow, New Size(16, 16)).ToBitmap snip It seems you're not disposing the temporary Icon you create to extract the bitmap from. If you're doing this a lot of times, it could explain the crash after a long run (all other things staying the same). If you're going to recreate this icon a gazillion times during the app lifetime, I suggest you create it just once, when the app starts, and place it somewhere your code can reach (actually, you could do the same with fntSmall and fntLarge)... Otherwise use something like: Using Bmp as Bitmap Using I as New Drawing.Icon(....) Bmp = I.ToBitmap End Using '... HTH. Regards, Branco. |
#4
| |||
| |||
|
|
cant believe I didn't catch that... thanks! also moved the font definitions up to a private member of the class so they are only created once with the class instance instead of each time.. Hopefully this was the problem "Branco Medeiros" <branco.medeiros (AT) gmail (DOT) com> wrote in message news:1174659772.437526.182130 (AT) l75g2000hse (DOT) googlegroups.com... Smokey Grindel wrote: I have an app that runs in the system tray. It takes an icon from the programs resources then draws two rectangles on it and numbers... the wierd thing is its crashing... here is the exception I am getting System.ArgumentException: Parameter is not valid. at System.Drawing.Biutmap..ctor(Int32 width, Int32 height, PixelFormat format) at System.Drawing.Icon.ToBitmap() snip Using bmp As Bitmap = New Drawing.Icon(My.Resources.star_yellow, New Size(16, 16)).ToBitmap snip It seems you're not disposing the temporary Icon you create to extract the bitmap from. If you're doing this a lot of times, it could explain the crash after a long run (all other things staying the same). If you're going to recreate this icon a gazillion times during the app lifetime, I suggest you create it just once, when the app starts, and place it somewhere your code can reach (actually, you could do the same with fntSmall and fntLarge)... Otherwise use something like: Using Bmp as Bitmap Using I as New Drawing.Icon(....) Bmp = I.ToBitmap End Using '... HTH. Regards, Branco. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |