RunInstallerAttribute クラス

アセンブリのインストール時に、Visual Studio の Custom Action Installer または インストーラ ツール (Installutil.exe) が起動されるかどうかを指定します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)

構文

'宣言
<AttributeUsageAttribute(AttributeTargets.Class)> _
Public Class RunInstallerAttribute
    Inherits Attribute
'使用
Dim instance As RunInstallerAttribute
[AttributeUsageAttribute(AttributeTargets.Class)] 
public class RunInstallerAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class)] 
public ref class RunInstallerAttribute : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class) */ 
public class RunInstallerAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Class) 
public class RunInstallerAttribute extends Attribute

解説

Installer から継承するクラスが、RunInstallerAttributetrue を 設定してマークされている場合は、アセンブリのインストール時に、Visual Studio の Custom Action Installer または InstallUtil.exe が起動されます。RunInstallerAttributefalse を設定してマークされたメンバは、インストーラを起動しません。既定値は false です。

注意

trueRunInstallerAttribute を使用してプロパティをマークすると、この属性の値は定数メンバ Yes に設定されます。RunInstallerAttributefalse を設定してマークされたプロパティの場合、値は No になります。したがって、コード内でこの属性の値を確認する場合は、属性を RunInstallerAttribute.Yes または RunInstallerAttribute.No として指定する必要があります。

詳細については、属性の概要属性を使用したメタデータの拡張 の各トピックを参照してください。

使用例

MyProjectInstaller に対してインストーラを実行する必要があることを指定する例を次に示します。

<RunInstallerAttribute(True)> _
Public Class MyProjectInstaller
    Inherits Installer

    ' Insert code here.
End Class 'MyProjectInstaller
[RunInstallerAttribute(true)]
 public class MyProjectInstaller : Installer {
    // Insert code here.
 }
[RunInstallerAttribute(true)]
ref class MyProjectInstaller: public Installer{
   // Insert code here.
};
/** @attribute RunInstallerAttribute(true)
 */
public static class MyProjectInstaller extends Installer
{
    // Insert code here.
} //MyProjectInstaller

MyProjectInstaller のインスタンスを作成する例を次に示します。そのクラスの属性を取得し、RunInstallerAttribute を抽出してから、インストーラを実行するかどうかを出力します。

Public Shared Function Main() As Integer
    ' Creates a new installer.
    Dim myNewProjectInstaller As New MyProjectInstaller()
    
    ' Gets the attributes for the collection.
    Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(myNewProjectInstaller)
    
    ' Prints whether to run the installer by retrieving the
    ' RunInstallerAttribute from the AttributeCollection. 
    Dim myAttribute As RunInstallerAttribute = _
        CType(attributes(GetType(RunInstallerAttribute)), RunInstallerAttribute)

    Console.WriteLine(("Run the installer? " & myAttribute.RunInstaller.ToString()))
    Return 0
End Function 'Main
public static int Main() {
    // Creates a new installer.
    MyProjectInstaller myNewProjectInstaller = new MyProjectInstaller();
 
    // Gets the attributes for the collection.
    AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewProjectInstaller);
 
    /* Prints whether to run the installer by retrieving the 
     * RunInstallerAttribute from the AttributeCollection. */
    RunInstallerAttribute myAttribute = 
       (RunInstallerAttribute)attributes[typeof(RunInstallerAttribute)];
    Console.WriteLine("Run the installer? " + myAttribute.RunInstaller.ToString());
  
    return 0;
 }
int main()
{
   // Creates a new installer.
   MyProjectInstaller^ myNewProjectInstaller = gcnew MyProjectInstaller;

   // Gets the attributes for the collection.
   AttributeCollection^ attributes = TypeDescriptor::GetAttributes( myNewProjectInstaller );

   /* Prints whether to run the installer by retrieving the 
       * RunInstallerAttribute from the AttributeCollection. */
   RunInstallerAttribute^ myAttribute = dynamic_cast<RunInstallerAttribute^>(attributes[ RunInstallerAttribute::typeid ]);
   Console::WriteLine( "Run the installer? {0}", myAttribute->RunInstaller );
   return 0;
}
public static void main(String[] args)
{
    // Creates a new installer.
    MyProjectInstaller myNewProjectInstaller = new MyProjectInstaller();

    // Gets the attributes for the collection.
    AttributeCollection attributes = 
        TypeDescriptor.GetAttributes(myNewProjectInstaller);

    /* Prints whether to run the installer by retrieving the 
       RunInstallerAttribute from the AttributeCollection. 
     */
    RunInstallerAttribute myAttribute = 
        ((RunInstallerAttribute)(attributes.get_Item(
        RunInstallerAttribute.class.ToType())));

    Console.WriteLine(("Run the installer? " 
        + System.Convert.ToString(myAttribute.get_RunInstaller())));
} //main

継承階層

System.Object
   System.Attribute
    System.ComponentModel.RunInstallerAttribute

スレッド セーフ

この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。

プラットフォーム

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 2.0、1.1、1.0

参照

関連項目

RunInstallerAttribute メンバ
System.ComponentModel 名前空間
Attribute
Installer