Bug with event handler

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
phhebert
Posts: 15
Last visit: Fri Feb 26, 2021 11:23 am

Bug with event handler

Post by phhebert »

Hi,

I'm experiencing a weird problem. I don't know what I did but it seems that my current form project is not seeing event handlers in the script anymore. I mean by that when I click on any event in the "Properties" pane, the Combo Box of that event doesn't show event handlers like it usally does. Same thing happens in the combox box of the "Script" tab that shows every functions and events. When I try to register the existing script's event handlers, a pop-up tells me that the event handler is missing and want me to Insert, Remove or Ignore the missing event Handler. If i ignore it and switch tab between "Designer" and "Script", the same pop-up is constantly showing up asking me to do the same thing. What's going on?

Thanks for your help!

jvierra
Posts: 14785
Last visit: Wed May 12, 2021 3:39 pm
Answers: 9
Has voted: 3 times
Been upvoted: 9 times

Re: Bug with event handler

Post by jvierra »

Sounds like you have renamed you handlers or in some way you have a missing or broken closure.

Copy all added code and add handler back one at a time then attach each as you add them. Eventually one will show you the error.

User avatar
phhebert
Posts: 15
Last visit: Fri Feb 26, 2021 11:23 am

Re: Bug with event handler

Post by phhebert »

I tried to add them back one a time like you said and unfortunately it seems like I am stuck in a loop. When I switch back and forth between "Script" and "Designer" tab, I get the pop up each time to Insert, Remove or Ignore the missing handler that I've just added and PS Studio keeps adding the handler in the script...

jvierra
Posts: 14785
Last visit: Wed May 12, 2021 3:39 pm
Answers: 9
Has voted: 3 times
Been upvoted: 9 times

Re: Bug with event handler

Post by jvierra »

I am sorry but I cannot teach you how to use PSS. One last time. Remove all code and run the form. Add code back one handler at a time and connect t control. Run form each time to be sure code will compile. Continue until you find your mistake.

User avatar
phhebert
Posts: 15
Last visit: Fri Feb 26, 2021 11:23 am

Re: Bug with event handler

Post by phhebert »

Thank you very much. I finally make it work by removing the whole code from script and run empty form.

jvierra
Posts: 14785
Last visit: Wed May 12, 2021 3:39 pm
Answers: 9
Has voted: 3 times
Been upvoted: 9 times

Re: Bug with event handler

Post by jvierra »

An easier way to do this but only when you first notice the issue: Use "Uno" (Ctrl-Z) to back up edits one at a time until you find the bad edit. You can undo/redo to review and copy changes until you fix the issue.

Locked