“动态操作只能在同构的应用程序域中执行"启动 PowerShell 时出错 [英] "dynamic operations can only be performed in homogenous appdomain" error while launching PowerShell

查看:26
本文介绍了“动态操作只能在同构的应用程序域中执行"启动 PowerShell 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个试图从 WCF REST 服务执行的 powershell 脚本.我正在使用 System.Management.AutomationSystem.Management.Automation.Runspaces程序集.

I have a powershell script that I am trying to execute from WCF REST service.I am using the System.Management.Automation and System.Management.Automation.Runspaces assemblies.

C# 代码如下所示:

Command command = new Command(path);
command.Parameters.Add(param);
RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create();
using (Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration))
{
    runspace.Open();
    ... other code
}

一旦我尝试执行 open 语句,就会发生这个错误:

This error happens here once I try to execute the open statement:

动态操作只能在同构的 AppDomain 中执行.

Dynamic operations can only be performed in homogenous AppDomain.

我看了又看,但没有任何效果.我曾尝试将此行添加到我的 web.config:但它对我没有任何作用.

I have looked and looked but nothing worked. I have tried adding this line to my web.config: But it didn't do anything for me.

你有什么想法吗?

推荐答案

我刚刚在谷歌上搜索了那个错误,它似乎与 legacyCasPolicy 被设置为 true 相关,正如所讨论的 这里此处.将其设置为 false 也解决了您的问题.可以在此处找到有关此配置元素的详细信息.

I just googled that error and it seemed to be related to legacyCasPolicy being set to true as discussed here and here. It turns setting it to false resolved your issue as well. Detailed information about this configuration element can be found here.

这篇关于“动态操作只能在同构的应用程序域中执行"启动 PowerShell 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆