ProgIdAttribute クラス
アセンブリ: mscorlib (mscorlib.dll 内)

<AttributeUsageAttribute(AttributeTargets.Class, Inherited:=False)> _ <ComVisibleAttribute(True)> _ Public NotInheritable Class ProgIdAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Class, Inherited=false)] [ComVisibleAttribute(true)] public sealed class ProgIdAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class, Inherited=false)] [ComVisibleAttribute(true)] public ref class ProgIdAttribute sealed : public Attribute

ProgID は、名前空間と型名を結合することによって、クラスに対して自動的に生成されます。ただし、ProgID は 39 文字に制限され、ピリオド以外の区切り記号を使用できないため、無効な ProgID が生成されることがあります。このような場合は、ProgIdAttribute を使用して、ProgID をクラスに手動で割り当てることができます。

ProgIdAttribute をクラスに適用する方法を次の例に示します。この例では、MyClass のすべての属性を取得し、ProgIdAttribute の Value プロパティを出力します。
<ClassInterface(ClassInterfaceType.AutoDispatch), ProgId("InteropSample.MyClass")> _ Public Class [MyClass] Public Sub New() End Sub 'New End Class '[MyClass] 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 'Main End Class 'TestApplication End Namespace 'InteropSample
[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 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 ); } }
/** @attribute ClassInterface(ClassInterfaceType.AutoDispatch) */ /** @attribute ProgId("InteropSample.MyClass") */ public class MyClass { public MyClass() { } //MyClass } //MyClass class TestApplication { public static void main(String[] args) { try { AttributeCollection attributes; attributes = TypeDescriptor.GetAttributes(MyClass.class.ToType()); ProgIdAttribute progIdAttributeObj = (ProgIdAttribute) (attributes.get_Item(ProgIdAttribute.class.ToType())); Console.WriteLine("ProgIdAttribute's value is set to : " + progIdAttributeObj.get_Value()); } catch (System.Exception e) { Console.WriteLine("Exception : " + e.get_Message()); } } //main } //TestApplication

System.Attribute
System.Runtime.InteropServices.ProgIdAttribute


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- ProgIdAttribute クラスのページへのリンク