Open TheManii opened 4 years ago
Interesting... We do this bit of reflection in order to set the ApartmentState properly.
@SteveL-MSFT when you added that support back in, did the API change?
@TylerLeonhardt the API did not change. Note that only the default runspace of pwsh is STA, new runspaces are MTA by default (same behavior is WinPS)
Great. We just need to add PS7 to that first if statement then.
Issue Description
I am not able to run my existing WPF + PS based code while specifically in the integrated console due to the fact that the integrated console runs in MTA. The same code does work fine either in a normal, standalone session (which I mean as launching PWSH.exe from the run dialog/similar) of PS 7 or in a standard (non integrated console) session of PWSH in VSC. Standalone sessions and standard sessions in VSC run under STA.
Background
Powershell 7.0 preview 3 (re) added STA as an available apartment state and also set it back to being the default apartment state.
STA is needed to run WPF and WinForm code as they will only run under STA. Previously PS Core removed STA as an option because there was no need to run under anything besides MTA as WPF/WF were no longer supported, but 7.0 preview 3 defaulted back to STA as a feature point to implicitly support WPF/WF.
Attached Logs
Steps to reproduce:
[System.Threading.Thread]::CurrentThread.GetApartmentState()
3a. Output is:MTA
1b. Launch a "normal"/standalone pwsh session 2b. run
[System.Threading.Thread]::CurrentThread.GetApartmentState()
3b. Output is:STA
Expected Results for step 3a: Either the output is also
STA
or an option to use STA by defaultEnvironment Information
Visual Studio Code
PowerShell Information
Visual Studio Code Extensions
Visual Studio Code Extensions(Click to Expand)
|Extension|Author|Version| |---|---|---| |code-spell-checker|streetsidesoftware|1.7.17| |cpptools|ms-vscode|0.24.1| |csharp|ms-vscode|1.21.3| |docs-markdown|docsmsft|0.2.13| |githistory|donjayamanne|0.4.6| |java|redhat|0.47.0| |powershell|ms-vscode|2019.9.0| |remote-wsl|ms-vscode-remote|0.38.10| |vscode-java-debug|vscjava|0.20.0| |vscode-java-dependency|vscjava|0.5.1| |vscode-java-pack|vscjava|0.7.1| |vscode-java-test|vscjava|0.19.0| |vscode-maven|vscjava|0.18.1| |vscodeintellicode|VisualStudioExptTeam|1.1.9|