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

前端之家收集整理的这篇文章主要介绍了在Windows 8 RTM中的.NET应用程序中嵌入Powershell v2.0前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在从Windows 7升级之前尝试运行托管的PowerShell脚本时,我收到以下错误我从来没有收到此错误

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,
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(2991) : Error
in type “System.Security.AccessControl.ObjectSecurity”: Exception: The
getter method should be public,
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(2998) : Error
in type “System.Security.AccessControl.ObjectSecurity”: Exception: The
getter method should be public,
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.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中应用了以下内容

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

可能是什么问题?

解决方案是执行以下操作,而不是仅添加一个仅适用于System.Management.Automation的块,如我阅读的帖子所建议的,您需要为所有引用的PS程序集添加一个块。
  1. <runtime>
  2. <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  3. <dependentAssembly>
  4. <assemblyIdentity name="System.Management.Automation" publicKeyToken="31bf3856ad364e35" />
  5. <publisherPolicy apply="no" />
  6. </dependentAssembly>
  7. <dependentAssembly>
  8. <assemblyIdentity name="Microsoft.PowerShell.Commands.Utility" publicKeyToken="31bf3856ad364e35" />
  9. <publisherPolicy apply="no" />
  10. </dependentAssembly>
  11. <dependentAssembly>
  12. <assemblyIdentity name="Microsoft.PowerShell.ConsoleHost" publicKeyToken="31bf3856ad364e35" />
  13. <publisherPolicy apply="no" />
  14. </dependentAssembly>
  15. <dependentAssembly>
  16. <assemblyIdentity name="Microsoft.PowerShell.Commands.Management" publicKeyToken="31bf3856ad364e35" />
  17. <publisherPolicy apply="no" />
  18. </dependentAssembly>
  19. <dependentAssembly>
  20. <assemblyIdentity name="Microsoft.PowerShell.Security" publicKeyToken="31bf3856ad364e35" />
  21. <publisherPolicy apply="no" />
  22. </dependentAssembly>
  23. <dependentAssembly>
  24. <assemblyIdentity name="Microsoft.PowerShell.Commands.Diagnostics" publicKeyToken="31bf3856ad364e35" />
  25. <publisherPolicy apply="no" />
  26. </dependentAssembly>
  27. </assemblyBinding>
  28. </runtime>

猜你在找的Windows相关文章