MahApps/MahApps.Metro · error · MahAppsException
The settings file '{filename ?? "<unknown>"}' seems to be co
Error message
The settings file '{filename ?? "<unknown>"}' seems to be corrupted What it means
Thrown by WindowSettings.Save()/load when deserializing the persisted WindowPlacement setting raises a ConfigurationErrorsException (e.g., the user.config or app settings file is malformed). The code walks the exception chain to find a filename and wraps it in a MahAppsException indicating corruption. The settings file stores window position/size across sessions.
Source
Thrown at src/MahApps.Metro/Controls/WindowSettings.cs:111
[UserScopedSetting]
public WindowPlacementSetting? Placement
{
get
{
try
{
return this[nameof(Placement)] as WindowPlacementSetting;
}
catch (ConfigurationErrorsException? ex)
{
string? filename = null;
while (ex != null && (filename = ex.Filename) == null)
{
ex = ex.InnerException as ConfigurationErrorsException;
}
throw new MahAppsException($"The settings file '{filename ?? "<unknown>"}' seems to be corrupted", ex);
}
}
set => this[nameof(Placement)] = value;
}
/// <summary>
/// Upgrades the application settings on loading.
/// </summary>
[UserScopedSetting]
public bool UpgradeSettings
{
get
{
try
{
return (this[nameof(UpgradeSettings)] as bool?).GetValueOrDefault(true);
}
catch (ConfigurationErrorsException? ex)View on GitHub (pinned to 72099e310b)
Solutions
- Delete the corrupted user.config file (typically under %LocalAppData%\<Company\<App\<Version>\user.config) and let the app recreate it.
- Call ApplicationSettingsBase.Reset() or .Upgrade() after schema changes to migrate old settings.
- Wrap the settings access in try-catch and fall back to default placement on ConfigurationErrorsException.
- Ensure settings properties are only added, not renamed/removed, across versions—or implement ISettingsUpgrade.
Example fix
// before
var placement = settings.Placement; // throws MahAppsException
// after
WindowPlacementSetting placement;
try
{
placement = settings.Placement;
}
catch (MahAppsException)
{
// settings file corrupted: reset and use defaults
settings.Reset();
settings.Save();
placement = settings.Placement;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Before reading placement, check the settings file exists and is readable
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
if (!config.HasFile)
return null; // use default placement Try / catch
WindowPlacementSetting placement;
try
{
placement = settings.Placement;
}
catch (MahAppsException)
{
settings.Reset();
settings.Save();
placement = settings.Placement;
} Prevention
- Call settings.Reset() or settings.Upgrade() after schema changes to migrate old user.config files.
- Wrap window-placement loading in try-catch and fall back to default placement.
- On corruption, delete the user.config under %LocalAppData% and let the app recreate it.
- Never rename or remove settings properties across versions without an upgrade plan.
When it happens
Trigger: The user-scoped settings file (user.config) containing persisted WindowPlacement is corrupted—truncated, invalid XML, or schema-mismatched after a version change. The ConfigurationManager throws ConfigurationErrorsException during read, which is caught and rewrapped.
Common situations: App upgraded and the settings schema changed, leaving an incompatible user.config. Machine crashed or disk issue truncated the settings file. Roaming profile conflict writing partial data. First run after a settings property was renamed/removed.
Related errors
- The inverse Flyout theme only works if the window theme abid
- The Dark Flyout theme only works if the window theme abides
- The Light Flyout theme only works if the window theme abides
- {nameof(AutoWatermarkProperty)} is not supported for {fe.Get
- The property 'IsSpellCheckContextMenuEnabled' may only be se
AI-assisted analysis of MahApps/MahApps.Metro@72099e310b (2026-08-13).
Data as JSON: /api/errors/1b3d7f87a300ec6d.
Report an issue: GitHub.