I've not been on this forum for long, so you may not thank me for my message which is only based on what you've said here, but anyone who was on this forum earlier than me deserves at least a hello. Hello, I have the opposite problem to you, I can't LOOSE weight. I don't know how underweight you are but I think you have more leeway before your health is affected. I've actually been on low calories for 8 years, exercising like it's going out of fashion sometimes until I get injured. More recently I've been on low carbs and that has had some effect but even those losses have stopped. The one thing I haven't done is give up, I want to know the answer, I want to know why my body doesn't do what the majority does. You may feel in a hopeless situation and a lot of us have been there, you just have to keep at it.
I have been consulting a nutritional therapist and that has helped me a lot, I have a friend who is stick thin, struggles to gain weight and she also sees the same nutritional therapist and it's helped her a lot.
Maybe that is an avenue you might want to pursue? In the meantime, DO NOT GIVE UP, you have to keep chipping away.
GPs are usually the first port of call but when it comes to proper nutrition, they leave a lot to be desired, they are GENERAL Practitioners after all. Even a personal trainer at your local gym would have some good advice for weight gain, not necessarily full of carbs although they do like their carbs. Keep going, you'll get there and that's the important thing to remember, you will get there.