Can cargo trains and passenger trains share the same line?

Solution 1:

Yes, train tracks service any kind of train. You can even have a cargo train go through a passenger station and vice-verse (though I would never recommend doing this if there is any alternative, since stopped trains at the station will hold up the whole line). However, you will probably find that separating your train network into either passenger and cargo tracks or intercity and intracity will significantly reduce train traffic.

As for the issue noted in the question, passenger trains will disappear like cars when they have spent too long on the track, and all trains will disappear if they cannot find a route to their destination. Most likely what happened was your construction temporarily took away the cargo train's route to its destination, causing it to disappear. You can prevent this by doing all construction while paused, but in the long run it isn't a big deal since it frees up a slot for a new cargo train to come immediately.