Reputation: 3
I'm trying to Debug an application form with buttons. Usually when we double click the button, the source window shows up with the click event for that button. However, in the latest version of .NET 5.0 release, there are a lot of things not working properly.
The following are multiple issues I'm facing that usually are not there and there is no explanation on Microsoft's Blog or MSDN about these issues:
Me.MainForm = Global.<ProjectNameHere>.<FormNameHere>
to Me.MainForm = Global.<ProjectNameHere>.Form1
& then throws an error that Form1 is not found. Why the hell this extra work? VB used to set this automatically.Public Class MainWindow
Private Sub Btn_Exit_Click(sender As Object, e As EventArgs)
Application.Exit()
End Sub
Private Sub Btn_MaxMin_Click(sender As Object, e As EventArgs)
If WindowState = FormWindowState.Normal Then
WindowState = FormWindowState.Maximized
Else
WindowState = FormWindowState.Normal
End If
End Sub
Private Sub Btn_Minimize_Click(sender As Object, e As EventArgs)
WindowState = FormWindowState.Minimized
End Sub
End Class
I tried Debugging and click events don't respond. I tried to rebuild solution and it doesn't work. I tried adding Refresh() after each line of code and doesn't work. I rechecked designer.vb and everything else and it doesn't work.
.NET 5.0 is broken when using Visual Basic WinForms. The code intellisense has become slow. Everything is slow and not working.
Product Version: Microsoft Visual Studio Community 2019 16.8.0
DotNET Framework: 5.0 (Released on 11 November 2020)
Operating System: Windows 10 20H2
Please help me fix these issues. No code provided because I don't know how will other devs reproduce these issues. I cannot find any similar problems in SO or anywhere else. I can't find any problem when using .NET 4.8 or other .NET versions other than 5.0 with WinForms and VB.
Upvotes: 0
Views: 244
Reputation: 640
Looking at your button click event handler code, I see that there is no Handles Button1.Click
.
In order for the code to run, it must be associated with the event by doing:
Private Sub Btn_Exit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Application.Exit()
End Sub
Another option is:
Private Sub Form1_Load(sender as Object, e as EventArgs) Handles Me.Load
AddHandler btnExit.Click, AddressOf Btn_Exit_Click 'run this somewhere when the form loads
End Sub
Private Sub Btn_Exit_Click(sender As Object, e As EventArgs)
Application.Exit()
End Sub
If this is helpful, great. If not, provide more of your code so we can see what's all happening.
Regards
Upvotes: 2