У меня есть следующая функция:
Public Sub performautowebrowserOperations()
Try
For Each link As HtmlElement In WebBrowser2.Document.GetElementsByTagName("input") 'sometimes throws a null reference exception
If link.GetAttribute("value") IsNot Nothing Then
If link.GetAttribute("value") = "Compare prices" Then
link.InvokeMember("click")
End If
End If
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Иногда закомментированная строка вызывает исключение NullReferenceException. Почему и как это исправить?