  The flux-ratio anomalies observed in multiply-lensed quasar images are most
plausibly explained as the result of perturbing structures superposed on the
underlying smooth matter distribution of the primary lens. The cold dark matter
cosmological model predicts that a large number of substructures should survive
inside larger halos but, surprisingly, this population alone has been shown to
be insufficient to explain the observed distribution of the flux ratios of
quasar's multiple images. Other halos (and their own subhalos) projected along
the line of sight to the primary lens have been considered as additional source
of perturbation. In this work, we use ray tracing through the Millennium II
simulation to investigate the importance of projection effects due to halos and
subhalos of mass m>1E8 Msun/h and extend our analysis to lower masses, m>1E6
Msun/h, using Monte-Carlo halo distributions. We find that the magnitude of the
violation depends strongly on the density profile and concentration of the
intervening halos, but clustering plays only a minor role. For a typical
lensing geometry (lens at redshift 0.6 and source at redshift 2), background
haloes (behind the main lens) are more likely to cause a violation than
foreground halos. We conclude that line-of-sight structures can be as important
as intrinsic substructures in causing flux-ratio anomalies. The combined effect
of perturbing structures within the lens and along the line of sight in the
LCDM universe results in a cusp-violation probability of 20-30%. This
alleviates the discrepancy between models and current data, but a larger
observational sample is required for a stronger test of the theory.
