dotnet/wpf · error · NotSupportedException
SR.CustomDictionarySourcesUnsupportedURI
Error message
SR.CustomDictionarySourcesUnsupportedURI
What it means
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.
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.
Example fix
// before
lexicons.Add(new Uri("https://intranet/dicts/custom.lex")); // throws
// after
var local = Path.Combine(localDictDir, "custom.lex");
await DownloadDictAsync(new Uri("https://intranet/dicts/custom.lex"), local);
lexicons.Add(new Uri(local)); Defensive patterns
Strategy: validation
Validate before calling
bool supported = uri != null && (!uri.IsAbsoluteUri || uri.IsUnc || uri.IsFile || uri.Scheme == "pack");
Type guard
static bool IsSupportedDictionaryUri(Uri uri) => uri != null && (!uri.IsAbsoluteUri || uri.IsUnc || uri.IsFile || MS.Internal.IO.Packaging.PackUriHelper.IsPackUri(uri));
Try / catch
try
{
lexicons.Add(uri);
}
catch (NotSupportedException)
{
// unsupported scheme (http/https); download locally and retry with file Uri
} Prevention
- 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
When it happens
Trigger: Adding a dictionary Uri with an unsupported scheme (http://, https://, ftp://) via Add/Insert/constructor; only IsUnc, IsFile, or pack Uris pass the check.
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- SR.CustomDictionaryItemAlreadyExists
- SR.CustomDictionaryNullItem
- ArgumentException: path
- ArgumentException: relativeTo
- ArgumentNullException: path
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/4d081589090a66c1.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/CustomDictionarySources.cs:344
/// Makes sure Uri is of supported kind. Throws exception for unsupported URI type.
/// Supported URI types [please keep this list updated]
/// 1. Local path
/// 2. Relative path
/// 3. UNC path
/// 4. Pack URI
/// </summary>
/// <param name="item"></param>
private static void ValidateUri(Uri item)
{
if (item == null)
{
throw new ArgumentException(SR.CustomDictionaryNullItem);
}
if (item.IsAbsoluteUri)
{
if (!(item.IsUnc || item.IsFile || MS.Internal.IO.Packaging.PackUriHelper.IsPackUri(item)))
{
throw new NotSupportedException(SR.CustomDictionarySourcesUnsupportedURI);
}
}
}
#endregion Private Methods
//------------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
#region Private Fields
private readonly List<Uri> _uriList;
private readonly TextBoxBase _owner;
#endregion Private Fields
}View on GitHub (pinned to 81131a70a4)