Share via


AssemblyInstaller.CheckIfInstallable(String) Méthode

Définition

Vérifie si l'assembly spécifié peut être installé.

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)

Paramètres

assemblyName
String

Assembly dans lequel rechercher des programmes d'installation.

Exceptions

L'assembly spécifié ne peut pas être installé.

Exemples

Dans l’exemple suivant, la CheckIfInstallable méthode est appliquée à un assembly existant et inexistant, et les résultats de l’appel sont affichés dans la console.

#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

Remarques

La CheckIfInstallable méthode détermine si l’assembly spécifié peut être installé. Pour éviter qu’une exception ne soit levée, le fichier doit répondre aux critères suivants :

  • Le fichier existe.

  • Le fichier est un assembly .NET Framework.

  • Les types publics peuvent être lus à partir du fichier.

  • Il existe au moins une classe publique non abstraite qui étend la Installer classe et contient l’attribut Yes .

  • Un instance de chaque programme d’installation peut être créé.

Notes

Si l’assembly est valide mais ne contient aucun programme d’installation, une exception est levée. Ce comportement diffère de celui au moment de l’installation, lorsque l’installation d’un assembly vide n’est pas une erreur.

S’applique à