You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am running this very simple PowerShell WPF script using VS Code PowerShell Extension by executing (Run). After I close the form and check $error, It always contains the same error. If I execute using or in a pwsh Terminal, $error has not errors. It seems to be directly related to using the Debugger in VS Code.
Note: The $Error contents also show up in this log File (C:\Users\MySelf\AppData\Roaming\Code\logs\20250220T121920\window4\exthost\ms-vscode.powershell\PowerShell.log).
Here is the output and $Error:
PowerShell Extension v2025.0.0
Copyright (c) Microsoft Corporation.
https://aka.ms/vscode-powershell
Type 'help' to get help.
PS C:\Git\SqlQueryEditor>
PS C:\Git\SqlQueryEditor>.'C:\Git\SqlQueryEditor\archive\Test-01.ps1'
Form is closing. Cleaning up resources.
PS C:\Git\SqlQueryEditor>$error
Errors : {At line:1 char:47+ [System.Diagnostics.DebuggerHidden()]param() ,eval $stdout.sync=true
+ ~
Missing expression after unary operator ','., At line:1 char:47+ [System.Diagnostics.DebuggerHidden()]param() ,eval $stdout.sync=true
+ ~~~~
Unexpected token 'eval'in expression or statement.}
Message : At line:1 char:47+ [System.Diagnostics.DebuggerHidden()]param() ,eval $stdout.sync=true
+ ~
Missing expression after unary operator ','.
At line:1 char:47+ [System.Diagnostics.DebuggerHidden()]param() ,eval $stdout.sync=true
+ ~~~~
Unexpected token 'eval'in expression or statement.
ErrorRecord : At line:1 char:47+ [System.Diagnostics.DebuggerHidden()]param() ,eval $stdout.sync=true
+ ~
Missing expression after unary operator ','.
At line:1 char:47+ [System.Diagnostics.DebuggerHidden()]param() ,eval $stdout.sync=true
+ ~~~~
Unexpected token 'eval'in expression or statement.
WasThrownFromThrowStatement : False
TargetSite : System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject] Invoke(System.Collections.IEnumerable)
Data : {}
InnerException :
HelpLink :
Source : System.Management.Automation
HResult : -2146233087
StackTrace : at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, PSInvocationSettings settings)
at Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.InvokeAndClear[TResult](PowerShell pwsh, PSInvocationSettings invocationSettings) in
C:\__w\1\s\src\PowerShellEditorServices\Services\PowerShell\Utility\PowerShellExtensions.cs:line 76
at Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.InvokeCommand[TResult](PowerShell pwsh, PSCommand psCommand, PSInvocationSettings invocationSettings) in
C:\__w\1\s\src\PowerShellEditorServices\Services\PowerShell\Utility\PowerShellExtensions.cs:line 99
at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.ExecuteNormally(CancellationToken cancellationToken) in
C:\__w\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 136
PS C:\Git\SqlQueryEditor>
# Load the required assemblyAdd-Type-AssemblyName System.Windows.Forms
$Error.Clear()
# Create a simple form$form=New-Object System.Windows.Forms.Form
$form.Text="Simple Form"# Handle the form's Closing event$form.Add_Closing({
Write-Host"Form is closing. Cleaning up resources."
})
# Show the form$form.ShowDialog() |Out-Null
# Load the required assemblyAdd-Type-AssemblyName System.Windows.Forms
$Error.Clear()
# Create a simple form$form=New-Object System.Windows.Forms.Form
$form.Text="Simple Form"# Handle the form's Closing event$form.Add_Closing({
Write-Host"Form is closing. Cleaning up resources."
})
# Show the form$form.ShowDialog() |Out-Null
Using VS Code configured with the PowerShell Extension, Run the debugger by executing (Run).
After closing the form and check $error.
2025-02-23 17:40:19.525 [info] [PSES] [Warn - 5:40:19 PM] <Warning>Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost: Runtime exception occurred while executing command:
System.Management.Automation.ParseException: At line:1 char:47
+ [System.Diagnostics.DebuggerHidden()]param() ,eval $stdout.sync=true
+ ~
Missing expression after unary operator ','.
At line:1 char:47
+ [System.Diagnostics.DebuggerHidden()]param() ,eval $stdout.sync=true
+ ~~~~
Unexpected token 'eval' in expression or statement.
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.InvokeAndClear[TResult](PowerShell pwsh, PSInvocationSettings invocationSettings) in C:\__w\1\s\src\PowerShellEditorServices\Services\PowerShell\Utility\PowerShellExtensions.cs:line 76
at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.ExecuteNormally(CancellationToken cancellationToken) in C:\__w\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 108 |
2025-02-23 17:59:32.882 [warning] PowerShell process terminated or Extension Terminal was closed, PID: 30660
2025-02-23 17:59:32.882 [error] The PowerShell Extension Terminal has stopped, would you like to restart it? IntelliSense and other features will not work without it!
2025-02-23 17:59:33.413 [info] Language service connection closed.
2025-02-23 17:59:33.415 [info] [PSES] [Error - 5:59:33 PM] Connection to PowerShell Editor Services (the Extension Terminal) was closed. See below prompt to restart!
2025-02-23 17:59:35.138 [info] Restarting session...
2025-02-23 17:59:35.147 [info] Starting 'PowerShell (x64)' at: C:\Program Files\PowerShell\7\pwsh.exe
2025-02-23 17:59:35.361 [info] PowerShell process started with PID: 31932
2025-02-23 17:59:38.627 [info] Started PowerShell v7.5.0.
2025-02-23 17:59:39.023 [info] PowerShell is up-to-date.
2025-02-23 17:59:52.665 [info] [PSES] [Warn - 5:59:52 PM] <Warning>Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost: Runtime exception occurred while executing command:
System.Management.Automation.ParseException: At line:1 char:47
+ [System.Diagnostics.DebuggerHidden()]param() ,eval $stdout.sync=true
+ ~
Missing expression after unary operator ','.
At line:1 char:47
+ [System.Diagnostics.DebuggerHidden()]param() ,eval $stdout.sync=true
+ ~~~~
Unexpected token 'eval' in expression or statement.
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, PSInvocationSettings settings)
at Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.InvokeAndClear[TResult](PowerShell pwsh, PSInvocationSettings invocationSettings) in C:\__w\1\s\src\PowerShellEditorServices\Services\PowerShell\Utility\PowerShellExtensions.cs:line 76
at Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.InvokeCommand[TResult](PowerShell pwsh, PSCommand psCommand, PSInvocationSettings invocationSettings) in C:\__w\1\s\src\PowerShellEditorServices\Services\PowerShell\Utility\PowerShellExtensions.cs:line 99
at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.ExecuteNormally(CancellationToken cancellationToken) in C:\__w\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 136 |
The text was updated successfully, but these errors were encountered:
Hi, do you have something in your "Watch" pane, perhaps for a different language you were using in your workspace? It's still going to run, and it does not look like PowerShell code. You'll need to remove other watch expressions.
Prerequisites
Summary
I am running this very simple PowerShell WPF script using VS Code PowerShell Extension by executing (Run). After I close the form and check $error, It always contains the same error. If I execute using or in a pwsh Terminal, $error has not errors. It seems to be directly related to using the Debugger in VS Code.
Note: The $Error contents also show up in this log File (C:\Users\MySelf\AppData\Roaming\Code\logs\20250220T121920\window4\exthost\ms-vscode.powershell\PowerShell.log).
Here is the output and $Error:
PowerShell Version
Visual Studio Code Version
Extension Version
Steps to Reproduce
Save the following script to a file:
Using VS Code configured with the PowerShell Extension, Run the debugger by executing (Run).
After closing the form and check $error.
Visuals
No response
Logs
Log File (C:\Users\MySelf\AppData\Roaming\Code\logs\20250220T121920\window4\exthost\ms-vscode.powershell\PowerShell.log) Contents:
The text was updated successfully, but these errors were encountered: