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
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.
I am experiencing a problem with...
Follow the instructions in the README about
capturing and sending logs.
| Name | Version |
| --- | --- |
| Operating System | Windows_NT x64 10.0.17134 |
| VSCode | 1.28.0|
| PowerShell Extension Version | 2.0.0-insiders-834 |
|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(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|;
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
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.
Ah! My fault! I will put it back in :)
I've just run into this as well
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 I am using the Powershell Preview now, i still do see the message.
Is this not merged in the preview?
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.
@rjmholt
Host version:
Major Minor Build Revision
----- ----- ----- --------
2 0 0 -1
I have already disabled the stable release
@rjmholt could you please push this out in the next preview release?
I can confirm that this is still a problem in preview 2.
Most helpful comment
Ah! My fault! I will put it back in :)