{"record":{"id":"ee3d749fe0cdec4d","repo":"dotnet/wpf","slug":"sr-invalidabsoluteuriinfontfamilyname","errorCode":null,"errorMessage":"SR.InvalidAbsoluteUriInFontFamilyName","messagePattern":"SR\\.InvalidAbsoluteUriInFontFamilyName","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Fonts.cs","lineNumber":92,"sourceCode":"        /// <returns>Collection of FontFamily objects from the specified font location.</returns>\n        /// <remarks>\n        /// The caller must have FileIOPermission(FileIOPermissionAccess.Read) for the specified font folder.\n        /// Each resulting FontFamily object has the specified base Uri as its BaseUri property and includes the\n        /// specified location as part of the friendly name specified by the Source property.\n        /// </remarks>\n        public static ICollection<FontFamily> GetFontFamilies(Uri baseUri, string location)\n        {\n            // Both Uri parameters are optional but neither can be relative.\n            if (baseUri != null && !baseUri.IsAbsoluteUri)\n                throw new ArgumentException(SR.UriNotAbsolute, nameof(baseUri));\n\n            // Determine the font location from the base URI and location string.\n            Uri fontLocation;\n            if (!string.IsNullOrEmpty(location) && Uri.TryCreate(location, UriKind.Absolute, out fontLocation))\n            {\n                // absolute location; make sure we support absolute font family references for this scheme\n                if (!Util.IsSupportedSchemeForAbsoluteFontFamilyUri(fontLocation))\n                    throw new ArgumentException(SR.InvalidAbsoluteUriInFontFamilyName, nameof(location));\n\n                // make sure the absolute location is a valid URI reference rather than a Win32 path as\n                // we don't support the latter in a font family reference\n                location = fontLocation.GetComponents(UriComponents.AbsoluteUri, UriFormat.SafeUnescaped);\n            }\n            else\n            {\n                // relative location; we need a base URI\n                if (baseUri == null)\n                    throw new ArgumentNullException(nameof(baseUri), SR.Format(SR.NullBaseUriParam, \"baseUri\", \"location\"));\n\n                // the location part must include a path component, otherwise we'll look in windows fonts and ignore the base URI\n                if (string.IsNullOrEmpty(location))\n                    location = \"./\";\n                else if (Util.IsReferenceToWindowsFonts(location))\n                    location = \"./\" + location;\n\n                fontLocation = new Uri(baseUri, location);","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Fonts.cs#L74-L110","documentation":"Fonts.GetFontFamilies throws this ArgumentException when the 'location' string parses as an absolute Uri but its scheme is not supported for absolute font family references (Util.IsSupportedSchemeForAbsoluteFontFamilyUri fails). The library only allows specific schemes (pack, file, http/https) in absolute font locations.","triggerScenarios":"Calling GetFontFamilies(baseUri, \"ftp://server/fonts\") or any absolute Uri with an unsupported scheme (ftp, ldap, custom app schemes).","commonSituations":"Pointing font enumeration at a network share via a non-HTTP UNC-style or custom protocol string that happens to parse as an absolute Uri.","solutions":["Use a supported scheme (pack, file, or http/https) in the location.","For a network path, copy fonts locally or serve over a supported scheme.","Pass the location as a relative string plus an absolute baseUri instead."],"exampleFix":"// before\nFonts.GetFontFamilies(null, \"ftp://server/fonts\");\n// after\nFonts.GetFontFamilies(null, \"file:///server/fonts\");","handlingStrategy":"validation","validationCode":"if (Uri.TryCreate(location, UriKind.Absolute, out var abs)\n    && !(abs.Scheme == Uri.UriSchemeFile || abs.Scheme == Uri.UriSchemeHttp || abs.Scheme == Uri.UriSchemeHttps || abs.Scheme == \"pack\"))\n    throw new ArgumentException(\"unsupported scheme\", nameof(location));","typeGuard":null,"tryCatchPattern":"try { Fonts.GetFontFamilies(null, location); }\ncatch (ArgumentException) { /* unsupported absolute scheme; reformat location */ }","preventionTips":["Restrict font locations to file, http(s), or pack schemes.","Prefer relative locations with an absolute baseUri over custom-scheme absolute Uris.","Copy fonts from exotic sources (ftp, shares) to a local file path first."],"tags":["wpf","fonts","uri","scheme"],"backgroundTag":"invalid-url","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}