-
Notifications
You must be signed in to change notification settings - Fork 518
Description
Hi all,
Our company has supported a custom PS module for many years that, among other things, interacts with Vagrant. For as long as I've been using VS Code, any script that uses this module fails when debugging using the VS PowerShell Integrated Console; however, debugging via ISE or simply executing it from PS never fails.
Here's the exception seen in the VS PowerShell Integrated Console:
Argument 'Get-XYZ' is not recognized as a cmdlet: Could not load type 'System.Runtime.Remoting.RemotingServices' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
I finally took some time to troubleshoot this issue and can easily see the following stacktrace in EditorServices.log when any attempt is made to hit 'Get-XYZ'...
System.Management.Automation.CmdletInvocationException: The scope number '1' exceeds the number of active scopes. (Parameter 'Scope')
Actual value was 1.
---> System.Management.Automation.PSArgumentOutOfRangeException: The scope number '1' exceeds the number of active scopes. (Parameter 'Scope')
Actual value was 1.
at System.Management.Automation.SessionStateInternal.GetScopeByID(Int32 scopeID)
at System.Management.Automation.SessionStateInternal.GetScopeByID(String scopeID)
at System.Management.Automation.SessionStateInternal.GetVariableTableAtScope(String scopeID)
at Microsoft.PowerShell.Commands.VariableCommandBase.GetMatchingVariables(String name, String lookupScope, Boolean& wasFiltered, Boolean quiet)
at Microsoft.PowerShell.Commands.GetVariableCommand.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
--- End of inner exception stack trace ---
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.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.InvokeWithDebugger(IEnumerable`1 input, IList`1 output, PSInvocationSettings settings, Boolean invokeMustRun)
at System.Management.Automation.ScriptDebugger.ProcessCommand(PSCommand command, PSDataCollection`1 output)
at Microsoft.PowerShell.EditorServices.Services.PowerShellContext.PowerShell5Operations.ExecuteCommandInDebugger[TResult](PowerShellContextService powerShellContext, Runspace currentRunspace, PSCommand psCommand, Boolean sendOutputToHost, Nullable`1& debuggerResumeAction) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\Session\PowerShell5Operations.cs:line 61
at Microsoft.PowerShell.EditorServices.Services.PowerShellContextService.ExecuteCommandInDebugger[TResult](PSCommand psCommand, Boolean sendOutputToHost) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\PowerShellContextService.cs:line 1955
at Microsoft.PowerShell.EditorServices.Services.PowerShellContextService.ExecuteCommandAsync[TResult](PSCommand psCommand, StringBuilder errorMessages, ExecutionOptions executionOptions) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\PowerShellContextService.cs:line 713
Here's the relevant version details:
- VS Code: 1.51.1
- PS Extension: v2020.6.0
It should be noted that I've tried numerous PS extensions (preview and otherwise) but always get the same exception. Does anybody have any idea what might be happening?