-
Notifications
You must be signed in to change notification settings - Fork 510
Debugger hangs when System.Windows.Forms
objects are used
#3410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Ok I have noticed that although F10,F11 etc are not working the terminal prompt is from the debugger eg [DBG]: PS C:\Users...\cmds\testit> so I can type v to step over or c to continue and the code jumps to the next breakpoint I am guessing that something in the Terminal should be being sent to the Visual Studio UI but is not when handling .NET calls |
I observe the same behaviour with the integrated terminal. It happens with: |
Interesting. It seems to be a protocol issue because as you say the PowerShell process itself is correctly debugging, it's just that the information that needs to be relayed from the process to the DAP server underneath VS Code. We'll need to repro this internally to make any headway, and the DAP is actually being worked on by @rjmholt so perhaps this bug will be fixed by the rework in PowerShell/PowerShellEditorServices#1459 Also the use of |
If there is anything further you need from me please let me know. I’m UK
based but retired so my time is my own.
Roger
…On Mon, 14 Jun 2021 at 21:39, Andrew Schwartzmeyer ***@***.***> wrote:
Interesting. It seems to be a protocol issue because as you say the
PowerShell process itself is correctly debugging, it's just that the
information that needs to be relayed from the process to the DAP server
underneath VS Code. We'll need to repro this internally to make any
headway, and the DAP is actually being worked on by @rjmholt
<https://github.com/rjmholt> so perhaps this bug will be fixed by the
rework in PowerShell/PowerShellEditorServices#1459
<PowerShell/PowerShellEditorServices#1459>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3410 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUMZMC7YONZKABWSPVW23HDTSZSJLANCNFSM46QZQLSA>
.
|
You are right about Forms: |
System Info: My comments touch on items previously discussed in this issue - hopefully they add something valuable. I was debugging a PowerShell script that used Get-ChildItem to process some files - the debugger worked as expected.. When I added a reference to System.Windows.Forms in the code to select a directory and ran the debugger, the debugger immediately stopped working. The debugger also stopped working on any other script, whether it had a reference to System.Windows.Forms or not. The failure was as @youngr137 described above: the terminal prompt changed to [DBG]: PS {my directory}, all the debugger toolbar buttons were grayed out except Pause / Restart / Stop, and debugger function keys (F5, F11, et al) did not work. I could, however, move to the next breakpoint by entering "c" at the [DBG] terminal prompt. In the midst of debugging a script and with the debugger toolbar partially grayed out as described above, I discovered if I moved to the next breakpoint by entering "c", then called the script again from the [DBG] terminal prompt (by entering the path and file name), the debugger would start from the beginning of the script (executing the code), advance past any previous breakpoints to the current breakpoint, and the debugger toolbar would revert to normal. When I pressed the toolbar down arrow (i.e., Step Into / F11), the debugger advanced but the toolbar was immediately grayed out again. This process could be repeated until all breakpoints were exhausted. Under any set of circumstances, the debugger never exited at the end of a script . . . I always had to stop the debugger to get a normal terminal prompt again. I also tried the debugger using VS Code version 1.56.2 with the same results. Other things that did not restore the debugger to normal operation:
Googling "Visual Studio Code debugger not working" returns a lot of complaints on many different forums (including GitHub) over the last three years. It sure would be nice if a concerted effort was made to resolve this issue in the very near future. Debugging is the ONLY reason I have VS Code installed - if it doesn't work, VS Code is useless to me. edit - added turning .NET feature off then back on |
Once I debugged a script with a reference to System.Windows.Forms, the debugger failed on all scripts. I then reinstalled Visual Studio Code (on top of the existing installation), and debug function was restored. If I again tried to debug a script with a reference to System.Windows.Forms, this cycle was repeated. |
Oof, that sounds awful. |
I see the same behaviour, VSCode runs up until a breakpoint without any issues, then when I single step (F10) it hangs forever. |
I have the same issue trying to debug a PS script that uses Windows Form. Unable to do it with VS Code I tried to use ISE (yuk!!) and at the end I was able to do it using Visual Studio 2019 and a trial copy of PowershellProTools that provides a similar capability. Please rush on fixing this issue. |
To be clear I'm not using WIndows Forms. I'm only importing the ActiveDirectory module. |
For what it's worth, you should only need to restart the PowerShell session. From the command palette in VS Code, run "PowerShell: Restart Current Session". I have made some progress debugging this but haven't found the root cause yet. |
@banyula @Abax378 @youngr137 (and anyone else with issues debugging a PowerShell script which uses an object from |
System.Windows.Forms
objects are used
System.Windows.Forms
objects are usedSystem.Windows.Forms
objects are used
I just tried and it worked as expected, not the first time after the VSIX was loaded because it hung on the DisplayDialog() method call by not displaying the dialog window. After I restarted VSCode it started working fine again being to able to stop at breakpoints after windows.form was invoked before DisplayDialog, as well as displaying the proper dialog thereafter. |
There's an entirely separate upstream issue with VS Code that GUI windows are displayed behind the VS Code window, and there's sadly nothing we as extension authors can do about it. So it sounds like it worked as best it could! This is great news. |
Here's that issue: #1175 |
I probably confused people looking at issue #3394 with my comment there yesterday as they should have been here for this issue. Essentially the issue raised appears to be fixed by the preview v2021.8.1. I am able to run scripts with System.Windows.Form objects in them and step through using F10, F11 etc. There is a remaining problem (which I don't think is the same as issue #2821) where the script can't be re-run (or any PS script run). The script fails to start and the PowerShell Extension Logs show a timeout. This is a small snippet from the log:
| Looking back through this log file the first error looks like: The file Untitled-1 does not exist but I am guessing gets created when you use File->New File. I had done this some days ago and just closed the tab that gets created. It does show up in the BREAKPOINTS section on the left of Visual Studio with 2 breakpoints. However having removed the breakpoints I still get problems on restarting/starting a script after a successful run. I stopped and restarted Visual Studio This issue is I think now raised as issue #3505 |
Super helpful, thanks @youngr137! Sometimes this feels like a game of whack-a-mole: fix one problem and another crops up 😬 |
The fix has been merged and will be in the next release! Seeing as how your new bug @youngr137 already has a separate issue, I'll mark this one resolved. |
This issue has been marked as fixed. It has been automatically closed for housekeeping purposes. |
The Powershell Preview extension is out with this fix in it! |
1623418243-1001617c-c46c-460d-a567-6024e60e18a91623416489171.zip
System Details Output
VSCode version: 1.57.0 b4c1bd0a9b03c749ea011b06c6d2676c8091a70c x64
VSCode extensions:
ms-vscode.powershell@2021.5.1
vscodevim.vim@1.21.1
PSES version: 2.4.3.0
PowerShell version:
Issue Description
Visual Studio was installed and ran for some days without problems. I saw a message indicating that an update was applied. After that I got the problem described below.
Script is:
I set a breakpoint on line 4 ($contextFilmStripAlbumPictureBoxMenuStrip = New-Object System.Windows.Forms.ContextMenuStrip)
Start debugging with F5. Stops on line 4 with highlight. Press F10 and debugger appears hung. (Run menu has grayed out the F10 and F11). These keys do not work. On occasions pressing F5 then 'Hello World' appears on terminal. Terminal prompt> is not hung.
Expected Behaviour
Expected using F10 to step over each line of code in script.
Actual Behaviour
After a number of steps Visual Studio hangs. F10,F11 are greyed out in the Run menu and the keys do not work
Attached Logs
Set to diagnostic and supplied.
The text was updated successfully, but these errors were encountered: