Graphics.FromHwnd(IntPtr.Zero) returns null, why?
Posted
by Martin Moser
on Stack Overflow
See other posts from Stack Overflow
or by Martin Moser
Published on 2009-03-10T08:57:18Z
Indexed on
2010/04/30
3:37 UTC
Read the original article
Hit count: 354
I'm currently investigating a problem with a 3rd party component (DevExpress) in my application. My issue is quite similar to this one DevExpress KB article. I get the same exception with more less the same stacktrace. So I used .NET Reflector to find out, what may be null in this scenario, and the only object which is a candiate to be null is Graphics. This is created with Graphics.FromHwnd(IntPtr.Zero). Because I don't have a broad knowledge about GDI, I would like to know if somebody can tell me possible scenarios when this may return null...
I tried to reproduce it in a scenario where windows is out of GDI handle's, but then I'm getting a "out of handles" - exception at least once, which is not the case in the issue I'm investigating
tia, Martin
© Stack Overflow or respective owner