AssemblyInstaller.CheckIfInstallable(String) Metodo

Definizione

Verifica se è possibile installare l'assembly specificato.

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)

Parametri

assemblyName
String

L'assembly nel quale cercare i programmi di installazione.

Eccezioni

Impossibile installare l'assembly specificato.

Esempio

Nell'esempio seguente il CheckIfInstallable metodo viene applicato sia a un assembly esistente che a un assembly inesistente e ai risultati della chiamata vengono visualizzati nella 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

Commenti

Il CheckIfInstallable metodo determina se è possibile installare l'assembly specificato. Per evitare la generazione di un'eccezione, il file deve soddisfare i criteri seguenti:

  • File esistente.

  • Il file è un assembly .NET Framework.

  • I tipi pubblici possono essere letti dal file.

  • Esiste almeno una classe pubblica e non astratta che estende la Installer classe e contiene l'attributo Yes .

  • È possibile creare un'istanza di ogni programma di installazione.

Nota

Se l'assembly è valido ma non contiene programmi di installazione, viene generata un'eccezione. Questo comportamento è diverso da quello in fase di installazione, quando non si verifica un errore durante l'installazione di un assembly vuoto.

Si applica a