"动态操作只能在同质的AppDomain&QUOT执行;同时发动PowerShell的错误 [英] "dynamic operations can only be performed in homogenous appdomain" error while launching PowerShell

查看:551
本文介绍了"动态操作只能在同质的AppDomain&QUOT执行;同时发动PowerShell的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我试图从WCF REST service.I执行PowerShell脚本现在用的是 System.Management.Automation 系统。 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#code是这样的:

The C# code looks like this:

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

此错误这里发生一次我试图执行的公开声明:

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.

你有什么想法?

推荐答案

我只是用Google搜索这个错误,它似乎是相关的 legacyCasPolicy 被设置为true讨论<一个href=\"http://stackoverflow.com/questions/8761113/dynamic-operations-can-only-be-performed-in-homogenous-appdomain-error\">here和<一个href=\"http://stackoverflow.com/questions/5541143/legacycasmodel-true-and-dynamic-data-operations\">here.原来其设置为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.

这篇关于&QUOT;动态操作只能在同质的AppDomain&QUOT执行;同时发动PowerShell的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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