Skip to content

Extension crash with Windows Powershell 5.1 : Exception encountered starting EditorServices #4483

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

Closed
6 tasks done
AlexBillon07 opened this issue Mar 29, 2023 · 5 comments
Closed
6 tasks done
Assignees
Labels
Issue-Bug A bug to squash. Resolution-Answered Will close automatically.

Comments

@AlexBillon07
Copy link

AlexBillon07 commented Mar 29, 2023

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

Since I have upgraded from Windows 2012R2 to 2016, the Powershell extension crashes each time I try to create a session with Windows Powershell 5.1

I have installed Powershell 7.3.3 and it works fine. Unfortunately, for some reasons I have to be able to use VSCode with Windows Powershell 5.1.

PowerShell Version

PS C:\Users\adm-a.billon> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14393.2248
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.2248
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Visual Studio Code Version

PS C:\Users\adm-a.billon> code --version
1.76.2
ee2b180d582a7f601fa6ecfdad8d9fd269ab1884
x64

Extension Version

PS C:\Users\adm-a.billon> code --list-extensions --show-versions | Select-String powershell

[email protected]

Steps to Reproduce

Launch a session with Windows Powershell (x64)

Visuals

image

Logs

StartEditorServices.log

[DBG]: Logging started
[DBG]: Beginning EndProcessing block
[VRB]: Removing PSReadLine
[DBG]: Creating host configuration
[DBG]: Determining REPL kind
[DBG]: REPL configured as PSReadLine
[DBG]: Configuring LSP transport
[DBG]: Configuring debug transport
[DBG]: Session file writer created
[VRB]: Adding AssemblyResolve event handler for dependency loading
[VRB]: Loading EditorServices
[VRB]: PID: 10536
[VRB]: 
== Build Details ==
- Editor Services version: 3.8.1
- Build origin:            Release
- Build commit:            016f1300cb4230cf71536cf3d4f0a4096e4ad23e
- Build time:              13/02/2023 00:00:00

[VRB]: 
== Host Startup Configuration Details ==
 - Host name:                 Visual Studio Code Host
 - Host version:              2023.2.1
 - Host profile ID:           Microsoft.VSCode
 - PowerShell host type:      System.Management.Automation.Internal.Host.InternalHost

 - REPL setting:              PSReadLine
 - Session details path:      c:\Users\adm-a.billon\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-9476-801731.json
 - Bundled modules path:      c:\Users\adm-a.billon\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules
 - Additional modules:        PowerShellEditorServices.VSCode
 - Feature flags:             

 - Log path:                  c:\Users\adm-a.billon\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\logs\1680103231-03241b20-87d4-4566-917e-83516dda30431680103223683\EditorServices.log
 - Minimum log level:         Diagnostic

 - Profile paths:
   + AllUsersAllHosts:       C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
   + AllUsersCurrentHost:    C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.VSCode_profile.ps1
   + CurrentUserAllHosts:    C:\Users\adm-a.billon\Documents\WindowsPowerShell\profile.ps1
   + CurrentUserCurrentHost: C:\Users\adm-a.billon\Documents\WindowsPowerShell\Microsoft.VSCode_profile.ps1

[DBG]: Loaded 'Microsoft.PowerShell.Commands.Diagnostics, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' from 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Diagnostics\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Commands.Diagnostics.dll'
[DBG]: Loaded 'Microsoft.WSMan.Management, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' from 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.WSMan.Management\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.WSMan.Management.dll'
[DBG]: Assembly resolve event fired for Microsoft.WSMan.Management.resources, Version=3.0.0.0, Culture=fr-FR, PublicKeyToken=31bf3856ad364e35
[DBG]: Assembly resolve event fired for Microsoft.WSMan.Management.resources, Version=3.0.0.0, Culture=fr-FR, PublicKeyToken=31bf3856ad364e35
[DBG]: Loaded 'Microsoft.WSMan.Management.resources, Version=3.0.0.0, Culture=fr, PublicKeyToken=31bf3856ad364e35' from 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.WSMan.Management.resources\v4.0_3.0.0.0_fr_31bf3856ad364e35\Microsoft.WSMan.Management.resources.dll'
[VRB]: 
== Console Details ==
 - Console input encoding: Europe de l'Ouest (DOS)
 - Console output encoding: Europe de l'Ouest (DOS)
 - PowerShell output encoding: US-ASCII

[VRB]: 
== PowerShell Details ==
- PowerShell version: 5.1.14393.2248
- Language mode:      FullLanguage

[DBG]: Loaded 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' from 'C:\Users\adm-a.billon\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules\PowerShellEditorServices\bin\Desktop\System.Runtime.InteropServices.RuntimeInformation.dll'
[VRB]: 
== Environment Details ==
 - OS description:  Microsoft Windows 10.0.14393 
 - OS architecture: X64
 - Process bitness: 64

[DBG]: Checking that .NET Framework version is at least 4.6.2
[VRB]: .NET registry version: 394802
[DBG]: Assembly resolve event fired for Microsoft.PowerShell.EditorServices, Version=3.8.1.0, Culture=neutral, PublicKeyToken=null
[VRB]: Updated PSModulePath to: 'C:\Users\adm-a.billon\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;c:\Users\adm-a.billon\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules'
[DBG]: Loading Microsoft.PowerShell.EditorServices, Version=3.8.1.0, Culture=neutral, PublicKeyToken=null from PSES dependency dir into LoadFile context
[DBG]: Validating configuration
[VRB]: Loading PowerShell Editor Services
[DBG]: Loaded 'Microsoft.PowerShell.EditorServices, Version=3.8.1.0, Culture=neutral, PublicKeyToken=null' from 'C:\Users\adm-a.billon\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules\PowerShellEditorServices\bin\Common\Microsoft.PowerShell.EditorServices.dll'
[DBG]: Loaded 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' from 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\netstandard\v4.0_2.0.0.0__cc7b13ffcd2ddd51\netstandard.dll'
[DBG]: Assembly resolve event fired for Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10
[VRB]: Starting EditorServices
[DBG]: Loaded 'System.ValueTuple, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' from 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ValueTuple\v4.0_4.0.0.0__cc7b13ffcd2ddd51\System.ValueTuple.dll'
[DBG]: Loading Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10 from PSES dependency dir into LoadFile context
[DBG]: Loaded 'Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10' from 'C:\Users\adm-a.billon\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules\PowerShellEditorServices\bin\Common\Serilog.dll'
[DBG]: Assembly resolve event fired for Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
[DBG]: Loading Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 from PSES dependency dir into LoadFile context
[DBG]: Loaded 'Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' from 'C:\Users\adm-a.billon\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules\PowerShellEditorServices\bin\Common\Microsoft.Extensions.Logging.Abstractions.dll'
[DBG]: Loader disposed
[ERR]: Exception encountered starting EditorServices. Exception logged in D:\a\_work\1\s\src\PowerShellEditorServices.Hosting\Commands\StartEditorServicesCommand.cs on line 239 in EndProcessing:
System.MissingMethodException: Méthode introuvable : 'Microsoft.PowerShell.EditorServices.Hosting.EditorServicesServerFactory Microsoft.PowerShell.EditorServices.Hosting.EditorServicesServerFactory.Create(System.String, Int32, System.IObservable`1<System.ValueTuple`2<Int32,System.String>>)'.
   à Microsoft.PowerShell.EditorServices.Hosting.EditorServicesRunner..ctor(HostLogger logger, EditorServicesConfig config, ISessionFileWriter sessionFileWriter, IReadOnlyCollection`1 loggersToUnsubscribe)
   à Microsoft.PowerShell.EditorServices.Hosting.EditorServicesLoader.LoadAndRunEditorServicesAsync()
   à Microsoft.PowerShell.EditorServices.Commands.StartEditorServicesCommand.EndProcessing()

vscode-powershell.log

3/29/2023 5:20:31 PM [DIAGNOSTIC] - Loaded settings:
{
  "powerShellAdditionalExePaths": {},
  "powerShellDefaultVersion": "Windows PowerShell (x64)",
  "powerShellExePath": "",
  "promptToUpdatePowerShell": true,
  "startAsLoginShell": {
    "osx": true,
    "linux": false
  },
  "startAutomatically": true,
  "enableProfileLoading": true,
  "helpCompletion": "BlockComment",
  "scriptAnalysis": {
    "enable": true,
    "settingsPath": "PSScriptAnalyzerSettings.psd1"
  },
  "debugging": {
    "createTemporaryIntegratedConsole": false
  },
  "developer": {
    "featureFlags": [],
    "bundledModulesPath": "../../PowerShellEditorServices/module",
    "editorServicesLogLevel": "Diagnostic",
    "editorServicesWaitForDebugger": false,
    "waitForSessionFileTimeoutSeconds": 240
  },
  "codeFormatting": {
    "autoCorrectAliases": false,
    "avoidSemicolonsAsLineTerminators": false,
    "preset": "Custom",
    "openBraceOnSameLine": true,
    "newLineAfterOpenBrace": true,
    "newLineAfterCloseBrace": true,
    "pipelineIndentationStyle": "NoIndentation",
    "whitespaceBeforeOpenBrace": true,
    "whitespaceBeforeOpenParen": true,
    "whitespaceAroundOperator": true,
    "whitespaceAfterSeparator": true,
    "whitespaceBetweenParameters": false,
    "whitespaceInsideBrace": true,
    "addWhitespaceAroundPipe": true,
    "trimWhitespaceAroundPipe": false,
    "ignoreOneLineBlock": true,
    "alignPropertyValuePairs": true,
    "useConstantStrings": false,
    "useCorrectCasing": false
  },
  "integratedConsole": {
    "showOnStartup": true,
    "startInBackground": false,
    "focusConsoleOnExecute": true,
    "useLegacyReadLine": false,
    "forceClearScrollbackBuffer": false,
    "suppressStartupBanner": false
  },
  "sideBar": {
    "CommandExplorerVisibility": true,
    "CommandExplorerExcludeFilter": []
  },
  "pester": {
    "useLegacyCodeLens": true,
    "outputVerbosity": "FromPreference",
    "debugOutputVerbosity": "Diagnostic"
  },
  "buttons": {
    "showRunButtons": true,
    "showPanelMovementButtons": false
  },
  "cwd": "",
  "enableReferencesCodeLens": true,
  "analyzeOpenDocumentsOnly": false
}
3/29/2023 5:20:31 PM [NORMAL] - Language server starting --
3/29/2023 5:20:31 PM [NORMAL] -     PowerShell executable: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
3/29/2023 5:20:31 PM [NORMAL] - Visual Studio Code v1.76.2 64-bit
3/29/2023 5:20:31 PM [NORMAL] -     PowerShell args: -NoProfile -ExecutionPolicy Bypass -Command Import-Module 'c:\Users\adm-a.billon\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2023.2.1' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\adm-a.billon\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules' -EnableConsoleRepl -StartupBanner "PowerShell Extension v2023.2.1
Copyright (c) Microsoft Corporation.

https://aka.ms/vscode-powershell
Type 'help' to get help.
" -LogLevel 'Diagnostic' -LogPath 'c:\Users\adm-a.billon\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\logs\1680103231-03241b20-87d4-4566-917e-83516dda30431680103223683\EditorServices.log' -SessionDetailsPath 'c:\Users\adm-a.billon\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-9476-801731.json' -FeatureFlags @() 
3/29/2023 5:20:31 PM [NORMAL] - PowerShell Extension v2023.2.1
3/29/2023 5:20:31 PM [NORMAL] -     PowerShell Editor Services args: Import-Module 'c:\Users\adm-a.billon\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2023.2.1' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\adm-a.billon\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules' -EnableConsoleRepl -StartupBanner "PowerShell Extension v2023.2.1
Copyright (c) Microsoft Corporation.

https://aka.ms/vscode-powershell
Type 'help' to get help.
" -LogLevel 'Diagnostic' -LogPath 'c:\Users\adm-a.billon\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\logs\1680103231-03241b20-87d4-4566-917e-83516dda30431680103223683\EditorServices.log' -SessionDetailsPath 'c:\Users\adm-a.billon\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-9476-801731.json' -FeatureFlags @() 
3/29/2023 5:20:31 PM [NORMAL] - Operating System: Windows 64-bit
3/29/2023 5:20:31 PM [NORMAL] - powershell.exe started.
3/29/2023 5:20:31 PM [NORMAL] - Waiting for session file...
3/29/2023 5:21:02 PM [WARNING] - Loading the PowerShell extension is taking longer than expected. If you're using privilege enforcement software, this can affect start up performance.

@AlexBillon07 AlexBillon07 added the Issue-Bug A bug to squash. label Mar 29, 2023
@ghost ghost added the Needs: Triage Maintainer attention needed! label Mar 29, 2023
@SydneyhSmith
Copy link
Collaborator

Thanks @AlexBillon07 it looks like you are using our February release, can you confirm this reproduces with our latest release?

@SydneyhSmith SydneyhSmith added Needs: Repro Info 🤔 and removed Needs: Triage Maintainer attention needed! labels Apr 5, 2023
@andyleejordan
Copy link
Member

andyleejordan commented Apr 5, 2023

You could try updating your .NET Framework...I have a hunch that's the problem and I'm not exactly sure what our supported minimum in the GAC scenario (Windows PowerShell 5.1) is right now. The code is checking for at least .NET Framework 4.6.2, but maybe that doesn't work any more.

Link to downloads. If you really want to experiment, try 4.7, see if it repeats (maybe restart to be sure) and then repeat up until 4.8.1 🤷

@AlexBillon07
Copy link
Author

Thanks @AlexBillon07 it looks like you are using our February release, can you confirm this reproduces with our latest release?

Same issue with the last version.

PS C:\Users\adm-a.billon> code --list-extensions --show-versions | Select-String powershell

[email protected]

@andschwa, I will try to update .NET Framework

@AlexBillon07
Copy link
Author

Hello,

I have updated .NET Framework to version 4.8 and it works now.

Thanks @andschwa

@andyleejordan
Copy link
Member

Heck yeah! Thanks for the update. I will get the check we do in the codebase and the documentation updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash. Resolution-Answered Will close automatically.
Projects
Status: Done
Development

No branches or pull requests

3 participants