This documentation is archived and is not being maintained.

ManagementException Class

Represents management exceptions.

For a list of all members of this type, see ManagementException Members.


[Visual Basic]
Public Class ManagementException
   Inherits SystemException
public class ManagementException : SystemException
public __gc class ManagementException : public SystemException
class ManagementException extends SystemException

Thread Safety

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


using System;
using System.Management;

// This sample demonstrates how to display error
// information stored in a ManagementException object.
class Sample_ManagementException
    public static int Main(string[] args)
            ManagementObject disk =
                new ManagementObject("Win32_LogicalDisk.DeviceID='BAD:'");
            disk.Get(); // throws ManagementException
            Console.WriteLine("This shouldn't be displayed.");
        catch (ManagementException e)
          Console.WriteLine("ErrorCode " + e.ErrorCode);
          Console.WriteLine("Message " + e.Message);
          Console.WriteLine("Source " + e.Source);
          if (e.ErrorInformation) //extended error object
              Console.WriteLine("Extended Description : " + e.ErrorInformation["Description"]);
        return 0;
[Visual Basic] 
Imports System
Imports System.Management

' This sample demonstrates how to display error
' information stored in a ManagementException object.
Class Sample_ManagementException
    Overloads Public Shared Function Main(args() As String) As Integer
            Dim disk As New ManagementObject("Win32_LogicalDisk.DeviceID='BAD:'")
            disk.Get() ' throws ManagementException
            Console.WriteLine("This shouldn't be displayed.")
        Catch e As ManagementException
            Console.WriteLine("ErrorCode " & e.ErrorCode)
            Console.WriteLine("Message " & e.Message)
            Console.WriteLine("Source " & e.Source)
            If e.ErrorInformation != Nothing Then 'extended error object
                Console.WriteLine("Extended Description : " & e.ErrorInformation("Description"))
            End If
        End Try
        Return 0
    End Function
End Class

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.


Namespace: System.Management

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

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

See Also

ManagementException Members | System.Management Namespace