rocksdanister/lively · warning · InvalidOperationException

${i18n.GetString("TextUnsupportedFile")} ({Path.GetExtension

Error message

${i18n.GetString("TextUnsupportedFile")} ({Path.GetExtension(filePath)})

What it means

Thrown at the tail of AddWallpaperFile when the file is neither a wallpaper package nor a recognised media type (FileTypes.GetFileType returns the -1 sentinel). The message is the localized 'unsupported file' string plus the actual extension for diagnostics.

Source

Thrown at src/Lively/Lively.UI.Shared/ViewModels/LibraryViewModel.cs:622

                }

                var arguments = fileType.IsApplicationWallpaper() ? 
                    await dialogService.ShowTextInputDialogAsync(i18n.GetString("TextWallpaperCommandlineArgs"), "Examples: --myarguments1 -myargument2") : 
                    string.Empty;

                // Show and confirm project files.
                if (fileType.IsDirectoryProject() && !await dialogService.ShowWallpaperProjectDirectoryDialogAsync(Path.GetDirectoryName(filePath)))
                    return null;

                var result = await desktopCore.CreateWallpaper(filePath, fileType, arguments);
                var model = result != null ? AddWallpaper(result) : null;

                if (autoSetWallpaper && model != null)
                    await desktopCore.SetWallpaper(model, userSettings.Settings.SelectedDisplay);

                return model;
            }
            throw new InvalidOperationException($"{i18n.GetString("TextUnsupportedFile")} ({Path.GetExtension(filePath)})");
        }

        /// <summary>
        /// Bulk import wallpapers; Only supports local media files and wallpaper package format.
        /// </summary>
        public async Task AddWallpapers(List<string> files, CancellationToken cancellationToken, IProgress<int> progress)
        {
            // Bulk import only supports wallpaper package and media files.
            files.RemoveAll(x => !FileTypes.IsWallpaperPackageExtension(x) && !FileTypes.GetFileType(x).IsMediaWallpaper());
            for (int i = 0; i < files.Count; i++)
            {
                try
                {
                    if (cancellationToken.IsCancellationRequested)
                        break;

                    var file = files[i];
                    if (FileTypes.IsWallpaperPackageExtension(file))

View on GitHub (pinned to c1036feb66)

Solutions

  1. Filter the file picker / drag-drop to supported extensions before calling AddWallpaperFile.
  2. Register the new extension in FileTypes if support is intended.
  3. Catch InvalidOperationException and show the localized message + extension to the user.

Example fix

// before
throw new InvalidOperationException($"{i18n.GetString("TextUnsupportedFile")} ({Path.GetExtension(filePath)})");

// after — pre-filter and never reach the throw for known-unsupported types
if (FileTypes.GetFileType(filePath) is (WallpaperType)(-1))
{
    await dialogService.ShowMessageAsync($"{i18n.GetString("TextUnsupportedFile")} ({Path.GetExtension(filePath)})");
    return null;
}
Defensive patterns

Strategy: validation

Validate before calling

if (!FileTypes.IsWallpaperPackageExtension(filePath)
    && FileTypes.GetFileType(filePath) is (WallpaperType)(-1))
{
    await dialogService.ShowMessageAsync($"{i18n.GetString("TextUnsupportedFile")} ({Path.GetExtension(filePath)})");
    return;
}

Type guard

static bool IsSupportedFile(string filePath)
    => FileTypes.IsWallpaperPackageExtension(filePath)
       || FileTypes.GetFileType(filePath) is not (WallpaperType)(-1);

Try / catch

try { await libraryViewModel.AddWallpaperFile(filePath, autoSetWallpaper); }
catch (InvalidOperationException ex) when (ex.Message.Contains(i18n.GetString("TextUnsupportedFile")))
{ /* already user-visible; optionally log */ }

Prevention

When it happens

Trigger: AddWallpaperFile(filePath, ...) where FileTypes.IsWallpaperPackageExtension is false AND FileTypes.GetFileType(filePath) is the (WallpaperType)(-1) sentinel — i.e. an extension Lively cannot handle.

Common situations: User drops a .pdf, .exe, .txt, or an unsupported media format; a new codec/extension not yet registered in FileTypes; case-sensitivity so .MP4 vs .mp4 mismatched the registry.

Related errors


AI-assisted analysis of rocksdanister/lively@c1036feb66 (2026-08-13). Data as JSON: /api/errors/db42ab0ed0b3481a. Report an issue: GitHub.