私は自分が求めていることを半分理解しており、できる限りこれを調査しようとしました。
タイプ [Systems.Collections.Specialized.StringCollection] のオブジェクトを使用しようとしています:
$newDBFiles = new-object Systems.Collections.Specialized.StringCollection;
エラーが発生します:
new-object : Cannot find type [Systems.Collections.Specialized.StringCollection]: make sure the assembly containing this type is loaded.
At line:1 char:15
+ $newDBFiles = new-object Systems.Collections.Specialized.StringCollection;
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
私はアセンブリをいくつかの異なる方法でロードしようとしましたが、成功しませんでした:
[System.Reflection.Assembly]::LoadWithPartialName("System.Collections.Specialized") | Out-Null;
add-type -AssemblyName systems;
add-type -AssemblyName systems.collections;
ドキュメントにはAdd-Type
、.dll の場所を受け入れると記載されています。StringCollection クラスのドキュメントを見ると、必要な .dll はSystem.dll
. 私のシステムにはすでに存在しているはずです。
既に読み込まれているアセンブリを見ると、これが正しいように見えます。
[appdomain]::currentdomain.getassemblies() | sort -property fullname | format-table fullname
System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
タイプの使用に関する投稿は多数ありますが、特定のアセンブリをロードする方法については見つかりませんでした。特別な .dll ファイルが必要ですか?