GuidAttribute クラス

定義

自動 GUID が望ましくない場合に、明示的な Guid を指定します。

public ref class GuidAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Interface | System.AttributeTargets.Struct, Inherited=false)]
public sealed class GuidAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Interface | System.AttributeTargets.Struct, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class GuidAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Interface | System.AttributeTargets.Struct, Inherited=false)>]
type GuidAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Interface | System.AttributeTargets.Struct, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type GuidAttribute = class
    inherit Attribute
Public NotInheritable Class GuidAttribute
Inherits Attribute
継承
GuidAttribute
属性

次の例では、固定 GUID を GuidAttribute 使用して COM にエクスポートされるクラスに を適用する方法を示します。

using namespace System;
using namespace System::Runtime::InteropServices;


[GuidAttribute("9ED54F84-A89D-4fcd-A854-44251E925F09")]
public ref class SampleClass
{
    // Insert class members here.
};
using System;
using System.Runtime.InteropServices;

[GuidAttribute("9ED54F84-A89D-4fcd-A854-44251E925F09")]
public class SampleClass
{
    // Insert class members here.
}
Imports System.Runtime.InteropServices


 <GuidAttribute("9ED54F84-A89D-4fcd-A854-44251E925F09")> _
 Public Class SampleClass
     ' Insert class members here.
 End Class

注釈

この属性はアセンブリ、インターフェイス、クラス、列挙体、構造体、またはデリゲートに適用できますが、 Tlbimp.exe (タイプ ライブラリ インポーター) はタイプ ライブラリをインポートするときに適用できます。

属性に渡される文字列は、 型 Guidの許容されるコンストラクター引数である形式である必要があります。 型 Guidとの競合を回避するには、長い名前を明示的に使用します GuidAttribute 。 明示的な GUID は、型に特定の GUID が必要な場合にのみ使用します。 属性を省略すると、GUID が自動的に割り当てられます。

コンストラクター

GuidAttribute(String)

指定した GUID を使用して、GuidAttribute クラスの新しいインスタンスを初期化します。

プロパティ

TypeId

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

(継承元 Attribute)
Value

クラスの Guid を取得します。

メソッド

Equals(Object)

このインスタンスが、指定されたオブジェクトと等価であるかどうかを示す値を返します。

(継承元 Attribute)
GetHashCode()

このインスタンスのハッシュ コードを返します。

(継承元 Attribute)
GetType()

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

(継承元 Object)
IsDefaultAttribute()

派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
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)

適用対象

こちらもご覧ください