This documentation is archived and is not being maintained.

ProgIdAttribute Class

Allows the user to specify the ProgID of a class.

Namespace:  System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
<ComVisibleAttribute(True)> _
<AttributeUsageAttribute(AttributeTargets.Class, Inherited := False)> _
Public NotInheritable Class ProgIdAttribute _
	Inherits Attribute
'Usage
Dim instance As ProgIdAttribute

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 

System.Object
  System.Attribute
    System.Runtime.InteropServices.ProgIdAttribute

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: