dotnet/wpf · error · ArgumentException
SR.Format(SR.CannotConvertType, source.GetType().FullName…
Error message
SR.Format(SR.CannotConvertType, source.GetType().FullName, typeof(PropertyPath))
What it means
PropertyPathConverter.ConvertFrom throws this ArgumentException when the source value is neither null, a string, nor already a PropertyPath. The converter only supports converting from string (or passing through PropertyPath); any other source type cannot be converted to PropertyPath, so the request is rejected.
Solutions
- Pass the path as a string: converter.ConvertFrom(null, culture, "Customer.Orders") or construct new PropertyPath("...") directly
- If the value is already a PropertyPath, use it as-is instead of re-converting
- Check the source object's type before conversion and convert it to string (e.g. ToString or Uri.ToString) first
- Fix the XAML/binding call site so a string literal is supplied for the path attribute
Example fix
// before
object src = new Uri("Customer.Orders");
var path = (PropertyPath)converter.ConvertFrom(null, null, src); // throws
// after
var path = (PropertyPath)converter.ConvertFrom(null, null, "Customer.Orders");
// or
var path = new PropertyPath("Customer.Orders"); Defensive patterns
Strategy: type-guard
Validate before calling
bool convertible = source is string || source is PropertyPath || source == null; if (!convertible) source = source?.ToString(); // pre-normalize to string
Type guard
bool CanConvertToPropertyPath(object o) => o is string || o is PropertyPath || o == null;
Try / catch
try { var path = (PropertyPath)converter.ConvertFrom(null, culture, source); }
catch (ArgumentException ex) when (ex.Message.Contains("Cannot convert")) { /* fall back to new PropertyPath(source?.ToString()) */ } Prevention
- Only feed strings (or existing PropertyPath instances) to PropertyPathConverter
- Prefer the PropertyPath constructor directly over the converter in code
- Quote path values properly in XAML so they arrive as strings
When it happens
Trigger: TypeConverter.ConvertFrom called with an int, Uri, Binding, or other non-string object; XAML or data-binding infrastructure feeding a non-string attribute value into a property typed as PropertyPath; programmatic conversion of arbitrary objects to PropertyPath.
Common situations: Passing a non-string value in XAML where a path string was expected (missing quotes or wrong element); calling converter.ConvertFrom directly in custom markup extensions; refactors changing a property type from string to PropertyPath while callers still pass typed values.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- SR.Format(SR.CannotConvertType, typeof(PropertyPath)…
- SR.Format(SR.General_BadType, "ConvertFrom")
- SR.Format(SR.General_BadType, "ConvertFrom")
- SR.Format(SR.PropertyPathIndexWrongType…
- SR.Format(SR.UnexpectedParameterType, value.GetType()…
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/18d87cbc7c36ec19.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/PropertyPathConverter.cs:102
/// <exception cref="ArgumentException">
/// An ArgumentException is thrown if the example object is not null and is not a valid type
/// which can be converted to a PropertyPath.
/// </exception>
/// <param name="typeDescriptorContext"> The ITypeDescriptorContext for this call. </param>
/// <param name="cultureInfo"> The CultureInfo which is respected when converting. </param>
/// <param name="source"> The object to convert to a PropertyPath. </param>
public override object ConvertFrom(ITypeDescriptorContext typeDescriptorContext,
CultureInfo cultureInfo,
object source)
{
ArgumentNullException.ThrowIfNull(source);
if (source is string)
{
return new PropertyPath((string)source, typeDescriptorContext);
}
throw new ArgumentException(SR.Format(SR.CannotConvertType, source.GetType().FullName, typeof(PropertyPath)));
}
/// <summary>
/// ConvertTo - Attempt to convert a PropertyPath to the given type
/// </summary>
/// <returns>
/// The object which was constructed.
/// </returns>
/// <exception cref="ArgumentNullException">
/// An ArgumentNullException is thrown if the example object is null.
/// </exception>
/// <exception cref="ArgumentException">
/// An ArgumentException is thrown if the example object is not null and is not a Brush,
/// or if the destinationType isn't one of the valid destination types.
/// </exception>
/// <param name="typeDescriptorContext"> The ITypeDescriptorContext for this call.
/// If this is null, then no namespace prefixes will be included.</param>
/// <param name="cultureInfo"> The CultureInfo which is respected when converting. </param>View on GitHub (pinned to 81131a70a4)