寺 here is the old word for a government office, not 'temple', and the name has nothing to do with
大理 in Yunnan:
理 meant 'judge'. In the Ming and Qing it reviewed the verdicts of the
刑部, and these two with the
都察院 made up the
三法司, the three top judicial offices.