Dynamically Generating Icons, safely#

My development efforts went on a major tangent recently when I discovered there was no “safe” way to dynamically generate an icon in the .NET Framework (using Icon.FromHandle() requires the UnmanagedCode SecurityPermission).  What was supposed to be a very minor feature of an application - updating a tray icon with custom text - turned into a major time sucker.  I was forced to learn the innards of the Bitmap and Icon file formats and write my own conversion code.  Isn't this the kind of coding the .NET Framework is supposed to prevent?  We should be writing business logic, not common image format conversion routines.  I'm not attacking .NET in general, there is no question it has made me more productive, I'm just a little bitter that I got bitten by one of the edge cases. (I have to admit, I enjoyed doing the “low level“ coding for a while, I just wasn't planning on the time requirement)

Anyway, the good news is, I did it, and now it's done.  I wrote the code so you don't have to.  I have posted it as my first ever article on The Code Project.  Check it out and let me know what you think.

Thursday, May 20, 2004 8:21:00 PM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

Thursday, February 23, 2006 5:22:08 PM (Central Standard Time, UTC-06:00)
Thanks for the code. I found it helps also when you're getting generic GDI+ errors.

Of course, now a "little" app sits in the systray sucking major CPU. If you know anything about that, I'd love to hear about it.
Comments are closed.
All content © 2012, josh
About this site
Send mail to the author(s) Contact me
Feed your aggregator (RSS 2.0)
Joshua Flanagan
I am a software developer focused on continuous improvement in the .NET community
Los Techies

On this page
Archives
Rest of the world

Acknowledgements

Powered by: newtelligence dasBlog 2.1.8209.14743

Special thanks to LosTechies.com

Site theme based on the essence design by Jelle Druyts

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.