{"record":{"id":"4d081589090a66c1","repo":"dotnet/wpf","slug":"sr-customdictionarysourcesunsupporteduri","errorCode":null,"errorMessage":"SR.CustomDictionarySourcesUnsupportedURI","messagePattern":"SR\\.CustomDictionarySourcesUnsupportedURI","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/CustomDictionarySources.cs","lineNumber":344,"sourceCode":"        /// Makes sure Uri is of supported kind. Throws exception for unsupported URI type.\n        /// Supported URI types [please keep this list updated]\n        /// 1. Local path\n        /// 2. Relative path\n        /// 3. UNC path\n        /// 4. Pack URI\n        /// </summary>\n        /// <param name=\"item\"></param>\n        private static void ValidateUri(Uri item)\n        {\n            if (item == null)\n            {\n                throw new ArgumentException(SR.CustomDictionaryNullItem);\n            }\n            if (item.IsAbsoluteUri)\n            {\n                if (!(item.IsUnc || item.IsFile || MS.Internal.IO.Packaging.PackUriHelper.IsPackUri(item)))\n                {\n                    throw new NotSupportedException(SR.CustomDictionarySourcesUnsupportedURI);\n                }\n            }\n        }\n        #endregion Private Methods\n        \n        //------------------------------------------------------\n        //\n        //  Private Fields\n        //\n        //------------------------------------------------------\n        #region Private Fields\n        private readonly List<Uri> _uriList;\n        private readonly TextBoxBase _owner;\n        #endregion Private Fields\n\n\n\n    }","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/CustomDictionarySources.cs#L326-L362","documentation":"ValidateUri accepts only UNC, file, or pack Uris as spell-checking dictionary sources; any other absolute Uri scheme throws NotSupportedException(SR.CustomDictionarySourcesUnsupportedURI). HTTP/HTTPS and other remote schemes are not supported because the speller reads dictionary files synchronously from disk or pack resources.","triggerScenarios":"Adding a dictionary Uri with an unsupported scheme (http://, https://, ftp://) via Add/Insert/constructor; only IsUnc, IsFile, or pack Uris pass the check.","commonSituations":"Pointing SpellCheck.CustomDictionaries at a dictionary hosted on a web server, storing dictionary paths in config as URLs instead of file paths, or users entering a URL in a settings UI.","solutions":["Download the dictionary to a local file first, then add a file:// Uri pointing to the local copy.","Convert the path to a valid file or UNC Uri (new Uri(@\"C:\\dicts\\custom.lex\", UriKind.Absolute) or \\\\server\\share\\dict.lex).","Embed the dictionary in the application and reference it via a pack Uri (pack://application:,,,/Dictionaries/custom.lex).","Validate the scheme before adding: allow only file, unc (path starting with \\\\\\\\), or pack."],"exampleFix":"// before\nlexicons.Add(new Uri(\"https://intranet/dicts/custom.lex\")); // throws\n// after\nvar local = Path.Combine(localDictDir, \"custom.lex\");\nawait DownloadDictAsync(new Uri(\"https://intranet/dicts/custom.lex\"), local);\nlexicons.Add(new Uri(local));","handlingStrategy":"validation","validationCode":"bool supported = uri != null && (!uri.IsAbsoluteUri || uri.IsUnc || uri.IsFile || uri.Scheme == \"pack\");","typeGuard":"static bool IsSupportedDictionaryUri(Uri uri) => uri != null && (!uri.IsAbsoluteUri || uri.IsUnc || uri.IsFile || MS.Internal.IO.Packaging.PackUriHelper.IsPackUri(uri));","tryCatchPattern":"try\n{\n    lexicons.Add(uri);\n}\ncatch (NotSupportedException)\n{\n    // unsupported scheme (http/https); download locally and retry with file Uri\n}","preventionTips":["Only use file, UNC, or pack Uris for custom dictionaries","Download remote dictionaries to disk before registering","Validate scheme in settings UIs before persisting paths"],"tags":["wpf","spellcheck","unsupported-uri","dictionary"],"backgroundTag":"unsupported-operation","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"}