ManagementClass.GetRelationshipClasses Method ()


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Retrieves relationship classes that relate the class to others.

Namespace:   System.Management
Assembly:  System.Management (in System.Management.dll)

Public Function GetRelationshipClasses As ManagementObjectCollection

Return Value

Type: System.Management.ManagementObjectCollection

A collection of association classes that relate the class to any other class.

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

The following example uses the GetRelationshipClasses method to list the relationship classes to the CIM_LogicalDisk class. For more information, see "CIM_LogicalDisk" in the Windows Management Instrumentation documentation in the MSDN Library at

Imports System
Imports System.Management

Class Sample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        Dim c As ManagementClass
        c = New ManagementClass("CIM_LogicalDisk")

        For Each r As ManagementClass In c.GetSubclasses()

            Console.WriteLine( _
                "Instances of {0} are sub-classes", _

        For Each r As ManagementClass In c.GetRelationshipClasses()

            Console.WriteLine( _
                "{0} is a relationship class to " & _
                c.ClassPath.ClassName, _

            For Each related As ManagementClass In c.GetRelatedClasses( _
                Nothing, r.ClassPath.ClassName, "Association", Nothing, _
                Nothing, Nothing, Nothing)

                Console.WriteLine( _
                    "{0} is related to " & c.ClassPath.ClassName, _

    End Function
End Class

.NET Framework
Available since 1.1
Return to top