I have notice something very obnoxious with VB.Net\'s treatment of Winform objects.
This has trashed several hours of our time. It will only get worse as we have more
Sorta. You could create a function or override ShowDialog that checks the My.Forms collection to see if the current instance is in it and if it is thrown an exception. There's not a setting that can be used to prevent it from being used.
EDIT: adding sample code illustrating the concept (using a beep instead of an exception).
Shared Function FormIsInMyForms(formName As String, frm As Form)
If formName = "Form1" Then
If frm.Equals(Form1) Then
Return True
Else
Return False
End If
End If
Return False
End Function
Public Overloads Sub ShowDialog()
If FormIsInMyForms("Form1", Me) Then
Beep()
End If
MyBase.ShowDialog()
End Sub
Doing the same thing via reflection is left as an exercise for the reader... :)