dotnet/maui · error · NotImplementedException
Cannot convert "{dateOnly}" into {destinationType}
Error message
Cannot convert "{dateOnly}" into {destinationType} What it means
ConvertToDestinationType(DateOnly,...) throws NotImplementedException when the destinationType is not string, DateTime, or DateOnly. The method handles exactly those three targets and rejects anything else (e.g. InstanceDescriptor, object, DateTimeOffset).
Source
Thrown at src/Controls/src/Core/DateTimeTypeConverter.cs:82
throw new NotImplementedException($"Cannot convert \"{value}\" into {destinationType}");
}
static object ConvertToDestinationType(DateOnly dateOnly, Type? destinationType, CultureInfo? culture)
{
if (destinationType == typeof(string))
{
return dateOnly.ToString( CultureInfo.InvariantCulture);
}
else if (destinationType == typeof(DateTime))
{
return dateOnly.ToDateTime(TimeOnly.MinValue);
}
else if (destinationType == typeof(DateOnly))
{
return dateOnly;
}
throw new NotImplementedException($"Cannot convert \"{dateOnly}\" into {destinationType}");
}
static object ConvertToDestinationType(DateTime dateTime, Type? destinationType, CultureInfo? culture)
{
if (destinationType == typeof(string))
{
return dateTime.ToString(CultureInfo.InvariantCulture);
}
else if (destinationType == typeof(DateTime))
{
return dateTime;
}
else if (destinationType == typeof(DateOnly))
{
return DateOnly.FromDateTime(dateTime);
}
throw new NotImplementedException($"Cannot convert \"{dateTime}\" into {destinationType}");View on GitHub (pinned to f377ff1c5e)
Solutions
- Request only string, DateTime, or DateOnly as the destination type.
- If you need another representation, convert manually after obtaining a DateTime via the supported path.
Example fix
// before converter.ConvertTo(ctx, culture, DateOnly.FromDateTime(DateTime.Now), typeof(DateTimeOffset)); // unsupported target // after var dt = (DateTime)converter.ConvertTo(ctx, culture, DateOnly.FromDateTime(DateTime.Now), typeof(DateTime));
Defensive patterns
Strategy: type-guard
Validate before calling
static bool SupportedDateOnlyTarget(Type? t) =>
t == typeof(string) || t == typeof(DateTime) || t == typeof(DateOnly); Type guard
static bool IsSupportedDestination(Type? t) => t is not null && (t == typeof(string) || t == typeof(DateTime) || t == typeof(DateOnly));
Prevention
- Restrict ConvertTo destinationType to string/DateTime/DateOnly.
- For other formats, convert to DateTime then transform manually.
When it happens
Trigger: A designer/serializer or custom code requesting ConvertTo from a DateOnly value to an unsupported destinationType.
Common situations: XAML designer serialization paths; third-party serializers asking for non-supported destination types.
Related errors
- Cannot convert "{dateTime}" into {destinationType}
- Cannot convert "{value}" into {typeof(DateTime)}
- Cannot convert "{value}" into {destinationType}
- XC0004
- XC0040
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/8b2315fbb204f866.
Report an issue: GitHub.