I am working on a 64-bit MDI Winforms application. When the application starts, it proceeds to load a LOT of data -- the process memory is sitting at around 9 GB when fully loaded.
After loading, the user can select one of a number of forms, which are displayed as MDI children.
SomeForm f = new SomeForm(); // Oops. v1 of this question had null here! Edited to correct this.
f.MdiParent = this; // Boom! AccessViolationException
f.Show();
This is how I'm instantiating and showing the child form. This is exactly how I have done it dozens of times, except now I'm getting an AccessViolationException when that second line is executed. Anyone have any idea why this is giving me a problem? Some thoughts:
64-bit Winforms. It's possible that the MDI functionality under 64-bit Windows just really hasn't been tested properly. MDI is a bit old-fashioned.
Some issue with DEP (Data Execution Prevention) -- is there some kind of internal limit to the process size, beyond which DEP malfunctions?
Some kind of threading problem. The aforementioned 8+ GB of data is being loaded via a new Thread() object. This calls back to the host form frequently to update on progress, which the host form displays appropriately. (The UI code is wrapped in an Invoke statement). Once the data load process completes, the thread terminates;
Unlikely scenarios, but I'm clutching at straws.
Are you sure the new SomeForm()
doesn't fail in the constructor?
In that case you're trying to set Disposed
object's property in this line:
f.MdiParent = this;