dotnet/maui · error · NotImplementedException
Cannot convert "{dateTime}" into {destinationType}
Error message
Cannot convert "{dateTime}" into {destinationType} What it means
ConvertToDestinationType(DateTime,...) throws NotImplementedException when destinationType is not string, DateTime, or DateOnly. Mirrors the DateOnly overload: only those three targets are accepted.
Source
Thrown at src/Controls/src/Core/DateTimeTypeConverter.cs:100
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}");
}
}
#endifView on GitHub (pinned to f377ff1c5e)
Solutions
- Limit destinationType to string, DateTime, or DateOnly.
- Convert to DateTime first, then transform to the final type yourself.
Example fix
// before converter.ConvertTo(ctx, culture, DateTime.Now, typeof(long)); // ticks not supported // after var s = (string)converter.ConvertTo(ctx, culture, DateTime.Now, typeof(string)); var ticks = DateTime.Parse(s, CultureInfo.InvariantCulture).Ticks;
Defensive patterns
Strategy: type-guard
Validate before calling
static bool SupportedDateTimeTarget(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.
- Convert to DateTime first, then to your custom target manually.
When it happens
Trigger: ConvertTo from a DateTime value to an unsupported destinationType such as InstanceDescriptor, DateTimeOffset, long (ticks), or a custom type.
Common situations: Designer/serialization requesting InstanceDescriptor; converting DateTime to a storage format the converter does not know.
Related errors
- Cannot convert "{value}" into {destinationType}
- Cannot convert "{dateOnly}" into {destinationType}
- Cannot convert "{value}" into {typeof(DateTime)}
- XC0004
- XC0040
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/5996effac43c2174.
Report an issue: GitHub.