In 1721-25 Schultheiss Hieronymus von Erlach built an elegant manor house known as Hindelbank Castle near the ruins of the old castle in Wiler. During the 18th century the castle became an internationally renowned center of high society. In 1866 Robert von Erlach sold the castle's lands to a private party, while the castle was sold to the Canton of Bern. The canton built a poorhouse and in 1896 a women's prison on the castle grounds. The castle was used as an administrative center.