Skip to content

Fix startup binding errors and background load sweep failure - #4206

Merged
siegfriedpammer merged 4 commits into
masterfrom
christophwille/fix-startup-binding-errors
Oct 5, 2026
Merged

siegfriedpammer merged 4 commits into
masterfrom
christophwille/fix-startup-binding-errors

Conversation

@christophwille

Copy link
Copy Markdown
Member

The console of a "Start Debugging" session in VS Code showed 12 [Binding] errors in three groups and one swallowed exception. Each has its own commit; this is what was in the output and how it was fixed.

1. Update banner (6 errors)

[Binding]An error occurred binding 'IsVisible' to 'IsPanelVisible' at 'IsPanelVisible': 'Unable to cast object of type 'ICSharpCode.ILSpy.ViewModels.MainWindowViewModel' to type 'ICSharpCode.ILSpy.ViewModels.UpdatePanelViewModel'.' (UpdatePanel #19766715)

The same error was logged for UpdateAvailable, Message, ButtonText, DownloadOrCheckUpdateCommand and CloseCommand.

  • Cause: MainWindow.axaml gave the panel a DataContext="{Binding UpdatePanel}" of its own. Until that binding produced a value the panel inherited the window's MainWindowViewModel, and its compiled bindings (x:DataType="vm:UpdatePanelViewModel") failed the cast.
  • Fix: the panel is hosted in a ContentControl with a DataTemplate, so it never sees the window's view model.

2. Dock chrome (4 errors)

[Binding]An error occurred binding '(unknown)' to 'DockCapabilityOverrides.CanDrag' at 'DockCapabilityOverrides': 'Value is null.' (ToolChromeControl #61244865)

Logged for CanDrag and CanDrop, on both ToolChromeControl and DocumentControl.

  • Cause: the Dock theme (checked by decompiling Dock.Avalonia.Themes.Simple 12.1.0.6) binds DockCapabilityOverrides.CanDrag/CanDrop on the tool and document docks themselves. ILSpyDockFactory only set that property on panes and tabs, and a layout restored from disk bypasses CreateLayout altogether.
  • Fix: InitLayout fills in DockCapabilityOverrides for every dockable, which covers fresh and restored layouts. The tool dock created on demand after InitLayout gets it in its initializer.

3. Tree connector lines (2 errors)

[Binding]An error occurred binding 'IsVisible' to '$visualParent[SharpTreeView].ShowLines' at '$visualParent[SharpTreeView]': 'Ancestor not found.' (TreeLines #35340021)
  • Cause: the row template bound TreeLines.IsVisible to ShowLines on a SharpTreeView ancestor, and the binding was evaluated while the row content was not under one. The exact moment was not reproduced in the headless tests.
  • Fix: the binding is removed. ShowLines is now an inherited property that TreeLines reads directly, so there is no ancestor lookup left to fail. The DataGridHierarchicalPresenter use of TreeLines has no SharpTreeView above it and keeps the default (lines shown).

4. Background load sweep

[AssemblyTreeModel] background load sweep failed: System.IO.DirectoryNotFoundException: Could not find a part of the path '.../sdk/11.0.100-preview.6.26359.118/Roslyn/Microsoft.Build.Tasks.CodeAnalysis.dll'.
  • Cause: one assembly-list entry that could not be loaded faulted the whole sweep, which skipped the CommandManager.InvalidateRequerySuggested() at its end. "Remove assemblies with load errors" was therefore not re-evaluated in the one case it exists for.
  • Fix: the per-assembly task catches the load failure (it is already recorded on the LoadedAssembly as HasLoadError), so the sweep always reaches the requery.

Tests

  • StartupBindingErrorTests boots the main window with a capturing Avalonia log sink and fails on any binding error. It was red for group 1 and, separately, for group 2 before the fixes.
  • BackgroundLoadSweepTests shows a list whose only assembly fails to load at a moment the test controls, and waits for the requery. It timed out before the fix. AssemblyTreeModel.ShowAssemblyList(AssemblyList) went from private to internal for it.
  • SharpTreeViewTests gained a case that rows follow the tree view's ShowLines. It does not reproduce the original "Ancestor not found" error.
  • Full ILSpy.Tests run: 1315 succeeded, 3 skipped, 0 failed.

Not verified: a fresh "Start Debugging" session in VS Code to confirm the console is clean.

Assisted-by: Claude:claude-fable-5-1:Claude Code

Dock's theme binds DockCapabilityOverrides.CanDrag/CanDrop on the tool and
document docks themselves, not only on the panes inside them, and logged a
binding error per property at startup. Filling them in from InitLayout
covers layouts restored from disk, which never pass through CreateLayout.

Assisted-by: Claude:claude-fable-5-1:Claude Code
With a DataContext binding of its own the panel first inherited the main
window's view model, and each of its compiled bindings failed the cast to
UpdatePanelViewModel and logged an error at startup. The new test boots the
window with a capturing log sink and fails on any binding error.

Assisted-by: Claude:claude-fable-5-1:Claude Code
The ancestor binding logged 'Ancestor not found' whenever a row's content
was evaluated outside a SharpTreeView. An inherited property needs no
lookup, and leaves the lines on where there is no tree view at all.

Assisted-by: Claude:claude-fable-5-1:Claude Code
One assembly that failed to load faulted the whole sweep, which skipped
the command requery at its end. 'Remove assemblies with load errors' was
therefore not re-evaluated in the one case it exists for.
ShowAssemblyList(AssemblyList) is internal so the test can show a list
whose load it controls.

Assisted-by: Claude:claude-fable-5-1:Claude Code
@siegfriedpammer
siegfriedpammer merged commit c993bef into master Oct 5, 2026
15 checks passed
@siegfriedpammer
siegfriedpammer deleted the christophwille/fix-startup-binding-errors branch October 5, 2026 15:01
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.

2 participants