none
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();
    
                scoreBox.Items.Clear();
                foreach (Score item in geluidlijst)
                {
    
                    bgExperience.AddFragment(item.Scores, item.liedje, item.Naam);
                }
    
                foreach (Score item in bgExperience.GetAlleScores())
                {
                    scoreBox.Items.Add(item.AlsString());
                }
    
            }

     

    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);
                Scores.Add(score);
            }
    Thx for watching and please respond ;)

     


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

Answers

  • 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.

     

    Regards


    Thomas Balkeståhl - Technical Specialist - SharePoint - http://blksthl.wordpress.com
    Tuesday, January 31, 2012 1:29 PM