VB -> C#: Missing event wiring for overridden members
See original GitHub issueVB.Net input code
Private Sub btn2_Click(sender As Object, e As EventArgs) Handles btn2.Click
lblMsg.Text = "Copying data From clipboard..."
lblMsg.Refresh()
Utils.ClipboardToDGV(uGrid.dgvData, True)
lblMsg.Text = CStr(uGrid.dgvData.Rows.Count) & " rows are ready to upload."
lblMsg.Refresh()
btn5.Visible = True
End Sub
Erroneous output
No event wiring. Function is converted correctly but event handler function is not wired to btn2.Click event
Expected output
Event handler function should be wired to btn2.Click event
Details
- Product in use: VS extension
- Version in use: 2.11.106.19330
- Did you see it working in a previous version, which?
- Any other relevant information to the issue, or your interest in contributing a fix.
Problem occurs on forms that inherit base form which has the definition of btn2 In the base form, vb.net code had a public Button btn2, but in the c# version it has a private Button _btn2 and a getter/setter called btn2
The designer code for child forms are referencing in some cases the private class member, e.g. _btn2, which causes an error since _btn2 is private, and in other cases the public member, e.g. btn3. The modifier issue is minor, the main problem is the wiring of events.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Thread: How do you implement an abstract event in VB?
I tried overriding add_DirectIOEvent - it says it's not overridable. I tried creating an add_DirectIOEvent method. It gives me this: ' ...
Read more >Handling and Raising Events
Typically, to raise an event, you add a method that is marked as protected and virtual (in C#) or Protected and Overridable (in...
Read more >How to override an event handler in the derived class ...
To override a virtual member from the base class, the derived class needs to use the override modifier, not the virtual modifier.
Read more >Troubleshooting Inherited Event Handlers - Visual Basic
Code in Event Handler Executes Twice for Every Call. An inherited event handler must not include a Handles clause. The method in the...
Read more >Overriding Events in VB
Is there a way to translate this code in VB? Most of it is easy, but I can't figure out a way to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yes that’s the jist of it. The button defined in the base class no longer has its click event wired to the handler defined in the inheriting class. The “expected CSharp output” from your comment has the correct event wiring.
I’ve made some decent progress on the small test case now. I’ll try it on some real apps tomorrow hopefully and refine it. If you’re willing to try out a prerelease build from the build system (or build it locally and try it), let me know and I can give some hints on doing so if it’s not obvious (in particular something a bit odd has happened with the local debug options attaching a debugger when building from source, so it’s best to just build it then install the output and restart)