Styryl dyes 4a-e containing a 15-crown-5 ether unit and a quinoline residue with a sulfonatoalkyl or sulfonatobenzyl N-substituent were synthesized. The relationship between the photochemical behavior of these dyes and their aggregates derived from complexation with Mg2+ in MeCN was studied using 1H NMR and absorption spectroscopy. The E-isomers of 4a-e were shown to form highly stable dimeric (2:2) complexes with Mg2+. Upon irradiation with visible light, the dimeric complexes undergo two competing photoreactions, viz., geometric E Z isomerization, resulting in an anion-capped 1:1 complex of the Z-isomer with Mg2+ and stereospecific syn-head-to-tail [2+2]-cycloaddition, affording a single isomer of bis-crown-containing cyclobutane. The N-substituent in the dye has a dramatic effect on the photochemical behavior of the dimeric complex. Molecular dynamics and semiempirical quantum-chemical calculations were carried out to interpret the observed photocycloaddition in the dimer. Conformational equilibria for the dimer of (E)-4b were analyzed using 1H NMR spectroscopy.