如何从InnerException获取DirectoryServicesCOMException?

时间:2014-07-11 12:38:15

标签: c# debugging exception active-directory try-catch

如何从InnerException获取DirectoryServicesCOMException ExtendedErrorMessage? 程序只捕获“catch(例外e)”,所以这不起作用:

try
{
   ...
}
   catch (DirectoryServicesCOMException e)
{
   throw e;
}

screen

类似的东西:

try
{
   ...
}
   catch (Exception e)
{
   throw e.InnerException.DirectoryServicesCOMException ....;
}

1 个答案:

答案 0 :(得分:0)

你应该可以这样做:

if (e.InnerException is DirectoryServicesCOMException)
{
    DirectoryServicesCOMException innerException = (DirectoryServicesCOMException)e.InnerException;
    // do whatever is correct with these kind of exception
}