InstallerCollection.CopyTo メソッド
アセンブリ: System.Configuration.Install (system.configuration.install.dll 内)
構文Dim instance As InstallerCollection Dim array As Installer() Dim index As Integer instance.CopyTo(array, index)
使用例InstallerCollection クラスの CopyTo メソッドの例を次に示します。これは MyAssembly1.exe および MyAssembly2.exe の AssemblyInstaller インスタンスを作成します。これらのインスタンスは、TransactedInstaller に追加されます。インストールされるアセンブリの名前が、コンソールに表示されます。インストール プロセスによって、MyAssembly1.exe と MyAssembly2.exe の両方がインストールされます。
Dim myTransactedInstaller As New TransactedInstaller() Dim myAssemblyInstaller As AssemblyInstaller Dim myInstallContext As InstallContext ' Create an instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'. myAssemblyInstaller = New AssemblyInstaller("MyAssembly1.exe", Nothing) ' Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'. myTransactedInstaller.Installers.Add(myAssemblyInstaller) ' Create an instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'. myAssemblyInstaller = New AssemblyInstaller("MyAssembly2.exe", Nothing) ' Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'. myTransactedInstaller.Installers.Add(myAssemblyInstaller) Dim myInstallers(myTransactedInstaller.Installers.Count-1) As Installer myTransactedInstaller.Installers.CopyTo(myInstallers, 0) ' Print the assemblies to be installed. Console.WriteLine("Printing all assemblies to be installed -") Dim i As Integer For i = 0 To myInstallers.Length - 1 If myInstallers(i).GetType().Equals(GetType(AssemblyInstaller)) Then Console.WriteLine("{0} {1}", i + 1, CType(myInstallers(i), AssemblyInstaller).Path) End If Next i
TransactedInstaller myTransactedInstaller = new TransactedInstaller(); AssemblyInstaller myAssemblyInstaller; InstallContext myInstallContext; // Create an instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'. myAssemblyInstaller = new AssemblyInstaller("MyAssembly1.exe", null); // Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'. myTransactedInstaller.Installers.Add(myAssemblyInstaller); // Create an instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'. myAssemblyInstaller = new AssemblyInstaller("MyAssembly2.exe", null); // Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'. myTransactedInstaller.Installers.Add(myAssemblyInstaller); Installer[] myInstallers = new Installer[myTransactedInstaller.Installers.Count]; myTransactedInstaller.Installers.CopyTo(myInstallers, 0); // Print the assemblies to be installed. Console.WriteLine("Printing all assemblies to be installed -"); for(int i = 0; i < myInstallers.Length; i++) { if((myInstallers[i].GetType()).Equals(typeof(AssemblyInstaller))) { Console.WriteLine("{0} {1}", i + 1, ((AssemblyInstaller)myInstallers[i]).Path); } }
TransactedInstaller^ myTransactedInstaller = gcnew TransactedInstaller; AssemblyInstaller^ myAssemblyInstaller; InstallContext^ myInstallContext; // Create an instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'. myAssemblyInstaller = gcnew AssemblyInstaller( "MyAssembly1.exe",nullptr ); // Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'. myTransactedInstaller->Installers->Add( myAssemblyInstaller ); // Create an instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'. myAssemblyInstaller = gcnew AssemblyInstaller( "MyAssembly2.exe",nullptr ); // Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'. myTransactedInstaller->Installers->Add( myAssemblyInstaller ); array<Installer^>^ myInstallers = gcnew array<Installer^>(myTransactedInstaller->Installers->Count); myTransactedInstaller->Installers->CopyTo( myInstallers, 0 ); // Print the assemblies to be installed. Console::WriteLine( "Printing all assemblies to be installed -" ); for ( int i = 0; i < myInstallers->Length; i++ ) { if ( dynamic_cast<AssemblyInstaller^>( myInstallers[ i ] ) ) { Console::WriteLine( "{0} {1}", i + 1, ( (AssemblyInstaller^)( myInstallers[ i ]) )->Path ); } }
TransactedInstaller myTransactedInstaller = new TransactedInstaller(); AssemblyInstaller myAssemblyInstaller; InstallContext myInstallContext; // Create an instance of 'AssemblyInstaller' // that installs 'MyAssembly1.exe'. myAssemblyInstaller = new AssemblyInstaller("MyAssembly1.exe", null); // Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'. myTransactedInstaller.get_Installers().Add(myAssemblyInstaller); // Create an instance of 'AssemblyInstaller' // that installs 'MyAssembly2.exe'. myAssemblyInstaller = new AssemblyInstaller("MyAssembly2.exe", null); // Add the instance of 'AssemblyInstaller' //to the 'TransactedInstaller'. myTransactedInstaller.get_Installers().Add(myAssemblyInstaller); Installer myInstallers[] = new Installer[myTransactedInstaller.get_Installers().get_Count()]; myTransactedInstaller.get_Installers().CopyTo(myInstallers, 0); // Print the assemblies to be installed. Console.WriteLine("Printing all assemblies to be installed -"); for (int i = 0; i < myInstallers.length; i++) { if (myInstallers.get_Item(i).GetType(). Equals(AssemblyInstaller.class.ToType())) { Console.WriteLine("{0} {1}", System.Convert.ToString(i + 1), ((AssemblyInstaller)(myInstallers.get_Item(i))).get_Path()); } }
.NET Framework のセキュリティ
プラットフォームWindows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照- InstallerCollection.CopyTo メソッドのページへのリンク