在Windows 8 RTM嵌入的Powershell 2.0的.NET应用程序 [英] Embedding Powershell v2.0 in .NET app on Windows 8 RTM

查看:157
本文介绍了在Windows 8 RTM嵌入的Powershell 2.0的.NET应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时得到试图从Windows 7升级我从来没有得到这个错误之前运行托管PowerShell脚本时,下面的错误。

Im getting the following error when trying to run hosted powershell scripts before upgrading from Windows 7 I never got this error.

在加载扩展类型数据出现以下错误   文件:Microsoft.P​​owerShell.Core,   C:\ WINDOWS \ Syswow64资料\ WindowsPowerShell \ V1.0 \ types.ps1xml(2977):错误   在输入System.Security.AccessControl.ObjectSecurity:例外:   getter方法​​应该是公开的,非空,静,和有一个   类型PSObject参数。 Microsoft.P​​owerShell.Core,   C:\ WINDOWS \ Syswow64资料\ WindowsPowerShell \ V1.0 \ types.ps1xml(2984):错误   在输入System.Security.AccessControl.ObjectSecurity:例外:   getter方法​​应该是公开的,非空,静,和有一个   类型PSObject参数。 Microsoft.P​​owerShell.Core,   C:\ WINDOWS \ Syswow64资料\ WindowsPowerShell \ V1.0 \ types.ps1xml(2991):错误   在输入System.Security.AccessControl.ObjectSecurity:例外:   getter方法​​应该是公开的,非空,静,和有一个   类型PSObject参数。 Microsoft.P​​owerShell.Core,   C:\ WINDOWS \ Syswow64资料\ WindowsPowerShell \ V1.0 \ types.ps1xml(2998):错误   在输入System.Security.AccessControl.ObjectSecurity:例外:   getter方法​​应该是公开的,非空,静,和有一个   类型PSObject参数。 Microsoft.P​​owerShell.Core,   C:\ WINDOWS \ Syswow64资料\ WindowsPowerShell \ V1.0 \ types.ps1xml(3005):错误   在输入System.Security.AccessControl.ObjectSecurity:例外:   getter方法​​应该是公开的,非空,静,和有一个   类型PSObject的参数。

The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(2977) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject. Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(2984) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject. Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(2991) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject. Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(2998) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject. Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3005) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.

我已经申请在App.config中以下

I have applied the following in App.config

  <dependentAssembly>
              <assemblyIdentity name="System.Management.Automation" publicKeyToken="31bf3856ad364e35" />
              <publisherPolicy apply="no" />
            </dependentAssembly>

什么可能的问题是什么?

what could the issue be?

推荐答案

解决的办法是做到以下几点,而不是仅仅增加一个块仅作为建议的我看了帖子System.Management.Automation,您需要添加一个是对所有引用的PS组件。

The solution is to do the following, rather than only adding a block for only System.Management.Automation as suggested by the posts I read, you need to add one for all referenced PS assemblies.

  <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Management.Automation" publicKeyToken="31bf3856ad364e35" />
            <publisherPolicy apply="no" />
          </dependentAssembly>
        <dependentAssembly>
          <assemblyIdentity name="Microsoft.PowerShell.Commands.Utility" publicKeyToken="31bf3856ad364e35" />
          <publisherPolicy apply="no" />
        </dependentAssembly>
        <dependentAssembly>
          <assemblyIdentity name="Microsoft.PowerShell.ConsoleHost" publicKeyToken="31bf3856ad364e35" />
          <publisherPolicy apply="no" />
        </dependentAssembly>
        <dependentAssembly>
          <assemblyIdentity name="Microsoft.PowerShell.Commands.Management" publicKeyToken="31bf3856ad364e35" />
          <publisherPolicy apply="no" />
        </dependentAssembly>
        <dependentAssembly>
          <assemblyIdentity name="Microsoft.PowerShell.Security" publicKeyToken="31bf3856ad364e35" />
          <publisherPolicy apply="no" />
        </dependentAssembly>
        <dependentAssembly>
          <assemblyIdentity name="Microsoft.PowerShell.Commands.Diagnostics" publicKeyToken="31bf3856ad364e35" />
          <publisherPolicy apply="no" />
        </dependentAssembly>
        </assemblyBinding>
    </runtime>

这篇关于在Windows 8 RTM嵌入的Powershell 2.0的.NET应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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