How can I find out whether an annotation, action, or destination is valid?

Q: I need PDF Library for our project. I found out that your library
is a very cool one and i downloaded trial version and tested it. When
i run AnnotationTest sample , i got the following error when i get the
following line.

if (action.GetType() == Action.Type.e_GoTo)

Exception: Message: Invalid Action

Please help me. I'd like to use your library. Yours is very simple to
use.
----
A:

It seems that you encountered an invalid action.
You can check is the annotation/action/destination is valid using
IsValid() method.
For example:

Annot annot = page.GetAnnot(i);
if (annot.IsValid() == false) continue;
if(annot.GetType() == Annot.Type.e_Link) {
  Action action = annot.GetLinkAction();
  if (action.GetType() == Action.Type.e_GoTo) {
    Destination dest = action.GetDest();
      if (dest.IsValid() == false) Console.WriteLine(" Not a valid
destination.");
      else {
        int page_num = dest.GetPage().GetIndex();
        Console.WriteLine(" Links to: page number {0:d} in this
document", page_num);
      }
   }
}