Object reference not set to an instance of an object. RRS feed

  • Question

  • Hey Guys and Girls,

    Me and a friend are working on a school project and keep getting the error: "Object reference not set to an instance of an object. "

    This is the code where it all went wrong: 

    private void submitScoreBtn_Click(object sender, EventArgs e)
                List<Score> geluidlijst;
                geluidlijst = dk.scoren();
                foreach (Score item in geluidlijst)
                    bgExperience.AddFragment(item.Scores, item.liedje, item.Naam);
                foreach (Score item in bgExperience.GetAlleScores())


    The line where the error shows = bgExperience.AddFragment(item.Scores, item.liedje, item.Naam);

    This is the addfragment void: 


            public void AddFragment(int scores, String Liedje, String naam)
                Score score = new Score(Liedje, scores, naam);
    Thx for watching and please respond ;)


    • Edited by Oolino Tuesday, January 31, 2012 1:22 PM
    Tuesday, January 31, 2012 1:22 PM


  • Hi.

    You would really increase the chanses of getting good help by adding a little more information...

    For instance, is the code in a webpart, if so, where is it running? Perhaps some comments in the code that tells what the objects are?

    The error: Object reference not set to an instance of an object' is very generic and tells us little.


    Add more details and I'm sure that you will be provided with good help here.



    Thomas Balkeståhl - Technical Specialist - SharePoint -
    Tuesday, January 31, 2012 1:29 PM