Error of "Object reference not set" occurs while passing two valid/instantiated objects.

I'm executing a custom method which calls for two objects, one ByVal and the other ByRef.  Both values are properly instantiated (and have data in them) at the moment the method is being called (debug mode shows this).  Why would this error occur??

Note: the objects are a dataRow (byval), and a treeview (byref).
LVL 15
David L. HansenProgrammer AnalystAsked:
Who is Participating?
Christian de BellefeuilleConnect With a Mentor ProgrammerCommented:
On which line this error happen?  11? (in the code snipet i mean)
Or in your RequestNode method?

If it's on Line 11, then appTools is not instanciated.
If its in RequestNode, then we need the code for RequestNode...
can you post the line of code where you get the error?

Christian de BellefeuilleProgrammerCommented:
can you show how you call this method?
can you show how this method is defined?
Have you really placed a breakpoint on the first line of the method to make sure that what you receive is really instanciated?
Does all the properties of theses instances are also instanciated?...

I've never seen a case where "Object reference not set" is given and that everything is properly instanciated...
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

David L. HansenProgrammer AnalystAuthor Commented:
Code is as follows:

I can see the data inside of "row" when I hover over it in debug-mode and the tree's name, etc. when I hover over it.  They have the right data in them.
Friend Class ModeController
Private tree As TreeView
Public Sub New(ByRef dataClass As DataClass, ByRef aTreeView As TreeView)
     dbTool = dataClass
     tree = aTreeView
End Sub
'below is in another method called chooseMode()
For Each row In dtLinkedApps.Rows
     appTool.RequestNode(row, tree) 'THIS IS THE LINE THAT FAILS.
Public Sub RequestNode(ByVal AppRow As DataRow, ByRef tree As TreeView)

Open in new window

David L. HansenProgrammer AnalystAuthor Commented:
Boy am I blind!!! :)

It was appTool that was uninstantiated, not the parameters....sigh..perhaps I need to clear my head)!

Thanks cdebel
Christian de BellefeuilleProgrammerCommented:
lol.  Don't worry, it happenned to me too
David L. HansenProgrammer AnalystAuthor Commented:
Sometimes ya just gotta laugh ;)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.