RunInstallerAttribute クラス

定義

アセンブリのインストール時に、Visual Studio の Custom Action Installer または 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 継承するクラスが に設定されている場合、 RunInstallerAttribute アセンブリのインストール時に trueVisual Studio のカスタム アクション インストーラーまたはInstallUtil.exeが呼び出されます。 にfalse設定されたRunInstallerAttributeメンバーは、インストーラーを呼び出しません。 既定値は、true です。

Note

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

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

コンストラクター

RunInstallerAttribute(Boolean)

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

フィールド

Default

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

No

アセンブリのインストール時に、Visual Studio の Custom Action Installer または Installutil.exe (インストーラー ツール) を起動しないことを指定します。 static フィールドは読み取り専用です。

Yes

アセンブリのインストール時に、Visual Studio の Custom Action Installer または 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)

適用対象

こちらもご覧ください