Dislocations alter perfect crystalline order and produce anisotropic broadening of the X-ray diffraction profiles, which is described by the dislocation contrast factor. Owing to the lack of suitable mathematical tools to deal with dislocations in crystals of any symmetry, contrast factors are so far only known for a few slip systems in high-symmetry phases and little detail is given in the literature on the calculation procedure. In the present paper a general approach is presented for the calculation of contrast factors for any dislocation configuration and any lattice symmetry. The new procedure is illustrated with practical examples of hexagonal metals and some low-symmetry mineral phases.