Who is paying the mortgage now? Of course it has to be paid till it's sold, but if the stbx is living in the house and you're paying the mortgage, this is often used as a substitute for alimony for that period of time.
Does your ex have a job at all? How long were you married, waht are her prospects for work? Are there kids? Where are the kids living?
The answers to all these questions can affect the issue of your house. If the house is too expensive for the two of you to afford, then it needs to be sold, but someone has to pay for it in the meantime. If it's the house where the kids were raised, then they'll likely be allowed to stay with whoever stays in the house till it's sold. I doubt the law will prevent it from being sold just because you did some unlicensed work on it unless it was a new house and not your primary residence for very long, such that it looks like you were doing a flipping job, in which case you need professional permits & etc. Talk to a different realtor if you've gotten a differnet answer... that rule you're citing seems... odd.
If you're hanging yoru hat on tryign to keep the house rather than sell it in a bad market, by saying that the law says it CAN"T sell, well you might want to find a way to switch your attitude about that because you could easily hurt your chances of getting a good sale by running around talking about things you think are defects in the house (especially if they aren't entirely defects, legally, and your own legal analysis of the situation isn't entirely accurate).
How long you've been married and what her job is will also affect this.
Your lawyer is right to give you the worst case scenario, but if it's scaring you into doing stupid things like not cooperate with selling the house and trying ot get a good price on it, then you need to go back and explain that you are terrified that you won't be able to make ends meet and would she tell you the LIKELY result of your sitaution, not just the worst case scenario!
Now... if your income is huge and you've been married to her for 35 years and have a pack of teens running around in the house and she's been a stay at home mother helping you in your career for the whole marriage. recognize that you may end up paying alimony for life. You may end up paying the mortgage, you will probably also pay child support, and if the house is too big for either of you once the kids are grown, you may be ordered to sell it as soon as possible.
Tell us more about your situation and we'll help you figure out how much doom & gloom you need to worry about.