I have had this happen so many times. To the point that I can't stand eating at anyone's home except my immediate family! For the first few years of being sick, I would suffer through, smile and eat the meal prepared for me. The final time I bothered to do that to spare someone else's feelings, I spent 11 days sick and even had to use vacation time from work! Not OKAY!
Here's how I have found it best to get out of this awkward situation that doesn't involve becoming a hermit that has to cook every single night for fear of eating anywhere but your own kitchen!
Make it very clear that you're on a special diet and don't generally eat food prepared by others. If the host/hostess will allow you to bring some food, definitely do it because then you can eat and you don't feel weird sitting there as the only non-eater. If they insist you eat the food being prepared, find out what it is and work with the party planners to work out a menu that will work for you. BBQ some steaks or chicken and just make sure they leave your piece of meat plain, etc. I always always always eat before I go anywhere. I can't be sitting at the table insisting I'm fine if my stomach is growling and I'm about to pass out from the hunger! Plus it can be so painful having to look at the beautiful and fragrant dinner rolls being passed around you if you haven't prepared by filling up your stomach! Lastly, even if the hosts have insisted I not bring anything, I usually still do - is that rude?!?! Even if it's just a dessert, they never complain once you show up with additional food for everyone!
I wish you luck with this situation. It is one you will face if you have any food intolerances and, in my experience, can be very awkward until you become strong enough to face the situation head on and stand up for your health!