{"record":{"id":"1bac3db43e60366b","repo":"dotnet/maui","slug":"uri-1bac3d","errorCode":null,"errorMessage":"uri","messagePattern":"uri","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/iOS/Platform.cs","lineNumber":663,"sourceCode":"\t\t\t\tif (uri.LocalPath.StartsWith(\"/local\"))\n\t\t\t\t{\n\t\t\t\t\tvar libraryPath = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.User)[0].Path;\n\t\t\t\t\tfilePath = IOPath.Combine(libraryPath, uri.LocalPath.Substring(7));\n\t\t\t\t}\n\t\t\t\telse if (uri.LocalPath.StartsWith(\"/temp\"))\n\t\t\t\t{\n\t\t\t\t\tfilePath = IOPath.Combine(IOPath.GetTempPath(), uri.LocalPath.Substring(6));\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tthrow new ArgumentException(\"Invalid Uri\", \"Source\");\n\t\t\t\t}\n\n\t\t\t\treturn filePath;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthrow new ArgumentException(\"uri\");\n\t\t\t}\n\t\t}\n\n\t\tinternal void SubscribeToAlertsAndActionSheets()\n\t\t{\n\t\t\tvar busyCount = 0;\n\t\t\tMessagingCenter.Subscribe(this, Page.BusySetSignalName, (Page sender, bool enabled) =>\n\t\t\t{\n\t\t\t\tif (!PageIsChildOfPlatform(sender))\n\t\t\t\t\treturn;\n\t\t\t\tbusyCount = Math.Max(0, enabled ? busyCount + 1 : busyCount - 1);\n#pragma warning disable CA1416, CA1422  // TODO: 'UIApplication.NetworkActivityIndicatorVisible' is unsupported on: 'ios' 13.0 and later\n\t\t\t\tUIApplication.SharedApplication.NetworkActivityIndicatorVisible = busyCount > 0;\n#pragma warning restore CA1416, CA1422\n\t\t\t});\n\n\t\t\tMessagingCenter.Subscribe(this, Page.AlertSignalName, (Page sender, AlertArguments arguments) =>\n\t\t\t{","sourceCodeStart":645,"sourceCodeEnd":681,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/iOS/Platform.cs#L645-L681","documentation":"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.","triggerScenarios":"Passing a null or unsupported uri value to the platform's Uri resolver; a Uri that is not absolute and not a recognized scheme.","commonSituations":"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.","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."],"exampleFix":"// before\nvar path = Platform.ResolveUri(uri);\n// after\nif (uri == null || !uri.IsAbsoluteUri)\n    throw new ArgumentException(\"A valid absolute file Uri is required.\", nameof(uri));\nvar path = Platform.ResolveUri(uri);","handlingStrategy":"validation","validationCode":"if (uri == null || !uri.IsAbsoluteUri)\n    throw new ArgumentException(\"A valid absolute Uri is required.\", nameof(uri));","typeGuard":"static bool IsValidAbsoluteUri(Uri u) => u != null && u.IsAbsoluteUri;","tryCatchPattern":null,"preventionTips":["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."],"tags":["maui","xamarin-forms","ios","uri","files","argument"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}