This is from
https://github.com/empira/PDFsharp/ which I just pulled down today. In PdfPage.cs line 383
The code throws an exception if the page does not have annotations because it tries to assign `this` when it have already established that _annotations is null, and GetValue doesn't create a new object.
Code:
public bool HasAnnotations
{
get
{
if (_annotations == null)
{
// Get annotations array if exists.
_annotations = (PdfAnnotations)Elements.GetValue(Keys.Annots);
_annotations.Page = this;
}
return _annotations != null;
}
}