ProgIdAttribute クラス

定義

ユーザーがクラスの ProgID を指定することを許可します。

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

次の例は、クラスに適用 ProgIdAttribute する方法を示しています。 アプリケーションはその後、すべての属性をMyClass取得し、のプロパティProgIdAttributeValue出力します。

[ClassInterface(ClassInterfaceType::AutoDispatch)]
[ProgId("InteropSample.MyClass")]
public ref class MyClass
{
public:
   MyClass(){}

};

int main()
{
   try
   {
      AttributeCollection^ attributes;
      attributes = TypeDescriptor::GetAttributes( MyClass::typeid );
      ProgIdAttribute^ progIdAttributeObj = dynamic_cast<ProgIdAttribute^>(attributes[ ProgIdAttribute::typeid ]);
      Console::WriteLine( "ProgIdAttribute's value is set to : {0}", progIdAttributeObj->Value );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception : {0}", e->Message );
   }
}
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ProgId("InteropSample.MyClass")]
public class MyClass
{
    public MyClass() {}
}

class TestApplication
{
   public static void Main()
   {
      try
      {
         AttributeCollection attributes;
         attributes = TypeDescriptor.GetAttributes(typeof(MyClass));
         ProgIdAttribute progIdAttributeObj = (ProgIdAttribute)attributes[typeof(ProgIdAttribute)];
         Console.WriteLine("ProgIdAttribute's value is set to : " + progIdAttributeObj.Value);
      }
      catch(Exception e)
      {
         Console.WriteLine("Exception : " + e.Message);
      }
   }
}
   <ClassInterface(ClassInterfaceType.AutoDispatch), ProgId("InteropSample.MyClass")>  _
   Public Class [MyClass]
      
      Public Sub New()
      End Sub
   End Class

   Class TestApplication
      
      Public Shared Sub Main()
         Try
            Dim attributes As AttributeCollection
            attributes = TypeDescriptor.GetAttributes(GetType([MyClass]))
            Dim progIdAttributeObj As ProgIdAttribute = CType(attributes(GetType(ProgIdAttribute)), ProgIdAttribute)
            Console.WriteLine(("ProgIdAttribute's value is set to : " + progIdAttributeObj.Value))
         Catch e As Exception
            Console.WriteLine(("Exception : " + e.Message.ToString()))
         End Try
      End Sub
   End Class
End Namespace 'InteropSample

注釈

この属性はクラスに適用できます。

ProgID は、名前空間と型名を組み合わせることで、クラスに対して自動的に生成されます。 ただし、ProgID は 39 文字に制限され、ピリオド以外の句読点は含めずに済むので、無効な ProgID が生成される可能性があります。 このような場合は、ProgID を使用して ProgIdAttributeクラスに手動で割り当てることができます。

コンストラクター

ProgIdAttribute(String)

指定した ProgID を使用して、ProgIdAttribute の新しいインスタンスを初期化します。

プロパティ

TypeId

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

(継承元 Attribute)
Value

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

メソッド

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)

適用対象