对特定的异常进行捕获和报错
try { var reference = uidoc.Selection.PickObject(ObjectType.Element, "请选择您要查看的元素"); } catch (Autodesk.Revit.Exceptions.OperationCanceledException ex) { TaskDialog.Show("ERROR", "未选取任何对象!"); //TaskDialog.Show("ERROR",ex.ToString()); return Result.Failed; }