当我尝试使用我的 C# 代码运行脚本时。我收到以下错误:
"You cannot call a method on a null-valued expression."
这会是我的 C# 代码错误吗
Runspace runSpace = RunspaceFactory.CreateRunspace();
runSpace.Open();
RunspaceInvoke runSpaceInvoker = new RunspaceInvoke(runSpace);
Pipeline pipeLine = runSpace.CreatePipeline();
pipeLine.Commands.AddScript(@"D:\NewSites\test-new\ConfigureIIS7.ps1");
try
{
pipeLine.Invoke();
}
catch (Exception ex)
{
throw ex;
}
pipeLine.Stop();
runSpace.Close();
还是我应该在我的 powershell 脚本中查找问题?shell 脚本在正常执行时工作。提前致谢。