I'm no electronics guy but that just looks all wrong. I suggest that you post that picture with a better description of your issue in the project guidance forum.
I see you running 24v to one of your Arduino's pins. I'm worried about damage from what I see. I see driving the solenoid directly off pin 4. From your description I was expecting to see a relay switching power to the solenoid.