A friend and I are both working out at the moment and we have very different body types.
My body has taken to a few years of smoking, drinking beer regularly and eating rubbish far too often like most 20 year old people do.... I put on a few kgs. Not a lot... I'm not a fat lolloping sea cow or anything, I'm 6'0 and 182 pounds. I just need to burn 5kgs or so to get back to being in shape. I want to put some more muscle into that as well. I don't care if my actual weight goes up, as long as it's muscle replacing fat.
He is the opposite. The same diet has seen him skinny as always, no fat on him at all. He can eat what ever the hell he wants with no result what so ever.
He has to work really, really hard to eat everything he needs to whilst doing heavy weights just to put on a single kilo.
You should talk to a dietitian to gain the weight healthily and in a way that you won't just burn off.
You need to eat 6 meals a day, loads of protein and carbs and all sorts of stuff. Don't just shovel fat into your face, that won't help.
When you build muscle your body will probably start burning more calories because having muscle burns more calories even at rest.
You'll need to do weights and eat a lot of the right food.
I'm not qualified to give you a sure-fire solution, just what worked for my friend who sounds similar to you. He has had some good results in weight and muscle gain. Do yourself a favour and spend some money on a dietitian and some weights that you can do at home.
I'm setting up a gym in my garage and so far it has been fantastic. I've got a bad knee, so I can't run any more than a couple of kilometers before I end up in pain for the rest of the week, so I've got a bike in there, I've got a rowing machine coming from a family friend and I've got a weights bench. Get the stereo going with some heavy metal and I've got my own gym set up. Run upstairs, do some more free weights on the carpet, grab a cold shower and go to work.
It's only been a few weeks and I'm already seeing massive results in both fat and muscle.