Closed janegilring closed 4 years ago
As a workaround for avoiding the error and getting the module loaded as part of the profile, the following works: if (Get-Module -Name EditorServicesCommandSuite -ListAvailable) {
Import-Module EditorServicesCommandSuite -ErrorAction SilentlyContinue #workaround
Import-Module EditorServicesCommandSuite
Import-EditorCommand -Module EditorServicesCommandSuite
}
Thanks @janegilring! This will also be fixed in v0.5.0. Info about running a daily build in this thread.
Awesome, I'll go ahead and close the issue.
Thank you, the work around works around :-)
But only with the PowerShell extension. If I have the preview extension I get
You cannot call a method on a null-valued expression.
At C:\Users\Rob\.vscode-insiders\extensions\ms-vscode.powershell-preview-2019.11.0\modules\PowerShellEditorServices\Commands\Public\Import-EditorCommand.ps1:61 char:9
+ $extensionService = $psEditor.GetType().
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\Rob\.vscode-insiders\extensions\ms-vscode.powershell-preview-2019.11.0\modules\PowerShellEditorServices\Commands\Public\Import-EditorCommand.ps1:65 char:9
+ $editorCommands = $extensionService.GetType().
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Is this a seperate issue ?
@janegilring Thank you. After trying everything I could think of to get this to work this morning (and wasting nearly two hours !) I found this. Thanks for sharing.
OS: Windows 10 1809 PowerShell version: Core 6.2.0 VS Code: 1.32.3 VS Code PowerShell extension: 1.12.0
I have the following defined in my VS Code PowerShell profile ($profile): if (Get-Module -Name EditorServicesCommandSuite -ListAvailable) {
}
During the past day or so, the following happens when the profile is loaded after starting VS Code: Import-Module : Assembly with same name is already loaded At C:\Users\janring\Documents\PowerShell\Microsoft.VSCode_profile.ps1:7 char:5 Import-Module EditorServicesCommandSuite
I am not 100% sure, but I do believe this started happening after upgrading to PowerShell Core 6.2.
Manually running Import-Module EditorServicesCommandSuite after the error occured works fine.
It does not happen when switching from PowerShell Core to Windows PowerShell, where the module is also being loaded as part of the profile.