Greetings

I have a MDI application that when run for the first time it asks for the activation code by showing the main Windows Form (MDI parent) and another activation acquire code Windows Form showed above the main Windows Form using the ShowDialog() method. The main Windows Form including a tool strip button when I exit the activation Windows Form by clicking the X upper right corner button, that tool strip is disabled and I cannot use it to exit the application and when I click the X upper right corner button of the main Windows Form to exit the application it gives me an error Windows report message informing that "vshost-clr2.exe has stopped working" when I looked for the main Windows form FormClosed event I found that line of code

System.Environment.Exit(0)

What is the problem the causing such error "vshost-clr2.exe has stopped working" when clicking the X upper right corner of the main Windows Form (the MDI parent)

Recommended Answers

All 2 Replies

Show the code that displays the dialog form and any sub routins it calls.

This code is within the splash Windows Form timer control

private void SplashTimer_Tick(object sender, EventArgs e)
            {
                if (Serial == null)
                {
                    if (progressBarX1.Value != 100)
                        progressBarX1.PerformStep();
                    else
                        progressBarX1.Value = 0;
                }
                else
                {
                    SplashTimer.Enabled = false;
                    MainForm f = new MainForm();
                    f.FormClosed += new FormClosedEventHandler(Splash_FormClosed);
                    this.Hide();
                    f.Show();
                }
            }

This Code within the main Windows Form when the application is running for the first time and there is no activation code within the registery key

if (active == 0)
            {
                frmActivation ff = new frmActivation();
                ff.ShowDialog();
            }

When the activation Windows Form appears and I do not provide an activation code and exit the activation Windows Form using the X upper corner button. The tool strip button control in the main Windows Form is disabled and when trying to close the main Windows Form using the X upper corner button is gives me the error I mentioned "vshost-clr2.exe has stopped working"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.