Assembly.IsDefinedとは? わかりやすく解説

Assembly.IsDefined メソッド

指定した属性がアセンブリに適用されているかどうかを示します。

名前空間: System.Reflection
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Overridable Function
 IsDefined ( _
    attributeType As Type, _
    inherit As Boolean _
) As Boolean
Dim instance As Assembly
Dim attributeType As Type
Dim inherit As Boolean
Dim returnValue As Boolean

returnValue = instance.IsDefined(attributeType, inherit)
public virtual bool IsDefined (
    Type attributeType,
    bool inherit
)
public:
virtual bool IsDefined (
    Type^ attributeType, 
    bool inherit
)
public boolean IsDefined (
    Type attributeType, 
    boolean inherit
)
public function IsDefined (
    attributeType : Type, 
    inherit : boolean
) : boolean

パラメータ

attributeType

このアセンブリでチェックする属性の Type。

inherit

この型のオブジェクトでは、この引数は無視されます。

戻り値
属性がアセンブリに適用されている場合は true。それ以外の場合は false。

例外例外
例外の種類条件

ArgumentNullException

attributeType が null 参照 (Visual Basic では Nothing) です。

使用例使用例

属性を定義し、IsDefined を使用して属性が定義されたかどうかを示すコード例を次に示します。このコード例では、定義されなかった属性も調べます。

Imports System
Imports System.Reflection

' Set an assembly attribute.
<Assembly:AssemblyTitleAttribute("A title example")>

' Note that the suffix "Attribute" can be omitted:
' <Assembly:AssemblyTitle("A title examle")>

Public Class Test
    Public Shared Sub Main()

        ' Get the assembly that is executing this method.
        Dim asm As [Assembly] = [Assembly].GetCallingAssembly

        ' Get the attribute type just defined.
        Dim aType As Type = GetType(AssemblyTitleAttribute)

        Console.WriteLine(asm.IsDefined(aType, false))

        ' Try an attribute not defined.
        aType = GetType(AssemblyVersionAttribute)

        Console.WriteLine(asm.IsDefined(aType, false))

    End Sub
End Class

' The output is:
' True
' False
'
using System;
using System.Reflection;

// Set an assembly attribute.
[assembly:AssemblyTitleAttribute("A title example")]


// Note that the suffix "Attribute" can be omitted:
// [assembly:AssemblyTitle("A title example")]


public class Test {

    public static void Main()
 {

        // Get the assembly that is executing this method.
        Assembly asm = Assembly.GetCallingAssembly();

        // Get the attribute type just defined.
        Type aType = typeof(AssemblyTitleAttribute);
        Console.WriteLine(asm.IsDefined(aType, false));

        // Try an attribute not defined.
        aType = typeof(AssemblyVersionAttribute);
        Console.WriteLine(asm.IsDefined(aType, false));
    }
}
//
//  The output is:
//  True
//  False
//
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

_Assembly.IsDefined メソッド

メモ : このメソッドは、.NET Framework version 2.0 で新しく追加されたものです。

COM オブジェクトに、IsDefined メソッドへのバージョンに依存しないアクセスが用意されています。

このメソッドは、CLS に準拠していません。  

名前空間: System.Runtime.InteropServices
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Function IsDefined ( _
    attributeType As Type, _
    inherit As Boolean _
) As Boolean
Dim instance As _Assembly
Dim attributeType As Type
Dim inherit As Boolean
Dim returnValue As Boolean

returnValue = instance.IsDefined(attributeType, inherit)
bool IsDefined (
    Type attributeType,
    bool inherit
)
bool IsDefined (
    Type^ attributeType, 
    bool inherit
)
boolean IsDefined (
    Type attributeType, 
    boolean inherit
)
function IsDefined (
    attributeType : Type, 
    inherit : boolean
) : boolean

パラメータ

attributeType

このアセンブリで確認するカスタム属性の Type。

inherit

この型のオブジェクトでは、この引数は無視されます。

戻り値
指定された Type で識別されるカスタム属性が定義されている場合は true。それ以外の場合は false。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

Assembly.IsDefinedのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Assembly.IsDefinedのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS