Skip to content

Start-EditorServices.ps1: [System.Random]::new() errors in Windows with Powershell 4 #248

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
geoffian opened this issue Aug 19, 2016 · 4 comments
Labels
Issue-Bug A bug to squash.
Milestone

Comments

@geoffian
Copy link

Running on Windows 8 (Powershell v3) & Windows 2012r2 (Powershell 4) from logs:

powershell.exe started --
pid: 8304
exe: C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe
bundledModulesPath: C:\Users\BB45210.vscode\extensions\ms-vscode.PowerShell-0.7.0\modules
args: C:\Users\BB45210.vscode\extensions\ms-vscode.PowerShell-0.7.0\scripts\Start-EditorServices.ps1 -EditorServicesVersion "0.7.0" -HostName "Visual Studio Code Host" -HostProfileId "Microsoft.VSCode" -HostVersion "0.7.0" -BundledModulesPath "C:\Users\BB45210.vscode\extensions\ms-vscode.PowerShell-0.7.0\modules" -LogLevel "Verbose" -LogPath "C:\Users\BB45210.vscode\extensions\ms-vscode.PowerShell-0.7.0\logs\1471588439-EditorServices.log"

ERROR: Method invocation failed because [System.Version] doesn't contain a method
ERROR: named 'new'.

@crchad
Copy link

crchad commented Aug 19, 2016

I'm seeing the same issue since updating to 0.7 this morning. Win 8.1 & PS 4, e.g.
ERROR: Method invocation failed because [System.Random] does not contain a method
ERROR: named 'new'.
At C:\Users\USERNAME.vscode\extensions\ms-vscode.PowerShell-0.7.0\scripts\Star
t-EditorServices.ps1:103 char:1

  • $rand = [System.Random]::new()

Also includes several others e.g.:
ERROR: Method invocation failed because [System.Random] does not contain a method
ERROR: named 'new'.
ERROR: Method invocation failed because [System.Version] does not contain a method
ERROR: named 'new'.
ERROR: Method invocation failed because [System.Net.Sockets.TcpListener] does not
ERROR: contain a method named 'new'.

@philkloose
Copy link

I'll just add that I'm seeing the same issue on Win7x64 (PowerShell v3).

@daviwil daviwil added this to the 0.7.1 milestone Aug 19, 2016
@daviwil daviwil added the Issue-Bug A bug to squash. label Aug 19, 2016
@daviwil
Copy link
Contributor

daviwil commented Aug 19, 2016

Hi guys, thanks for the report! There's definitely an issue on older Windows systems, I'll try to ship an update early next week to address this.

In the meantime you can remove the installed PowerShell extension and download one of the older releases from our releases page. Just extract the previous release package into $HOME\.vscode\extensions and restart VS Code.

daviwil added a commit to PowerShell/PowerShellEditorServices that referenced this issue Aug 23, 2016
This change resolves some compatibility issues with PowerShell v3 and v4.
The new PowerShellEditorServices.psm1 file was using the ::new()
constructor syntax that is only available in PowerShell v5 and higher.
Also, the AstVisitor2 class was causing issues with Add-Type when being
loaded into the older versions of PowerShell.

Issue #276 tracks the need for bringing AstVisitor2 usage back after a
more appropriate multi-version support strategy is designed.

Related to PowerShell/vscode-powershell#248
daviwil added a commit to PowerShell/PowerShellEditorServices that referenced this issue Aug 23, 2016
This change resolves some compatibility issues with PowerShell v3 and v4.
The new PowerShellEditorServices.psm1 file was using the ::new()
constructor syntax that is only available in PowerShell v5 and higher.
Also, the AstVisitor2 class was causing issues with Add-Type when being
loaded into the older versions of PowerShell.

Issue #276 tracks the need for bringing AstVisitor2 usage back after a
more appropriate multi-version support strategy is designed.

Related to PowerShell/vscode-powershell#248
daviwil added a commit that referenced this issue Aug 24, 2016
This change fixes #248 which reports that the extension cannot be loaded
on Windows 7 machines running PowerShell v3 (and probably also any machine
running PowerShell v4).  The Start-EditorServices.ps1 script relied in
features only present in PowerShell v5.  New code paths have been added to
the script to make it compatible with v3 and v4.
@daviwil daviwil mentioned this issue Aug 24, 2016
@daviwil
Copy link
Contributor

daviwil commented Aug 24, 2016

Just shipped a new release with a fix for this issue! Let me know if it resolves everything for you.

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.
Projects
None yet
Development

No branches or pull requests

4 participants