次の方法で共有


ManagementException クラス

管理例外を表します。

この型のすべてのメンバの一覧については、ManagementException メンバ を参照してください。

System.Object
   System.Exception
      System.SystemException
         System.Management.ManagementException

<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

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

使用例

 
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] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.Management

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

アセンブリ: System.Management (System.Management.dll 内)

参照

ManagementException メンバ | System.Management 名前空間