AssemblyInstaller.CheckIfInstallable(String) Método

Definición

Comprueba si se puede instalar el ensamblado especificado.

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

Ensamblado donde se van a buscar los instaladores.

Excepciones

No se puede instalar el ensamblado especificado.

Ejemplos

En el ejemplo siguiente, el CheckIfInstallable método se aplica a un ensamblado existente y inexistente y los resultados de la llamada se muestran en la consola.

#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

Comentarios

El CheckIfInstallable método determina si se puede instalar el ensamblado especificado. Para evitar que se produzca una excepción, el archivo debe cumplir los criterios siguientes:

  • El archivo ya existe.

  • El archivo es un ensamblado de .NET Framework.

  • Los tipos públicos se pueden leer desde el archivo.

  • Hay al menos una clase pública y no abstracta que extiende la Installer clase y contiene el Yes atributo .

  • Se puede crear una instancia de cada instalador.

Nota

Si el ensamblado es válido pero no contiene instaladores, se produce una excepción. Este comportamiento difiere de eso en el momento de la instalación, cuando no es un error instalar un ensamblado vacío.

Se aplica a