使用Runspace Factory for Powershell会产生错误

我在下面使用这一行得到了以下错误,在我开始在这家新公司工作之前,我从未见过它。

System.PlatformNotSupportedException:此平台不支持ReflectionOnly加载。
在System.Reflection.Assembly.ReflectionOnlyLoadFrom(String assemblyFile)
在System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadMshSnapinAssembly(PSSnapInInfo mshsnapinInfo)

在using语句中发生错误。 我在Windows 2008 R2上使用Visual Studio 2017。

using (Runspace runspace = RunspaceFactory.CreateRunspace()) { runspace.Open(); PowerShell ps = PowerShell.Create(); ps.Runspace = runspace; PSSnapInException psex; runspace.RunspaceConfiguration.AddPSSnapIn("Citrix*", out psex); Pipeline pipeline = runspace.CreatePipeline(); Command getSession = new Command("Get-XASession"); getSession.Parameters.Add("-ComputerName", serverName); getSession.Parameters.Add("-AccountDisplayName", objWINS + "\\" + strUser); pipeline.Commands.Add(getSession); Collection output = pipeline.Invoke(); } 

事实certificate,powershell运行空间工厂不支持.NET Core应用程序。 我不得不使用普通的.NET Framework 4.7.1重新创建我的应用程序。