It is common for written contracts between entities to contain a "No Assignment" clause, which essentially states that, for a contract between entities A and B, the benefits or rights under the contract A cannot be assigned to another entity C without the consent of B.
It is possible for a breach of contract by B to precipitate the dissolution of A. (Examples: If B poaches a key member of A, or if the existence of A as a going concern depends entirely on its contract with B.) In such an event, it appears that a "No Assignment" clause would in effect make B immune to any liability claims, because A no longer exists and the contract could not be assigned to any beneficiary of A.
Not a perfect analogy, but in playground terms this is sort of like Bob and Al agreeing, "Let's build a sandcastle. But (here's the No Assignment clause) your friends don't get to play with it unless I agree." Once the sandcastle is complete Bob kills Al (yeah, it's a tough playground). Per the contract, Bob can invite all his friends to play and reject all of Al's friends.
Is there a legal doctrine that prevents a scenario like this?
I.e., can a contract clause indirectly render a contract party immune to liability for that party's breach of contract? I have a notion that there is something like the obverse of the "unclean hands" doctrine that would prevent this.