The error Value Close() cannot be called while doing CreateHandle() usually happens when we try to close the form in the constructor or Load event.
the following code gives the error:
Private Sub RootForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'If Failed then close the form
Me.Close 'The exception throws -->Value Close() cannot be called while doing CreateHandle()
The form should not be closed on load event. Instead we can write the procedure to close the form, and call the procedure in button click.
But the form cannot be closed during the loading point of time. So the form's closing call should be done after loading the form.