我一直在使用PowerShell推进.NET框架,但遇到了一个我不理解的问题。以下代码运行正常:
$foo = New-Object "System.Collections.Generic.Dictionary``2[System.String,System.String]"
$foo.Add("FOO", "BAR")
$foo
Key Value
--- -----
FOO BAR
然而,这并不包括:
$bar = New-Object "System.Collections.Generic.SortedDictionary``2[System.String,System.String]"
New-Object : Cannot find type [System.Collections.Generic.SortedDictionary`2[System.String,System.String]]: make sure t
he assembly containing this type is loaded.
At line:1 char:18
+ $bar = New-Object <<<< "System.Collections.Generic.SortedDictionary``2[System.String,System.String]"
它们都在同一个程序集中,那我错过了什么?
正如答案中所指出的那样,这基本上只是PowerShell v1的问题。