Kir-Antipov / HotAvalonia

🔥 Supercharge your Avalonia development experience with hot reload capabilities
MIT License
165 stars 7 forks source link

[Bug] Can't reload ( Static resource not found) #9

Open MakesYT opened 1 month ago

MakesYT commented 1 month ago

Not sure why I encountered an overloading error, but I couldn't create a minimal example of the problem because I couldn't reproduce the bug Src code: https://github.com/MakesYT/Kitopia/blob/886a4785a087b41381fe005f655d974c388889b3/KitopiaAvalonia/Windows/SearchWindow.axaml

 <Button ToolTip.Tip="{Binding Path=. ,Converter={StaticResource SearchItemToInfo}}"
[2024-05-26 21:18:49,452-ERROR][2][Program] System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. (Static resource 'SearchItemToInfo' not found.)
 ---> System.Collections.Generic.KeyNotFoundException: Static resource 'SearchItemToInfo' not found.
   at Avalonia.Markup.Xaml.MarkupExtensions.StaticResourceExtension.ProvideValue(IServiceProvider serviceProvider)
   at KitopiaAvalonia.Windows.SearchWindow.XamlClosure_21.Build_12(IServiceProvider) in D:\WPF.net\Kitopia\KitopiaAvalonia\Windows/SearchWindow.axaml:line 83
   at Avalonia.Markup.Xaml.XamlIl.Runtime.XamlIlRuntimeHelpers.PointerDeferredContent`1.InvokeBuilder(IServiceProvider serviceProvider)
   at Avalonia.Markup.Xaml.XamlIl.Runtime.XamlIlRuntimeHelpers.DeferredContent`1.Build(IServiceProvider serviceProvider)
   at Avalonia.Markup.Xaml.Templates.TemplateContent.Load[T](Object templateContent)
   at Avalonia.Markup.Xaml.Templates.TemplateContent.Load(Object templateContent)
   at Avalonia.Markup.Xaml.Templates.ControlTemplate.Build(TemplatedControl control)
   at Avalonia.Controls.Primitives.TemplatedControl.ApplyTemplate()
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Controls.VirtualizingStackPanel.RealizeElements(IReadOnlyList`1 items, Size availableSize, MeasureViewport& viewport)
   at Avalonia.Controls.VirtualizingStackPanel.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.LayoutManager.Measure(Layoutable control)
   at Avalonia.Layout.LayoutManager.ExecuteMeasurePass()
   at Avalonia.Layout.LayoutManager.InnerLayoutPass()
   at Avalonia.Layout.LayoutManager.ExecuteLayoutPass()
   at Avalonia.Layout.LayoutManager.ExecuteQueuedLayoutPass()
   at Avalonia.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at Avalonia.Media.MediaContext.RenderCore()
   at Avalonia.Media.MediaContext.Render()
   at Avalonia.Threading.DispatcherOperation.InvokeCore()
   --- End of inner exception stack trace ---
[2024-05-26 21:18:49,454-ERROR][2][Program] System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. (Can only add items to the beginning or end of realized elements.)
 ---> System.NotSupportedException: Can only add items to the beginning or end of realized elements.
   at Avalonia.Controls.Utils.RealizedStackElements.Add(Int32 index, Control element, Double u, Double sizeU)
   at Avalonia.Controls.VirtualizingStackPanel.RealizeElements(IReadOnlyList`1 items, Size availableSize, MeasureViewport& viewport)
   at Avalonia.Controls.VirtualizingStackPanel.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.LayoutManager.Measure(Layoutable control)
   at Avalonia.Layout.LayoutManager.ExecuteMeasurePass()
   at Avalonia.Layout.LayoutManager.InnerLayoutPass()
   at Avalonia.Layout.LayoutManager.ExecuteLayoutPass()
   at Avalonia.Layout.LayoutManager.ExecuteQueuedLayoutPass()
   at Avalonia.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at Avalonia.Media.MediaContext.RenderCore()
   at Avalonia.Media.MediaContext.Render()
   at Avalonia.Threading.DispatcherOperation.InvokeCore()
   --- End of inner exception stack trace ---
Kir-Antipov commented 1 month ago

Sadly, there's not much I can do here: you couldn't build an MRE, and I cannot build your project to investigate what's going on because the KitopiaWeb submodule doesn't seem to be public. Your prebuilt binaries are merged into a single file in an unholy union, so I cannot easily investigate those via ILSpy. And I certainly do not have the Avalonia XAML compiler built directly into my brain (for better or for worse :D), so SearchWindow.axaml is not particularly useful for me as there are no obvious issues with it.

Without at least one of these approaches being accessible to investigate the issue, your guess as to what's gone wrong is as good as mine.

I would greatly appreciate if you could run a CI to build your project without merging it into a single file, so I can grab it from GitHub and inspect the code generated by Avalonia.

MakesYT commented 1 month ago

Sadly, there's not much I can do here: you couldn't build an MRE, and I cannot build your project to investigate what's going on because the KitopiaWeb submodule doesn't seem to be public. Your prebuilt binaries are merged into a single file in an unholy union, so I cannot easily investigate those via ILSpy. And I certainly do not have the Avalonia XAML compiler built directly into my brain (for better or for worse :D), so SearchWindow.axaml is not particularly useful for me as there are no obvious issues with it.

Without at least one of these approaches being accessible to investigate the issue, your guess as to what's gone wrong is as good as mine.

I would greatly appreciate if you could run a CI to build your project without merging it into a single file, so I can grab it from GitHub and inspect the code generated by Avalonia.

KitopiaWeb has no impact on the build project. It is a relatively independent project. There are non-single file builds here https://github.com/MakesYT/Kitopia/releases/tag/0.0.2.049