我有一个来自 .Net 的对象,该对象具有 SyncHashTable 类型的属性,如果没有抛出异常,则无法查看该属性。
单行复制:
[HashTable]::Synchronized(@{})
使用 repro 更容易玩多线:
$ht = new-object hashtable
$ht.add("foo", "bar")
$hts = [Hashtable]::Synchronized($ht)
$hts
错误:
format-default : Object reference not set to an instance of an object.
+ CategoryInfo : NotSpecified: (:) [format-default], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.FormatDefaultCommand
有人对此有任何见解吗?