Object reference not set to an instance of an Object...

Posted on 2006-05-09
Medium Priority
Last Modified: 2010-04-23
If I had a nickel for everytime I got this error.... this one has had this noob guessing for a while though.

Here's my code in the Page_Load sub:

        ' the PopulateDropDown() method returns an ArrrayList from my DAL.
        Dim alDD As ArrayList = DA.PopulateDropDown()

        'populate Modules drop down list
        ddlModules.DataSource = alDD

The exception is thrown on the first line, but I'm obviously stuck on why.  The DA was dimmed at the form level (just below the Web Form Designer Generated Code block) so it would be in scope for all methods in that Class:

Dim DA As DAL_NurseEdMods.DataAccess

Thanks for any help!
Question by:tmccrank
  • 2
  • 2
LVL 52

Expert Comment

by:Carl Tawn
ID: 16643728
Time to dust off the debugger. Put a breakpoint on the line in question and double-check that DA is a valid object. If it is, then it may be a problem with what "PopulateDropDown()" is returning.

Author Comment

ID: 16643823
Thanks Carl,
I tried the breakpoint, but the exception is thrown even before the debugger steps in to the PopulateDropDown() function, which tells me that it can't be that method.  Is this right?
Anyway, during debugging DA is showing up as "Nothing".  But won't it be "Nothing" until the function returns an ArrayList?  Like I said earlier, it's not even going there.
LVL 52

Accepted Solution

Carl Tawn earned 500 total points
ID: 16643883
No, DA should be a valid object at this point. PopulateDropDown() is a method of whatever class DA is. So you need to look at the declaration of DA.

Chances are you code says something like:

    Dim DA As SomeClass

Rather than:

   Dim DA As New SomeClass()


   Dim DA As SomeClass = New SomeClass()

Author Comment

ID: 16643929
Dim DA As New DAL_NurseEdMods.DataAccess

That fixed it.
Thanks very much.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question