Soundbomber's picture

[Solved] Error : 6 when calling GLControl.MakeCurrent

I was getting this error recently after calling GLControl.MakeCurrent.
I was using a single context of GL and multiple GLControls in VB.Net.
The error only ever happened when I had closed the control's parent form and then re-opened it.
Error 6 is a windows Invalid Handle error, so after a little experimenting, I decided to override the GLControls' OnHandleDestroyed event and removed the MyBase call.
Now I don't really know what the implications of doing this may be, but everything seems to work fine now.
Any updates and I will keep posting.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
objarni's picture

So you created your own GLControl class "MyGLControl" via inheritance, and wrote your own version of the OnHandleDestroyed method (overriding the one found in GLControl?)?

the Fiddler's picture

The error: 6 issue was caused by an OpenTK bug that has been fixed in SVN (fix will be available in OpenTK 0.9.8). Under some circumstances, OpenTK would leak device contexts, causing it to run out of DCs after some time.

This workaround works because it stopps OpenTK from executing the leaky code. OpenTK 0.9.8+ should work fine without the workaround.

Please file a bug if you encounter error: 6 when using SVN or OpenTK 0.9.8+.

Soundbomber's picture

Just to confirm that OTK 0.9.8 works fine. No bug.