|Project:||The Open Toolkit library|
|Status:||in progress (review)|
When you place a GLControl directly on to a form, it works fine.
However if you put a GLControl on to a user control and put that user control on to the form,
the GLControl creates a rendering context during design time and often it fails, causing crashes or errors.
It appears to be a problem or "feature" of the WinForms designer. Nested controls are alive during design time.
If you have code that draws to the GLControl, you will see it being drawn during design time.
From what I've read, the way around it is to use if(LicenseManager.UsageMode == LicenseUsageMode.Designtime) instead of if(DesignMode)
but this test only works in the control's constructor. However it can be evaluated in the constructor and stored for later use.
I think if all the if(DesignMode) checks in GLControl.cs are changed to use a more reliable check, it should fix the problem.
It's easy to reproduce but I will upload a sample project if I can figure out how.
1. Create new WinForms project
2. Add new user control called UserControl1
3. Drop a GLControl on to the user control
4. Rebuild project
5. Drop UserControl1 on to main form
6. GLControl should crash