Exeption throw when call Annot.isValid

I use this code to get Annot object in page

Dim objAnnot As Annot = Me.GetDoc.GetPage(PageIndex).GetAnnot(i)
If objAnnot IsNot Nothing Then
   If objAnnot.IsValid And objAnnot.GetType = Annot.Type.e_Link Then
         ..... make some action
   end if
end if

A exeption throw SOMETIME (sometime is ok) when I call
objAnnot.IsValid. If I retry directly after, sometime it's ok and
sometime throw again.

This is the exeption message:
   Message: Object header not found
   Conditional expression: false
   Filename : ObjParser.cpp
   Function : trn::SDF::ObjParser::GetObj
   Linenumber : 199

P.S. I try with different document with same result

Any idea?


The problem is most likely due to interaction between your app code
and the rendering thread in PDFViewCtrl (i.e. a threading issue). It
is possible that both rendering thread (PDFViewCtrl) and your
application code (Form field extraction/manipulation) are trying to
access the PDFDoc at the same time. Because PDFNet is loading the file
incrementally (for
efficiency) this could lead to some critical sections. To resolve the
problem simply surround and code that can access document which is
shown in PDFViewCtrl using doc.Lock()/Unlock().


… Access or manipulate the doc. e.g.
annot = ..


Since this is a frequent cause of confusion we will probably remove
this requrement in future (i.e. let PDFNet do the locking) however for
the time being you need to lock the document yourself.