0

So im doing some card game that requires alot of PictureBoxes and i bumped into a problem that is driving me nuts..

anyway here is the code:

private void ChangeCard(string card)
    {

        v0s0.Image = Image.FromFile(card);
        v0s1.Image = Image.FromFile(card);
        v0s2.Image = Image.FromFile(card);
        v0s3.Image = Image.FromFile(card);
        v0s4.Image = Image.FromFile(card);
        v0s5.Image = Image.FromFile(card);
        v0s6.Image = Image.FromFile(card);

    }

 private void Draw()
    {
        if (pl1)
        {
            ChangeCard("./Resources/p1.png");
            //pl1 = false;
            //pl2 = true;
        }
        else if (pl2)
        {
            ChangeCard("./Resources/p2.png");
            //pl2 = false;
           // pl1 = true;
        }
    }

Now method ChangeCard is used for changing the card pictures when its called, the Draw method is used for changing players and visually changing cards.

For some reason this doesn't work it pops up:

An unhandled exception of type 'System.NullReferenceException' occurred in projectName.exe
Additional information: Object reference not set to an instance of an object

I don't know why but i am pretty sure that the image direction is right.(ChangeCard("./Resources/p2.png");)

0 Answers0