If you share your house with your dog, it does not have to be "all or nothing". I remember when I was young, that the living and dining room were the special rooms, reserved for Christmas, company, and off-limits until a special event was declared.
There was no thought that existed in my mind to invite myself to the royal dining room table to enjoy my morning cereal. I respected my parents reservations of the rooms on an invitation only basis.
This same rule can, and should, exist for your dog, if you have an area you would like to label off limits, whether to preserve from dog hair or as a cat sanctuary, you are entitled to do that! This boundary can be accomplished without a ten foot barricade, shock line, or threats.
Establish a clear boundary. This means....the rule exists 100% of the time during our training period, and the dog can not have access to the area when you are not home. A change in flooring, or a door way, is ideal because it is as clear as black and white, carpet and tile. But any type of boundary, and even old dogs, can be trained.
When your dog approaches the forbidden room or area, simply and calmly say, "No" and call your dog away from the room. When your dog has re-directed, say, "Good Dog".
This process needs to be continual, constant, non-stop. You will notice success and be amazed as your dog acknowledges you and your communication becomes more clear to your dog, as you learn to speak the same language.
In the beginning, it's ok to use gates and barriers at times when you are too busy to supervise your preserved area, to avoid your dog trespassing. As time progresses, gates can become a semi-blocked doorway, or even a small curtain rod, and your dog will recognize this standard road block, and will detour himself to another welcomed area. Eventually, you will not need anything to deter your dog from entering this area. The amount of time this takes depends only on your training skills.
We have a saying when speaking to dogs we are training, "Just because you are able, does not mean you may!"
Good luck, and enjoy the freedom that boundaries can offer!