Objo.
Feedback Forum Docs Objo Studio
Feedback

Bug #124

`Window.Add` crashes app when the same control instance is added twice

Status
Fixed
Fixed in
v26.5.4
Source discussion
https://forum.objo.dev/d/51-add-the-same-control-in-window-crash-app
Last updated
2026-05-17

Public summary

Summary

Adding the same control instance to a window more than once crashes the desktop app instead of producing a controlled ObjoBasic runtime error.

Reproducing

Var bt As New Button
Self.Add(bt)
Self.Add(bt)

Put this in a window Opening event and run the app.

Expected

The app should not hard-crash. Window.Add(control) should reject a control that already has a visual parent and report a clear runtime error, e.g: "Control has already been added to a window or container."

Actual

The app crashes.

Notes

This is user-invalid code because a single control instance can only have one parent. The bug is that Window.Add posts directly to the Avalonia UI thread and calls ContentCanvas.Children.Add(control) without checking whether the control is already parented.

Objo.

Build apps visually, deploy anywhere.

Feedback is a public read-only status mirror for Objo Studio.