France had invested in Dai Viet by supporting Nguyen Anh's faction against the Tayson rebellion during the Vietnamese Civil War (1789–1802). French king Louis XVI signed with Nguyen Anh the Treaty of Versailles in 1787 to give the Nguyen loyalists an alliance with France. Although the treaty was never ratified, thousands of French mercenaries and officers rallied to the side of Nguyen Anh and struggled against the Taysons. When Anh defeated the Taysons and was crowned as Emperor Gia Long (r. 1802–1819) of the unified Kingdom of Vietnam in 1802, roughly 400 Frenchmen served the new monarchy as court officials and advisers of Gia Long, who relatively tolerated all religions including Catholicism. Unfortunately, Gia Long's successor–Emperor Minh Mạng (r. 1820–1841) was a conservative Confucian-minded and isolationist ruler. He abolished diplomatic relations with France in 1826. Began from 1833, after the Lê Văn Khôi revolt, the Vietnamese monarch chiefly targeting Catholic Christians for religious persecution by labeling them as "tà đạo" (heretics), issued several "dụ cấm đạo Gia tô" (edict of restriction of the Catholic religion), and forbid missionaries activities. This persecution of Catholics and the executions of French bishops created an excuse for intervention by France, but the new French monarchy under the reign of Louis Philippe I (r. 1830–1848) did not focus on the protection of their missionaries in the Far East.