dotnet/maui · error · ArgumentException
uri
Error message
uri
What it means
Platform.cs throws ArgumentException("uri") on the else branch when the supplied uri is not a recognized file-style Uri at all (i.e. it is null or not usable as a local file). This is the fallback for unrecognized inputs that did not match the file-path resolution logic.
Source
Thrown at src/Compatibility/Core/src/iOS/Platform.cs:663
if (uri.LocalPath.StartsWith("/local"))
{
var libraryPath = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.User)[0].Path;
filePath = IOPath.Combine(libraryPath, uri.LocalPath.Substring(7));
}
else if (uri.LocalPath.StartsWith("/temp"))
{
filePath = IOPath.Combine(IOPath.GetTempPath(), uri.LocalPath.Substring(6));
}
else
{
throw new ArgumentException("Invalid Uri", "Source");
}
return filePath;
}
else
{
throw new ArgumentException("uri");
}
}
internal void SubscribeToAlertsAndActionSheets()
{
var busyCount = 0;
MessagingCenter.Subscribe(this, Page.BusySetSignalName, (Page sender, bool enabled) =>
{
if (!PageIsChildOfPlatform(sender))
return;
busyCount = Math.Max(0, enabled ? busyCount + 1 : busyCount - 1);
#pragma warning disable CA1416, CA1422 // TODO: 'UIApplication.NetworkActivityIndicatorVisible' is unsupported on: 'ios' 13.0 and later
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = busyCount > 0;
#pragma warning restore CA1416, CA1422
});
MessagingCenter.Subscribe(this, Page.AlertSignalName, (Page sender, AlertArguments arguments) =>
{View on GitHub (pinned to f377ff1c5e)
Solutions
- Validate the uri is non-null and absolute before passing.
- For remote images use UriImageSource with an http(s) Uri; for local files use the correct /local or /temp prefix.
- Guard the binding path so a null/empty Uri does not reach the platform resolver.
Example fix
// before
var path = Platform.ResolveUri(uri);
// after
if (uri == null || !uri.IsAbsoluteUri)
throw new ArgumentException("A valid absolute file Uri is required.", nameof(uri));
var path = Platform.ResolveUri(uri); Defensive patterns
Strategy: validation
Validate before calling
if (uri == null || !uri.IsAbsoluteUri)
throw new ArgumentException("A valid absolute Uri is required.", nameof(uri)); Type guard
static bool IsValidAbsoluteUri(Uri u) => u != null && u.IsAbsoluteUri;
Prevention
- Validate uri is non-null and absolute before resolving.
- Use UriImageSource for http(s) Uris, file prefixes for local files.
- Guard binding paths against null/empty Uris.
When it happens
Trigger: Passing a null or unsupported uri value to the platform's Uri resolver; a Uri that is not absolute and not a recognized scheme.
Common situations: Setting ImageSource to a null Uri; passing a relative Uri; feeding an http Uri where a file Uri is required by the local-file resolution path; binding source set before Uri assignment.
Related errors
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/1bac3db43e60366b.
Report an issue: GitHub.