【发布时间】:2011-05-24 07:19:20
【问题描述】:
基于这个 SO 答案:Catching COMException specific Error Code,我想知道,如果我只需要查看异常的特定部分,是否可以跨操作系统和多个版本的 OL 正确处理 COMExceptions。例如,
private const uint HRESULT_OPERATIONABORTED = 0x80004004;
// ...
try {
// something that could throw COMExceptions
} catch (System.Runtime.InteropServices.COMException e) {
switch ((uint)e.ErrorCode) {
case HRESULT_OPERATIONABORTED:
break;
default:
break;
}
}
这是否足够跨平台,还是只需要考虑部分错误代码?
编辑 - 澄清一下,我的确切问题是比较 (uint)e.ErrorCode 和 0x80004004 是否过于具体(也就是说,我是否总是得到 0x80004004 这个特定的错误,无论 OS/OL 是什么),或者这是否是正确的处理方式。
【问题讨论】:
标签: c# outlook-addin comexception