dotnet/wpf · error · InvalidOperationException
SR.ProgressBarReadOnly
Error message
SR.ProgressBarReadOnly
What it means
IRangeValueProvider.SetValue on ProgressBarAutomationPeer unconditionally throws InvalidOperationException with SR.ProgressBarReadOnly because a ProgressBar is a read-only indicator — its value is driven by the application, never set by UIA clients. The peer also advertises IsReadOnly=true via the RangeValue pattern.
Solutions
- Do not set progress via UIA; update ProgressBar.Value (or the bound view-model property) from application code.
- Use only RangeValuePattern.Value to read progress in tests; simulate work through the app's API/view-model instead.
- Remove ProgressBar from the list of RangeValue targets in generic automation harnesses.
Example fix
// before (test) rangeValuePattern.SetValue(50.0); // always throws // after var current = rangeValuePattern.Value; // read-only viewModel.Progress = 50; // drive progress from the app
Defensive patterns
Strategy: validation
Validate before calling
if (rangeValuePattern.IsReadOnly) { /* never call SetValue on progress bars */ } Prevention
- Never script SetValue against ProgressBar; read RangeValue only
- Drive progress from application/view-model code in tests
- Exclude read-only controls from generic pattern-exercising harnesses
When it happens
Trigger: Any UIA client call to RangeValuePattern.SetValue() on a ProgressBar, regardless of state — there is no code path that allows it.
Common situations: Automation scripts that treat progress bars like sliders and attempt to set progress; generic pattern-exercising test harnesses that call SetValue on every RangeValue-capable element.
Related errors
- 0x80040209
- Cannot remove signature from read-only file.
- Cannot sign read-only file.
- CollectionIsFixedSize
- E_ACCESSDENIED
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/70f64225613615b5.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/ProgressBarAutomationPeer.cs:47
///
public override object GetPattern(PatternInterface patternInterface)
{
// Indeterminate ProgressBar should not support RangeValue pattern
if (patternInterface == PatternInterface.RangeValue && ((ProgressBar)Owner).IsIndeterminate)
return null;
return base.GetPattern(patternInterface);
}
/// <summary>
/// Request to set the value that this UI element is representing
/// </summary>
/// <param name="val">Value to set the UI to, as an object</param>
/// <returns>true if the UI element was successfully set to the specified value</returns>
//[CodeAnalysis("AptcaMethodsShouldOnlyCallAptcaMethods")] //Tracking Bug: 29647
void IRangeValueProvider.SetValue(double val)
{
throw new InvalidOperationException(SR.ProgressBarReadOnly);
}
///<summary>Indicates that the value can only be read, not modified.
///returns True if the control is read-only</summary>
bool IRangeValueProvider.IsReadOnly
{
get
{
return true;
}
}
///<summary>Value of a Large Change</summary>
double IRangeValueProvider.LargeChange
{
get
{
return double.NaN;View on GitHub (pinned to 81131a70a4)