dotnet/wpf · error · ArgumentException
SR.Automation_InvalidSynchronizedInputType
Error message
SR.Automation_InvalidSynchronizedInputType
What it means
SynchronizedInputAdaptor.StartListening validates that the SynchronizedInputType requested is one of the five supported values (KeyUp, MouseLeftButtonDown/Up, MouseRightButtonDown/Up). Any other value throws ArgumentException with SR.Automation_InvalidSynchronizedInputType naming the bad inputType.
Solutions
- Pass only SynchronizedInputType.KeyUp/KeyDown/MouseLeftButtonDown/MouseLeftButtonUp/MouseRightButtonDown/MouseRightButtonUp values supported by the API.
- Validate with Enum.IsDefined(typeof(SynchronizedInputType), value) before calling StartListening.
- Fix casts of raw integers to SynchronizedInputType in client or wrapper code.
- Rebuild/re-reference matching UIAutomationClient and PresentationCore versions.
Example fix
// before
provider.StartListening((SynchronizedInputType)42);
// after
var type = SynchronizedInputType.MouseLeftButtonUp;
if (Enum.IsDefined(typeof(SynchronizedInputType), type))
{
provider.StartListening(type);
} Defensive patterns
Strategy: validation
Validate before calling
SynchronizedInputType[] valid =
{
SynchronizedInputType.KeyUp, SynchronizedInputType.MouseLeftButtonDown,
SynchronizedInputType.MouseLeftButtonUp, SynchronizedInputType.MouseRightButtonDown,
SynchronizedInputType.MouseRightButtonUp
};
if (!valid.Contains(inputType)) return; Type guard
bool IsValidSynchronizedInputType(SynchronizedInputType t) =>
t is SynchronizedInputType.KeyUp or SynchronizedInputType.MouseLeftButtonDown
or SynchronizedInputType.MouseLeftButtonUp or SynchronizedInputType.MouseRightButtonDown
or SynchronizedInputType.MouseRightButtonUp; Try / catch
try
{
provider.StartListening(inputType);
}
catch (ArgumentException ex)
{
// invalid SynchronizedInputType; correct the enum value
} Prevention
- Use only the documented SynchronizedInputType members
- Never cast raw integers to SynchronizedInputType
- Validate client-supplied enum values before forwarding to the provider
- Keep UIAutomationClient and WPF assembly versions in sync
When it happens
Trigger: Calling ISynchronizedInputProvider.StartListening with a SynchronizedInputType value outside the supported set — e.g. default(SynchronizedInputType), an out-of-range cast, or an enum member added in a different framework version.
Common situations: UIA clients (or test code) passing a raw int cast to SynchronizedInputType; custom providers forwarding client-supplied enum values without validation; version mismatch between client pattern definition and WPF implementation.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- SR.Automation_InvalidEventId
- SR.Automation_RecursivePublicCall
- SR.TextProvider_InvalidChild
- ArgumentOutOfRangeException
- Can only countersign parts with Digital Signature…
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/27f98d069852eef2.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Automation/SynchronizedInputAdaptor.cs:38
internal SynchronizedInputAdaptor(DependencyObject owner)
{
Invariant.Assert(owner != null);
_owner = owner;
}
/// <summary>
/// This method is called by automation framework to trigger synchronized input processing.
/// </summary>
/// <param name="inputType"> Synchronized input type</param>
void ISynchronizedInputProvider.StartListening(SynchronizedInputType inputType)
{
if (inputType != SynchronizedInputType.KeyDown &&
inputType != SynchronizedInputType.KeyUp &&
inputType != SynchronizedInputType.MouseLeftButtonDown &&
inputType != SynchronizedInputType.MouseLeftButtonUp &&
inputType != SynchronizedInputType.MouseRightButtonDown &&
inputType != SynchronizedInputType.MouseRightButtonUp)
{
throw new ArgumentException(SR.Format(SR.Automation_InvalidSynchronizedInputType, inputType));
}
UIElement e = _owner as UIElement;
if (e != null)
{
if (!e.StartListeningSynchronizedInput(inputType))
{
throw new InvalidOperationException(SR.Automation_RecursivePublicCall);
}
}
else
{
ContentElement ce = _owner as ContentElement;
if (ce != null)
{
if (!ce.StartListeningSynchronizedInput(inputType))
{
throw new InvalidOperationException(SR.Automation_RecursivePublicCall);View on GitHub (pinned to 81131a70a4)