From 1508 to 1918 the residence was used as city castle and government seat by the Bavarian dukes, electors and kings.