Je voudrais utiliser un HashSet dans un script PowerShell. Je pense avoir compris comment instancier objets de collection génériques en faisant:Puis-je utiliser System.Core.dll/System.Collections.Generic.HashSet dans powershell?
[type] $strType = "string"
$listClass = [System.Collections.Generic.List``1]
$listObject = $base.MakeGenericType(@($t))
$myList = New-Object $setObject
Cela fonctionne bien pour les listes et les dictionnaires, mais lorsque je tente de créer un HashSet je reçois:
Unable to find type [System.Collections.Generic.HashSet`1]: make sure that the assembly containing this type is loaded.
Alors il semble maintenant que j'ai besoin de charger System.Core.dll mais je ne peux pas sembler obtenir powershell pour charger cet assembly. Par exemple appeler [System.Reflection.Assembly] :: LoadWithPartialName ("System.Core") fait cette exception:
"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."
Tous les pointeurs?
êtes-vous dans powershell v1 ou v2? – x0n
Je suis sur Win2k8 R2 et get-host dit version 2.0 – nick
Copie possible: Voir la réponse à http://stackoverflow.com/questions/184476/powershell-generic-collections – zdan