加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

在Windows 8 RTM中的.NET应用程序中嵌入Powershell v2.0

发布时间:2020-12-13 21:10:20 所属栏目:Windows 来源:网络整理
导读:在从Windows 7升级之前尝试运行托管的PowerShell脚本时,我收到以下错误我从来没有收到此错误。 The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:WindowsSysWOW64WindowsPowerShellv1.0types.p
在从Windows 7升级之前尝试运行托管的PowerShell脚本时,我收到以下错误我从来没有收到此错误。

The following error occurred while loading the extended type data
file: Microsoft.PowerShell.Core,
C:WindowsSysWOW64WindowsPowerShellv1.0types.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:WindowsSysWOW64WindowsPowerShellv1.0types.ps1xml(2984) : Error
in type “System.Security.AccessControl.ObjectSecurity”: Exception: The
getter method should be public,
C:WindowsSysWOW64WindowsPowerShellv1.0types.ps1xml(2991) : Error
in type “System.Security.AccessControl.ObjectSecurity”: Exception: The
getter method should be public,
C:WindowsSysWOW64WindowsPowerShellv1.0types.ps1xml(2998) : Error
in type “System.Security.AccessControl.ObjectSecurity”: Exception: The
getter method should be public,
C:WindowsSysWOW64WindowsPowerShellv1.0types.ps1xml(3005) : Error
in type “System.Security.AccessControl.ObjectSecurity”: Exception: The
getter method should be public,and have one
parameter of type PSObject.

我已经在App.config中应用了以下内容

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

可能是什么问题?

解决方案是执行以下操作,而不是仅添加一个仅适用于System.Management.Automation的块,如我阅读的帖子所建议的,您需要为所有引用的PS程序集添加一个块。
<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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读