GuidAttribute Klass

Definition

Tillhandahåller en explicit Guid när ett automatiskt GUID är oönskat.

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
Arv
GuidAttribute
Attribut

Exempel

I följande exempel visas hur du tillämpar på GuidAttribute en klass som exporteras till COM med ett fast GUID.

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

Kommentarer

Du kan använda det här attributet för sammansättningar, gränssnitt, klasser, uppräkningar, strukturer eller ombud, även om Tlbimp.exe (typbiblioteksimportör) kan tillämpa det åt dig när det importerar ett typbibliotek.

Strängen som skickas till attributet måste vara i ett format som är ett acceptabelt konstruktorargument för typen Guid. Om du vill undvika konflikter med typen Guidanvänder du det långa namnet GuidAttribute explicit. Använd endast ett explicit GUID när en typ måste ha ett specifikt GUID. Om attributet utelämnas tilldelas ett GUID automatiskt.

Konstruktorer

Name Description
GuidAttribute(String)

Initierar en ny instans av GuidAttribute klassen med angivet GUID.

Egenskaper

Name Description
TypeId

När den implementeras i en härledd klass hämtar du en unik identifierare för den här Attribute.

(Ärvd från Attribute)
Value

Guid Hämtar klassens.

Metoder

Name Description
Equals(Object)

Returnerar ett värde som anger om den här instansen är lika med ett angivet objekt.

(Ärvd från Attribute)
GetHashCode()

Returnerar hash-koden för den här instansen.

(Ärvd från Attribute)
GetType()

Hämtar den aktuella instansen Type .

(Ärvd från Object)
IsDefaultAttribute()

När den åsidosättas i en härledd klass anger du om värdet för den här instansen är standardvärdet för den härledda klassen.

(Ärvd från Attribute)
Match(Object)

När den åsidosätts i en härledd klass returneras ett värde som anger om den här instansen är lika med ett angivet objekt.

(Ärvd från Attribute)
MemberwiseClone()

Skapar en ytlig kopia av den aktuella Object.

(Ärvd från Object)
ToString()

Returnerar en sträng som representerar det aktuella objektet.

(Ärvd från Object)

Explicita gränssnittsimplementeringar

Name Description
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Mappar en uppsättning namn till en motsvarande uppsättning av sändningsidentifierare.

(Ärvd från Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Hämtar typinformationen för ett objekt, som kan användas för att hämta typinformationen för ett gränssnitt.

(Ärvd från Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Hämtar antalet typinformationsgränssnitt som ett objekt tillhandahåller (antingen 0 eller 1).

(Ärvd från Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Ger åtkomst till egenskaper och metoder som exponeras av ett objekt.

(Ärvd från Attribute)

Gäller för

Se även