RunInstallerAttribute クラス

定義

アセンブリのインストール時に、Visual Studioカスタム アクション インストーラーと Installutil.exe (インストーラー ツール) のどちらを呼び出すかを指定します。

public ref class RunInstallerAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class)]
public class RunInstallerAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type RunInstallerAttribute = class
    inherit Attribute
Public Class RunInstallerAttribute
Inherits Attribute
継承
RunInstallerAttribute
属性

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

[RunInstallerAttribute(true)]
ref class MyProjectInstaller: public Installer{
   // Insert code here.
};
[RunInstallerAttribute(true)]
 public class MyProjectInstaller : Installer {
    // Insert code here.
 }
<RunInstallerAttribute(True)> _
Public Class MyProjectInstaller
    Inherits Installer

    ' Insert code here.
End Class

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

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 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;
 }
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

注釈

Installer から継承するクラスが RunInstallerAttributetrue に設定されている場合、アセンブリのインストール時にVisual Studioのカスタム アクション インストーラーまたは InstallUtil.exe が呼び出されます。 RunInstallerAttributefalse に設定されたメンバーは、インストーラーを呼び出しません。 既定値は true です。

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

詳細については、「属性」を参照してください。

コンストラクター

名前 説明
RunInstallerAttribute(Boolean)

RunInstallerAttribute クラスの新しいインスタンスを初期化します。

フィールド

名前 説明
Default

既定の可視性 ( No) を指定します。 この static フィールドは読み取り専用です。

No

アセンブリのインストール時に、Visual Studio カスタム アクション インストーラーまたは Installutil.exe (インストーラー ツール) を呼び出さないでください。 この static フィールドは読み取り専用です。

Yes

アセンブリのインストール時に、Visual Studioカスタム アクション インストーラーまたは Installutil.exe (インストーラー ツール) を呼び出す必要があることを指定します。 この static フィールドは読み取り専用です。

プロパティ

名前 説明
RunInstaller

アセンブリのインストール中にインストーラーを呼び出す必要があるかどうかを示す値を取得します。

TypeId

派生クラスで実装されている場合は、この Attributeの一意の識別子を取得します。

(継承元 Attribute)

メソッド

名前 説明
Equals(Object)

指定した RunInstallerAttribute の値が現在の RunInstallerAttributeと等しいかどうかを判断します。

GetHashCode()

現在の RunInstallerAttributeのハッシュ コードを生成します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

この属性が既定であるかどうかを判断します。

Match(Object)

派生クラスでオーバーライドされた場合、このインスタンスが指定したオブジェクトと等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Objectの簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

名前 説明
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

インターフェイスの型情報を取得するために使用できるオブジェクトの型情報を取得します。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されるプロパティとメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象

こちらもご覧ください