Skip to content

2.0.0-insiders-834: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made #1571

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
skest3qc opened this issue Oct 10, 2018 · 12 comments
Assignees
Labels

Comments

@skest3qc
Copy link

Hi,
i just tried this piece of code:
"out " | Set-Clipboard
and got this error:
Set-Clipboard : Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it.

It works in Windows Powershell 5.1

@rjmholt
Copy link
Contributor

rjmholt commented Oct 10, 2018

Hi @skest3qc thanks for opening an issue. Can you please attach information on your system environment? You'll find a PowerShell snippet in the issue template you can paste into the Integrated Console that will provide this information.

@skest3qc
Copy link
Author

Issue Description

I am experiencing a problem with...

Attached Logs

Follow the instructions in the README about
capturing and sending logs.

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 10.0.17134
VSCode 1.28.0
PowerShell Extension Version 2.0.0-insiders-834

PowerShell Information

Name Value
PSVersion 5.1.17134.228
PSEdition Desktop
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.17134.228
BuildVersion 10.0.17134.228
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)
Extension Author Version
comparewinmerge skest3qc 0.0.1
csharp ms-vscode 1.16.2
gitlab-workflow fatihacet 1.2.0
PowerShell ms-vscode 2.0.0-insiders-834
VBScript luggage66 0.0.2
vscode-searchstackoverflow mimi 0.0.1
xml DotJoshJohnson 2.3.2

@rjmholt
Copy link
Contributor

rjmholt commented Oct 10, 2018

I'm not sure how easy to fix this will be -- I suspect a number of the Windows PowerShell cmdlets could display strange behaviour in our context.

Tagging @SeeminglyScience for visibility too

@SeeminglyScience
Copy link
Collaborator

The runspace just needs to be set to STA when it's created. There was a compiler directive that excluded it from Core, must have just gotten missed in the netstandard migration.

@rjmholt
Copy link
Contributor

rjmholt commented Oct 10, 2018

Ah! My fault! I will put it back in :)

@kilasuit
Copy link
Contributor

I've just run into this as well

@rjmholt
Copy link
Contributor

rjmholt commented Oct 23, 2018

GitHub should have closed this issue but didn't for some reason. The fix for this is merged. I'll trigger a v2 AppVeyor build so you can get it.

@rjmholt rjmholt closed this as completed Oct 23, 2018
@skest3qc
Copy link
Author

@rjmholt I am using the Powershell Preview now, i still do see the message.

Is this not merged in the preview?

@rjmholt
Copy link
Contributor

rjmholt commented Feb 4, 2019

This should be in the preview, see the code here.

Have you uninstalled the non-preview extension? You should be able to check the version of the backend in the Integrated Terminal with $Host.Version.

@skest3qc
Copy link
Author

skest3qc commented Feb 5, 2019

@rjmholt
Host version:

Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      0      -1

I have already disabled the stable release

@skest3qc
Copy link
Author

@rjmholt could you please push this out in the next preview release?

@ili101
Copy link

ili101 commented Mar 31, 2019

I can confirm that this is still a problem in preview 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants