Skip to content

ImageConverter crashes the app when the received file no longer exists #1701

Open

Description

@icysky

Description

When the built-in Image Converter tool receives a file that no longer exists, DevToys terminates immediately with an unhandled FileNotFoundException.

The exception escapes ImageConverterGuiTool.OnDataReceived, which is declared async void, so the try/catch in GuiToolInstance cannot observe it and the process is killed via Task.ThrowAsync.

Steps to reproduce

  1. Put a file reference somewhere that reaches the Image Converter tool (clipboard file list, "Open with DevToys", recent file, etc.).
  2. Delete the file before the tool consumes it.
  3. Start DevToys / open the Image Converter tool.
  4. The app exits a few seconds after startup.

In my case the tool received C:\Users\Admin\Desktop\门岗新环保新流程.png, which had already been deleted.

Expected behavior

Show an error inside the tool (or ignore the incoming data) and keep the application running.

Actual behavior

The whole app crashes. Windows Event Log shows .NET Runtime event 1026 and Application Error event 1000 (KERNELBASE.dll, exception code 0xe0434352).

Stack trace

System.IO.FileNotFoundException: Unable to find the indicated file.
File name: 'C:\Users\Admin\Desktop\门岗新环保新流程.png'
   at DevToys.Api.SimpleSandboxedFileReader..ctor(FileInfo fileInfo) in ...\SimpleSandboxedFileReader.cs:line 21
   at DevToys.Api.SandboxedFileReader.FromFileInfo(FileInfo fileInfo) in ...\SandboxedFileReader.cs:line 31
   at DevToys.Tools.Tools.Graphic.ImageConverter.ImageConverterGuiTool.OnDataReceived(String dataTypeName, Object parsedData) in ...\ImageConverterGuiTool.cs:line 138
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

Environment

  • DevToys: 2.0.9 / 2.0-preview.9 (Windows, %LOCALAPPDATA%\Programs\DevToys Preview)
  • OS: Windows 10 Pro, 10.0.28000.1836
  • .NET: 8.0.22 (CoreCLR 8.0.2225.52707)

Suggested fix

  1. Check FileInfo.Exists before calling SandboxedFileReader.FromFileInfo (in all three OnDataReceived branches: StaticImageFile, StaticImageFiles, and the temp file path).
  2. Avoid async void for OnDataReceived, or wrap the whole body in try/catch and surface the error in the tool UI.
  3. Optionally make SandboxedFileReader.FromFileInfo reject missing files with a clearer, catchable exception.

Logs

Relevant excerpt from %LOCALAPPDATA%\DevToys-preview\Logs\log-20261120T165521.txt:

2026-11-20T16:55:22.7758604+08:00  Information  [DevToys.Core.Tools.GuiToolInstance]  [LogInstanceCreated]  Instance of 'ImageConverter' tool created.
2026-11-20T16:55:22.7809545+08:00  Critical     [DevToys.Windows.MainWindow]  [0]  Unhandled exception !!!
Unable to find the indicated file.
System.IO.FileNotFoundException: Unable to find the indicated file.
File name: 'C:\Users\Admin\Desktop\门岗新环保新流程.png'
   at DevToys.Api.SimpleSandboxedFileReader..ctor(FileInfo fileInfo)
   at DevToys.Api.SandboxedFileReader.FromFileInfo(FileInfo fileInfo)
   at DevToys.Tools.Tools.Graphic.ImageConverter.ImageConverterGuiTool.OnDataReceived(String dataTypeName, Object parsedData)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions