AssemblyInstaller.CheckIfInstallable(String) Methode

Definitie

Controleert of de opgegeven assembly kan worden geïnstalleerd.

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)

Parameters

assemblyName
String

De assembly waarin moet worden gezocht naar installatieprogramma's.

Uitzonderingen

De opgegeven assembly kan niet worden geïnstalleerd.

Voorbeelden

In het volgende voorbeeld wordt de CheckIfInstallable methode toegepast op zowel een bestaande als niet-bestaande assembly en de resultaten van de aanroep worden weergegeven in de 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

Opmerkingen

De CheckIfInstallable methode bepaalt of de opgegeven assembly kan worden geïnstalleerd. Om te voorkomen dat er een uitzondering wordt gegenereerd, moet het bestand voldoen aan de volgende criteria:

  • Het bestand bestaat.

  • Het bestand is een .NET Framework-assembly.

  • De openbare typen kunnen worden gelezen uit het bestand.

  • Er is ten minste één openbare, niet-abstracte klasse die de Installer klasse uitbreidt en het Yes kenmerk bevat.

  • Er kan een exemplaar van elk installatieprogramma worden gemaakt.

Note

Als de assembly geldig is maar geen installatieprogramma's bevat, wordt er een uitzondering gegenereerd. Dit gedrag verschilt van dat tijdens de installatie, wanneer het geen fout is bij het installeren van een lege assembly.

Van toepassing op