This isn't always doable, but if you have damaged threads in a casting, chase them as deep as you can, ending up with a bottoming tap.
Then install stud(s) to the very VERY BOTTOM of the hole, utilizing every last thread you can.
Mount your attachment on the stud(s) and finish with a good nut.
Now, the casting only needs to be an anchor and there is no pulling/twisting/torsional stress on the casting threads--all that stress is on the new nut, plus you probably gained several new, good threads to help anchor the stud.
I've done Mikesters procedure and can add that sometimes its easier and stronger to weld a slightly smaller but thicker FLAT WASHER to the top of the stud. This lets you get closer to the stud with the welder, resulting in better penetration, rather than reaching down thru a nut to weld. After you get the washer welded good, THEN weld the nut to the washer.
Then get on the nut with a breaker bar or wrench and start LIGHTLY swinging from loose to tight, each time putting SLIGHTLY more force on the unscrewing direction. Back and forth. Be patient. I've swung that breaker bar for more than a minute sometimes, gently and not putting too much power on the wrench. By and by, it may start to move, ever so slightly. Just keep swinging the wrench or breaker bar back and forth. Dont get impatient. Take only whatever slack the bolt will give you. Just keep swinging the bar in a wider and wider arc. You want to work/grind the rust and corrosion looser and looser. Penetrating oil will help after it starts to move.