memstechtips/Winhance · error · InvalidOperationException
Configuration file is invalid or corrupted.
Error message
Configuration file is invalid or corrupted.
What it means
InvalidOperationException thrown by ResolvePowerPlanValue when applying a configuration: a setting of kind power-plan-selection was selected, but the ConfigurationItem carried no PowerPlanGuid. The resolver cannot build a power-plan value without a GUID, so it treats the config file as corrupted. The message is generic even though the cause is specific (logged separately).
Source
Thrown at src/Winhance.Infrastructure/Features/Common/Services/ConfigurationApplicationBridgeService.cs:142
return item.SelectedIndex.Value;
}
return 0;
}
private object ResolvePowerPlanValue(SettingDefinition setting, ConfigurationItem item)
{
if (!string.IsNullOrEmpty(item.PowerPlanGuid))
{
return new Dictionary<string, object>
{
["Guid"] = item.PowerPlanGuid,
["Name"] = item.PowerPlanName ?? "Unknown"
};
}
_logService.Log(LogLevel.Error, "Config file is missing PowerPlanGuid for power-plan-selection.");
throw new InvalidOperationException("Configuration file is invalid or corrupted.");
}
private object? ResolveNumericRangeValue(SettingDefinition setting, ConfigurationItem item)
{
if (item.PowerSettings == null || item.PowerSettings.Count == 0)
return null;
// PowerCfg-backed NumericRange settings are exported in SYSTEM units (raw powercfg
// reads, e.g. seconds). PowerCfgApplier treats incoming dict/scalar values as DISPLAY
// units and converts display→system itself, so we must convert system→display here —
// exactly as RecommendedSettingsResolver.BuildPowerCfgApplyValue does for the manual
// quick-set path. Non-PowerCfg NumericRange settings carry no PowerCfgSettings and pass
// through unchanged.
bool isPowerCfg = setting.PowerCfgSettings?.Any() == true;
string? displayUnits = isPowerCfg ? RecommendedSettingsResolver.GetPowerCfgDisplayUnits(setting) : null;
var hasAcValue = item.PowerSettings.TryGetValue("ACValue", out var acVal);
var hasDcValue = item.PowerSettings.TryGetValue("DCValue", out var dcVal);
View on GitHub (pinned to f23d554eb2)
Solutions
- Open the config file and confirm each power-plan-selection item has a non-empty PowerPlanGuid (and ideally PowerPlanName).
- Re-export the configuration from a working Winhance install rather than hand-editing.
- If the plan is a built-in one, fill the well-known GUID: Balanced = 381b4222-f694-41f0-9685-ff5bb260df2e, High performance = 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c, Power saver = a1841308-3541-4fab-bc81-f71556f20b4a.
- Improve the error message to name the offending item and the missing field so the user can fix it directly.
Example fix
// before
_logService.Log(LogLevel.Error, "Config file is missing PowerPlanGuid for power-plan-selection.");
throw new InvalidOperationException("Configuration file is invalid or corrupted.");
// after: name the item so the user can fix the specific entry
throw new InvalidOperationException(
$"Configuration item '{item.SettingId ?? item.Name}' is a power-plan-selection but has no PowerPlanGuid. " +
"Set PowerPlanGuid (and PowerPlanName) in the config file and retry."); Defensive patterns
Strategy: validation
Validate before calling
// Validate the config item before applying.
bool IsValidPowerPlanItem(ConfigurationItem item) =>
!string.IsNullOrEmpty(item.PowerPlanGuid); Try / catch
catch (InvalidOperationException ex) when (ex.Message.Contains("Configuration file is invalid or corrupted"))
{
// Tell the user a power-plan-selection item is missing its Guid; offer to skip that item or re-export config.
} Prevention
- Re-export configs from a working Winhance install rather than hand-editing.
- Validate every power-plan-selection item has a non-empty Guid on import.
- Keep the well-known built-in plan GUIDs documented for manual repair.
When it happens
Trigger: ApplyConfigurationAsync encounters a ConfigurationItem whose SettingDefinition is power-plan-selection but PowerPlanGuid is null/empty. This happens when the exported/imported config file omitted the Guid field for that power plan entry, or the schema changed and the field was renamed/dropped during serialization.
Common situations: User hand-edited a saved config JSON and removed the Guid. An older Winhance version exported power plans without a Guid field. A config import from another machine references a power plan GUID that was not serialized. The UI created a power-plan-selection item without resolving the GUID.
Related errors
- Insufficient disk space on {driveName} for {operationName}.
- Could not delete the existing working directory '{workingDir
- Boot file not found: {etfsbootPath}
- UEFI boot file not found: {efisysPath}
- oscdimg.exe failed with exit code: {exitCode}
AI-assisted analysis of memstechtips/Winhance@f23d554eb2 (2026-08-13).
Data as JSON: /api/errors/7e3be7601d807e85.
Report an issue: GitHub.