ProgIdAttribute Class
.NET Framework 3.0
Allows the user to specify the ProgID of a class.
Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Assembly: mscorlib (in mscorlib.dll)
'Declaration <AttributeUsageAttribute(AttributeTargets.Class, Inherited:=False)> _ <ComVisibleAttribute(True)> _ Public NotInheritable Class ProgIdAttribute Inherits Attribute 'Usage Dim instance As ProgIdAttribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class, Inherited=false) */ /** @attribute ComVisibleAttribute(true) */ public final class ProgIdAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Class, Inherited=false) ComVisibleAttribute(true) public final class ProgIdAttribute extends Attribute
Not applicable.
You can apply this attribute to classes.
ProgIDs are automatically generated for a class by combining the namespace with the type name. This can produce an invalid ProgID however, as ProgIDs are limited to 39 characters and can contain no punctuation other than a period. In such case, a ProgID can be manually assigned to the class using ProgIdAttribute.
The following example demonstrates how to apply ProgIdAttribute on a class. The application then gets all attributes of MyClass, and prints the Value property of ProgIdAttribute.
<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
/** @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
Windows 98, Windows Server 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
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: