Error: Unhandled exception has occurred in your application

VAer-4038 766 Reputation points
2021-01-07T04:12:52.26+00:00

Let us say, I have ChildForm1 (selecting comboBox item, then display query result in DataGridView), and I have no problem running query on this child form.

Then I click parent form's menustrip button and switch to open ChildForm2 (at this moment, ChildForm1 is closed). If I click a button and run query from ChildForm2, sometimes it pops up this error message (Unhandled exception).

This does not only happen to ChildForm1. For most child forms, there are some query (button_click/Combo Box Selected Item Change, etc). If I open application, and randomly go to a child form, it seems it runs fine. But after running some query on this form, if I switch to another child form and running new query there, the error message could pop up.

Why?

When I open a new child form, previous child form has already closed. Quite new to Visual Studio, have no ideas what causes the issue.

Is there a way to "kill" unhandled exception before opening a new child form?

Thanks.

54228-unhandled.jpg

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,892 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.