Looks like some of the anchor-nodes in link_html do not have "href"-Tags (link.Attributes["href"]). This might generate the NullReferenceException you are getting during the foreach.
Check if Value is set before using it.
String.IsNullOrEmpty(link.Attributes["href"])
for example