Skip to content

Skip missing session assemblies when navigating on launch - #3790

Merged
siegfriedpammer merged 1 commit into
masterfrom
fix-navigate-launch-missing-assembly
Jun 17, 2026
Merged

Skip missing session assemblies when navigating on launch#3790
siegfriedpammer merged 1 commit into
masterfrom
fix-navigate-launch-missing-assembly

Conversation

@siegfriedpammer

Copy link
Copy Markdown
Member

Problem

Launching ILSpy with a navigation target (--navigateto/-n, or the VS add-in IPC path) crashes at startup with an unhandled DirectoryNotFoundException when the restored session still references an assembly whose file has since been deleted or moved:

System.IO.DirectoryNotFoundException: Could not find a part of the path '.../test.dll'.
   at ICSharpCode.ILSpyX.LoadedAssembly.GetMetadataFileAsync() ...
   at ICSharpCode.ILSpy.AssemblyTree.AssemblyTreeModel.NavigateOnLaunchAsync(...)
   at ICSharpCode.ILSpy.AssemblyTree.AssemblyTreeModel.HandleCommandLineArgumentsAsync(...)

NavigateOnLaunchAsync eagerly pre-loads every relevant assembly's metadata before resolving the target. When no assembly is passed positionally, "relevant" is the whole restored session list, so a single gone file aborts the entire launch. (Passing an assembly on the command line masks it, because then only that one assembly is relevant.)

Fix

Use the non-throwing GetMetadataFileOrNullAsync() in the pre-load loop (both the N: namespace branch and the type/member branch). A missing or unreadable assembly now resolves to null and is skipped; the subsequent entity search already tolerates null (it uses GetMetadataFileOrNull()), so a still-present navigation target resolves as before.

Test

Adds a headless regression test that injects a session assembly whose file does not exist, then navigates on launch and asserts the launch completes without throwing and the present target (System.Linq.Enumerable) is still selected. The test fails (reproducing the DirectoryNotFoundException) before the fix and passes after. Full ILSpy.Tests suite green.

🤖 Generated with Claude Code

Navigating to a target on startup first eagerly loads every relevant
assembly's metadata so the entity search that follows can resolve it.
That pre-load used the throwing GetMetadataFileAsync, so a restored
session that still referenced an assembly whose file had since been
deleted or moved crashed startup with an unhandled
DirectoryNotFoundException instead of simply skipping the gone entry.

Use GetMetadataFileOrNullAsync there: a missing or unreadable assembly
now resolves to null and is skipped, which the entity search already
tolerates (it uses the OrNull variant too).

Assisted-by: Claude:claude-opus-4-8:Claude Code
@siegfriedpammer
siegfriedpammer merged commit c649060 into master Jun 17, 2026
11 checks passed
@christophwille
christophwille deleted the fix-navigate-launch-missing-assembly branch June 23, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant