在 Configuration Manager 中,当发生Configuration Manager错误时,要么是 Windows Management Instrumentation (WMI) ,要么是 SMS 提供程序错误。
在 __ExtendedStatus 实例中报告 WMI 错误。 在 的 SMS_ExtendedStatus实例中报告 SMS 提供程序错误。
处理错误的方式取决于当前使用的编程语言。
使用 WMI 进行错误处理
在 VBScript 中,如果在同步操作期间发生错误,则错误对象 Number 属性为非零。 通常,在更改或查询 SMS 提供程序后检查此值。 在异步操作中,您会收到回调函数的 OnCompleted 错误对象。
获取错误对象实例后,可以检查 __Class 属性来确定错误的来源。 WMI 为 WMI 错误创建 __ExtendedStatus 的实例,SMS 提供程序为 SMS 提供程序错误创建 的 SMS_ExtendedStatus 实例。
SMS_ExtendedStatus 派生自 __ExtendedStatus。 还可以在 SMSProv.log 中找到 SMS 提供程序错误的详细信息。
有关处理同步错误的详细信息,请参阅如何使用 WMI 处理 Configuration Manager 同步错误。
有关处理异步错误的详细信息,请参阅如何使用 WMI 处理 Configuration Manager 异步错误。
使用托管 SMS 提供程序进行错误处理
若要使用托管 Configuration Manager 提供程序处理 Configuration Manager 错误,请捕获特定于 Configuration Manager 的异常。
| 异常 | 说明 |
|---|---|
SmsQueryException |
SmsQueryException发生 Configuration Manager 查询错误时引发。 它提供特定于Configuration Manager (SMS_ExtendedStatus) 的异常信息,并封装引发的任何 WMI 异常。SmsQueryException.ErrorCode 映射到等效的 System.ManagementException 异常代码。SmsQueryException.ExtendStatusCode 映射到在 中 SMS_ExtendedStatus.ErrorCode引发的 SMS 提供程序错误代码。 |
SmsConnectionException |
SmsConnectionException 当与 WMI 的连接丢失时引发。 |
SmsException |
SmsException是 和SmsConnectionException派生的SmsQueryException基类。 它永远不会被抬起,但可以抓住它来捕捉 SmsQueryExceptionSmsConnectionException和 。 |
访问 __ExtendedStatus 和 SMS_ExtendedStatus 对象
由于__ExtendedStatus SMS_ExtendedStatus 且未由托管 SMS 提供程序包装,因此必须使用 System.Management ManagedException 对象。
如果不需要访问错误 WMI 对象,则可以访问 SMSException.Details 中的异常详细信息字符串。
有关处理同步异常的详细信息,请参阅如何使用托管代码处理 Configuration Manager 同步错误。
有关处理异步异常的详细信息,请参阅如何使用托管代码处理 Configuration Manager 异步错误。
另请参阅
如何使用 WMI 处理 Configuration Manager 同步错误
如何使用 WMI 处理 Configuration Manager 异步错误