Compartilhar via


AssemblyInstaller.CheckIfInstallable(String) Método

Definição

Verifica para ver se o assembly especificado pode ser instalado.

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)

Parâmetros

assemblyName
String

O assembly no qual pesquisar instaladores.

Exceções

O assembly especificado não pode ser instalado.

Exemplos

No exemplo a seguir, o CheckIfInstallable método é aplicado a um assembly existente e inexistente e os resultados da chamada são exibidos no 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

Comentários

O CheckIfInstallable método determina se o assembly especificado pode ser instalado. Para evitar que uma exceção seja gerada, o arquivo deve atender aos seguintes critérios:

  • O arquivo existe.

  • O arquivo é um assembly .NET Framework.

  • Os tipos públicos podem ser lidos do arquivo.

  • Há pelo menos uma classe pública não abstrata que estende a Installer classe e contém o Yes atributo .

  • Uma instância de cada instalador pode ser criada.

Observação

Se o assembly for válido, mas não contiver instaladores, uma exceção será gerada. Esse comportamento difere daquele no momento da instalação, quando não é um erro instalar um assembly vazio.

Aplica-se a