About 1200 the original fortress Kasteln was built in the middleSchenkenberger valley, a few kilometers away from Schenkenberg Castle. In 1238 the castle is first mentioned in a deed of gift to the residents of the castle who were vassals of the Kyburgs. In 1262 Ruchenstein castle was built on the cliff directly behind the fort for the Knight of Ruchenstein. After the extinction of the Kyburg line in 1264, the castle came under the power of the House of Habsburg. Then in 1301 the Ruchenstein line died out, ten years after they had been given the fort as a gift by the Habsburgs. Both castles were acquired by the lords of Mülinen from Brugg. From here, they ruled over a small area on the southern edge of the Jura. The castle belonged to the family of Mülinen until 1631 when Johann Ludwig von Erlach bought both castles. The Bernese patrician and general ordered the reconstruction of the castle in 1642 to a representative of manor house. Ruchenstein castle was demolished a year later and served as a building material supplier. Because the builder had no previous expertise, and the client was mostly absent, the conversion proved to be expensive and lasted until 1650. After about a century in the possession of the family of Erlach, in 1732 Bern bought the little bailiwick for 90,000 Taler. It was the smallest bailiwick of the Bernese Aargau, consisting of the villages Auenstein, Oberflachs, Schinznach and Villnachern. After the fall of the Ancien Régime and the Act of Mediation in 1803, the bailiwick came into possession of the newly formed canton of Aargau. The castle was sold in 1836 to a private citizen. In 1855 the brothers Frederick and Louis Carnival of Aarau acquired the property and opened a "rescue institution for orphans and neglected pupils" of the Reformed denomination. On 24 August 1907 one of the pupils set the castle and adjacent barn on fire. Both buildings suffered heavy damage and had to be rebuilt. It wasn't until 1909 that the Institute started operations in the manor again. The Institute received the status of a foundation in 1923 and was converted in 1955 in a boarding school for students with behavioral problems. In 1969 next to the castle they built a second school building, swimming pool and a staff house. The entire castle was extensively renovated in 2009 inside and out and adapted to the current needs of the social education.
Building
Kasteln is the only uniform baroque palace built in the Aargau. The current design is mainly due to the modifications under Johann Ludwig von Erlach. At the core is a four-story medieval castle with two-story wings, from 1642–50, to the east and west. The wings were built partly from material from the demolished castle Ruchenstein. The unusually rich interior of the castle in 1907 was lost in the fire.