I See Sharp I See Sharp - 2 months ago 4x
Vb.net Question

Why am I getting System.NullReferenceException: Object reference not set to an instance of an object?

I'm trying to assign an instance of a Form to a Form Property

The system keeps showing an error at my second line of code below

Dim objFrm = New LsProg.SFile.frmTestRel(AddressOf sOpDos, AddressOf sOpDosLine, AddressOf sOpFac)
_FavoriteForm.FrmInstance = objFrm
_FavoriteForm.FrmName = objFrm.Name


If you get a NullReferenceException you need to think about what is actually Null and then go back and make sure you initialise it.

You told us

_FavoriteForm.FrmInstance = objFrm

threw this exception, so _FavoriteForm is clearly Null and needs to be initialised fist.