ManagementException Class
Represents management exceptions.
For a list of all members of this type, see ManagementException Members.
System.Object
System.Exception
System.SystemException
System.Management.ManagementException
[Visual Basic] <Serializable> Public Class ManagementException Inherits SystemException [C#] [Serializable] public class ManagementException : SystemException [C++] [Serializable] public __gc class ManagementException : public SystemException [JScript] public Serializable 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.
Example
[C#] 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) { try { 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 Try 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
in the upper-left corner of the page.
Requirements
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)