AssemblyInstaller.CheckIfInstallable(String) Metoda

Definice

Zkontroluje, jestli je možné nainstalovat zadané sestavení.

public:
 static void CheckIfInstallable(System::String ^ assemblyName);
public static void CheckIfInstallable(string assemblyName);
static member CheckIfInstallable : string -> unit
Public Shared Sub CheckIfInstallable (assemblyName As String)

Parametry

assemblyName
String

Sestavení, ve kterém se mají vyhledat instalační programy.

Výjimky

Zadané sestavení nelze nainstalovat.

Příklady

V následujícím příkladu se CheckIfInstallable metoda použije na existující i neexistující sestavení a výsledky volání se zobrazí v konzole.

#using <System.dll>
#using <System.Configuration.Install.dll>

using namespace System;
using namespace System::Configuration::Install;
int main()
{
   try
   {
      
      // Determine whether the assembly 'MyAssembly' is installable.
      AssemblyInstaller::CheckIfInstallable( "MyAssembly_CheckIfInstallable.exe" );
      Console::WriteLine( "The assembly 'MyAssembly_CheckIfInstallable' is installable" );
      
      // Determine whether the assembly 'NonExistant' is installable.
      AssemblyInstaller::CheckIfInstallable( "NonExistant" );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( e );
   }

}
using System;
using System.Configuration.Install;

class MyCheckIfInstallableClass:Installer
{
   static void Main()
   {

      try
      {
         // Determine whether the assembly 'MyAssembly' is installable.
         AssemblyInstaller.CheckIfInstallable( "MyAssembly_CheckIfInstallable.exe" );

         Console.WriteLine( "The assembly 'MyAssembly_CheckIfInstallable' is installable" );

         // Determine whether the assembly 'NonExistant' is installable.
         AssemblyInstaller.CheckIfInstallable( "NonExistant" );
      }
      catch( Exception )
      {
      }
   }
}
Imports System.Configuration.Install

Class MyCheckIfInstallableClass
   
   Shared Sub Main()

      Try
         ' Determine whether the assembly 'MyAssembly' is installable.
         AssemblyInstaller.CheckIfInstallable("MyAssembly_CheckIfInstallable.exe")
         
         Console.WriteLine("The assembly 'MyAssembly_CheckIfInstallable' is installable")
         
         ' Determine whether the assembly 'NonExistant' is installable.
         AssemblyInstaller.CheckIfInstallable("NonExistant")
       Catch 
      End Try

   End Sub

End Class

Poznámky

Metoda CheckIfInstallable určuje, zda je možné nainstalovat zadané sestavení. Aby se zabránilo vyvolání výjimky, musí soubor splňovat následující kritéria:

  • Soubor existuje.

  • Soubor je sestavení .NET Framework.

  • Veřejné typy lze ze souboru číst.

  • Existuje alespoň jedna veřejná, ne abstraktní třída, která rozšiřuje Installer třídu a obsahuje Yes atribut.

  • Je možné vytvořit instanci každého instalačního programu.

Note

Pokud je sestavení platné, ale neobsahuje žádné instalační programy, vyvolá se výjimka. Toto chování se liší od tohoto chování v době instalace, pokud není chyba instalace prázdného sestavení.

Platí pro