Error: Unhandled exception has occurred in your application

VAer-4038 776 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

Developer technologies | Windows Forms
{count} votes

Your answer

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