I’m trying to test if an object is nothing before I get it’s value, but I get an error “NullReferenceException”
happens on the first line here:
If Not ORInvoiceLineRet.InvoiceLineRet.ItemRef.FullName Is Nothing Then
li.FullName = ORInvoiceLineRet.InvoiceLineRet.ItemRef.FullName.GetValue()
End If
System.NullReferenceException
{“Object reference not set to an instance of an object.”}
How can I test for this, without just handling the error in a try/catch?
There are more objects involved that can be nothing:
ORInvoiceLineRetcan be nothingORInvoiceLineRet.InvoiceLineRetcan be nothingORInvoiceLineRet.InvoiceLineRet.ItemRefcan be nothingORInvoiceLineRet.InvoiceLineRet.ItemRef.FullNamecan be nothingSo the only safe way here is: