yes it is necessary to be in the state of sanctifying grace before receiving sacraments of Eucharist, confirmation, matrimony, and holy orders, and if one is conscious and able to do so, confess before anointing of the sick (otherwise that sacrament returns one to the state of grace). Objectively, someone living in an invalid marriage has not been in communion with the Church and has been in a state of sin during that time. Subjectively, I have no idea what your spiritual condition is, so take it to the priest in confession and simply tell him the facts, and any other sins of your past life you can recall. Even those you don’t remember will be absolved and washed away for good. If it is the idea of confessing to a priest who knows you that bothers you, go to another parish. If it is the idea of confessing face to face that is disconcerting, kneel in front of the screen and remain anonymous. If it is the idea of the confessional box itself that brings back bad memories, ask to meet outside in the pews, or even on the parish grounds.
God bless you for responding to the grace of the Holy Spirit in returning to the sacraments especially that of matrimony. Jesus is ready to pour his grace on you and draw you to himself, and that begins in sacramental confession. Don’t deny yourself that ocean of love and mercy. Welcome home. The graces will shower down on you and your family through this reconciliation. That sound you hear is the angels rejoincing in heaven.