Without a wiring diagram I can only guess what's wrong, probably the power comes into the light fixture first and the wire to the wall switch only carries power and not neutral. If so you must connect the fan to neutral up by the light fixture and get it power from a new line run from the wall switch box. Otherwise give details on what you have.