I'm working on an application that is passed an HDC from a COM method (the HDC is passed in as a 32-bit long integer. When I call the static method Graphics.FromHdcInternal method while debugging I get an out of memory error thrown (this works fine when running compiled code). I'm using C# with .net 2.0 (I found there was a bug in .net 1.1 but I assume they fixed it for 2.0). Has anyone seen this and do they know a way around it? Is there some setting I need to change?