We are creating a comic book application using C# and are having a mainForm created on startup as usual and then when pressing the '1' key a new form called detailForm pops up showing the details of the selected comic book. There is a also a third form that is created if you press '1' again on the detailForm that will bring up another form called comicForm that shows the actual comic book.
Our problem begins when you press '1' to go to the detailForm from the mainForm and then immediately press '2' to go back to the mainForm. When you do this, we get either of these exception. It is not consistent and can show either a System.AccessViolationException or a System.Runtime.InteropServices.SEHException.
We have a COM object on the detailForm that shows a youtube video specific to each comic book character.
There are 2 warnings being thrown when building the project each time:
1> COM Reference 'AcroPDFLib' is the interop assembly for ActiveX control 'AxAcroPDFLib' but was marked to be linked by the compiler with the /link flag. This COM reference will be treated as a reference and will not be linked.
1> COM Reference 'ShockwaveFlashObjects' is the interop assembly for ActiveX control 'AxShockwaveFlashObjects' but was marked to be linked by the compiler with the /link flag. This COM reference will be treated as a reference and will not be linked.
After it runs this code segment, it crashes each time:
private void detailForm_KeyDown_1(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.D2)
{
player.controls.stop();
this.Close();
}
if (e.KeyData == Keys.D1)
{
this.Close();
player.controls.stop();
ComicForm comicShow = new ComicForm(newComic);
comicShow.Show();
comicShow.Focus();
}
}
After the crash, it highlights this in Program.cs, but doesn't actually run it:
Application.Run(new MainForm());