问题描述
即时得到试图从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.PowerShell.Core, C:\ WINDOWS \ Syswow64资料\ WindowsPowerShell \ V1.0 \ types.ps1xml(2977):错误 在输入System.Security.AccessControl.ObjectSecurity:例外: getter方法应该是公开的,非空,静,和有一个 类型PSObject参数。 Microsoft.PowerShell.Core, C:\ WINDOWS \ Syswow64资料\ WindowsPowerShell \ V1.0 \ types.ps1xml(2984):错误 在输入System.Security.AccessControl.ObjectSecurity:例外: getter方法应该是公开的,非空,静,和有一个 类型PSObject参数。 Microsoft.PowerShell.Core, C:\ WINDOWS \ Syswow64资料\ WindowsPowerShell \ V1.0 \ types.ps1xml(2991):错误 在输入System.Security.AccessControl.ObjectSecurity:例外: getter方法应该是公开的,非空,静,和有一个 类型PSObject参数。 Microsoft.PowerShell.Core, C:\ WINDOWS \ Syswow64资料\ WindowsPowerShell \ V1.0 \ types.ps1xml(2998):错误 在输入System.Security.AccessControl.ObjectSecurity:例外: getter方法应该是公开的,非空,静,和有一个 类型PSObject参数。 Microsoft.PowerShell.Core, C:\ WINDOWS \ Syswow64资料\ WindowsPowerShell \ V1.0 \ types.ps1xml(3005):错误 在输入System.Security.AccessControl.ObjectSecurity:例外: getter方法应该是公开的,非空,静,和有一个 类型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应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!