Graphics.FromHwnd(IntPtr.Zero) returns null, why?
- by Martin Moser
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