Tôi muốn sử dụng HashSet trong tập lệnh PowerShell. Tôi nghĩ rằng tôi đã tìm ra cách để nhanh chóng đối tượng bộ sưu tập chung bằng cách thực hiện:Tôi có thể sử dụng System.Core.dll/System.Collections.Generic.HashSet trong powershell không?
[type] $strType = "string"
$listClass = [System.Collections.Generic.List``1]
$listObject = $base.MakeGenericType(@($t))
$myList = New-Object $setObject
này hoạt động tốt cho các danh sách và từ điển, nhưng khi tôi cố gắng tạo ra một HashSet tôi nhận được:
Unable to find type [System.Collections.Generic.HashSet`1]: make sure that the assembly containing this type is loaded.
Vì vậy, có vẻ như bây giờ tôi cần phải tải System.Core.dll nhưng tôi dường như không thể có được sức mạnh để tải lắp ráp đó. Ví dụ gọi [System.Reflection.Assembly] :: LoadWithPartialName ("System.Core") gây ngoại lệ này:
"LoadWithPartialName" with "1" argument(s): "Could not load file or assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified."
Bất kỳ con trỏ?
là bạn trong PowerShell v1 hoặc v2? – x0n
Tôi đang sử dụng Win2k8 R2 và máy chủ lưu trữ nói phiên bản 2.0 – nick
Có thể trùng lặp: Xem câu trả lời cho http://stackoverflow.com/questions/184476/powershell-generic-collections – zdan