I have written an application to aid releasing our internal systems (compressing, setting release information etc.). Everything works fine, except I get some odd behaviour.
When the MsgBox pops up saying "Rollout Successful", if you click the OK button, the application disappears from the screen (as in moves to the back), and a different application takes focus. Sometimes the application disappears from the Windows taskbar too (though can be Alt+Tabbed to, and visible if you minimise the other windows)
I've also noticed this happening inside our main application (It's an MDI parent calling DlgForm.ShowDialog(Me). I've even tried putting Me.Activate afterwards to try and recapture focus), but have no idea why it happens or even how to debug it. I never used to have this issues with MsgBox.
Does anybody know why this happens? or any ideas on how to fix it?
Private Sub ReleaseApp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReleaseApp.Click
Dim res As Assembly
If ReleaseType.Text = "" Then
MsgBox("No reason for release selected")
Exit Sub
End If
Try
res = BuildRolloutAssembly()
If res Is Nothing Then Throw New Exception("Could not create assembly")
Dim relObj As Object = res.CreateInstance("ReleaseObject")
Dim t As Type = res.GetType("ReleaseObject")
If CBool(t.InvokeMember("Release", BindingFlags.InvokeMethod, Nothing, relObj, New Object() {NewVersion.Text, RelNotes.Text, resourceFolder, ReleaseType.Text}, Nothing, Nothing, Nothing)) Then
MsgBox("Rollout Successful", MsgBoxStyle.Information)
Else
MsgBox("Rollout Failed!", MsgBoxStyle.Exclamation)
End If
Catch ex As Exception
MsgBox("Rollout Failed!", MsgBoxStyle.Exclamation)
End Try
End Sub
Edit:
If I create a new project with the following:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("Hello")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MessageBox.Show("Hello 2")
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim x As New Form1
x.ShowDialog()
End Sub
End Class
The application never loses the focus, regardless of which buttons you press. This would indicate that something else is causing this behaviour