Ok, got a fix for it (I think).
My original suspicion was that if a Form had certain behaviours activated on it before it had been notified it had an MdiParent, it would not like switching from being a normal frame to an MDI frame. (Please excuse incorrect terminology.) So I started by minimizing the actions called before setting MdiParent, and with everything taken out that was not necessary, it seemed to work fine.
However it the actual cause of the crash was not any specific one of the calls that were taken out, but instead seems to be that too many demands are being placed on the Forms in consecutive calls.
Here's an overview of what's happening:
PlatformController.theInstance.MdiParent = mainWindowMDI;
PlatformController.theInstance.WindowState = FormWindowState.Maximized;
Here's the create() function:
public static void create()
if (theInstance == null)
theInstance = new PlatformController();
If I comment out the (in execution order) calls to Show(), Activate(), Hide(), and Show(), then it runs OK. If I try and isolate them one at a time, they all work in isolation, and (I didn't try all combinations) work ok when 3 are active and any 1 is commented out.
So the question is, are these calls necessary? From what I could see, the answer is no. Can't we just create, set MdiParent, and Hide() and then invoke Show() and Activate() when required?
Here's the info on each one, for reference for people like me who just looked at them for the first time:
"Activates the form and gives it focus."
"Conceals the control from the user... equivalent to setting the Visible property to false."
"Displays the control to the user... equivalent to setting the Visible property to true."
- Visible property
"true if the control and all its parent controls are displayed; otherwise, false. The default is true."
Anyway, so, is this the right thing to do? Trim down our WinForm setup routines to just what we require - it seems to work here. If you want, let me know, and I'll clean it up and commit a fix.
More info on using MDI and WinForms:http://msdn2.microsoft.com/en-us/library/xyhh2e7e.aspx