From 165b5e8bb4b4ee8d6702a174f65d291725a5b809 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Wed, 2 Oct 2019 17:27:46 -0700 Subject: [PATCH] apply apt state for PS7 --- .../Services/PowerShellContext/PowerShellContextService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs b/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs index c0effd3be..a9bc845d7 100644 --- a/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs +++ b/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs @@ -39,7 +39,7 @@ public class PowerShellContextService : IDisposable, IHostSupportsInteractiveSes static PowerShellContextService() { // PowerShell ApartmentState APIs aren't available in PSStandard, so we need to use reflection - if (!VersionUtils.IsNetCore) + if (!VersionUtils.IsNetCore || VersionUtils.IsPS7) { MethodInfo setterInfo = typeof(Runspace).GetProperty("ApartmentState").GetSetMethod(); Delegate setter = Delegate.CreateDelegate(typeof(Action), firstArgument: null, method: setterInfo);