AvaloniaUI / AvaloniaVS

Visual Studio Extension for Avalonia
MIT License
421 stars 81 forks source link

Avalonia Project Library preview selects wrong class for preview, causes InvalidOperationException #393

Open finlaybob opened 11 months ago

finlaybob commented 11 months ago

Describe the bug

Same issue as Rider Plugin https://github.com/ForNeVeR/AvaloniaRider/issues/301

Maybe it's not the plugins and is another issue

The previewer doesn't use the project that the file is part of in the previewer, it's using the executable project that references the library project, and when it's not finding the right method it self destructs.

The UI part of my app needs to be optional and based on configuration, this works at runtime, but being unable to preview is a bit of a blocker.

To Reproduce

Run the program and it should start the app as expected.

Open MainWindow.axaml, it should show the Process Exited error.

Output window should show the stacktrace provided.

AvaloniaVS plugin version

11.1

Avalonia version

11.0.2

Visual Studio version

17.7.3

Relevant log output

15:30:59.136 [Information] 0 Starting previewer process for '"C:\Projects\AvaTest\ZZBase\bin\Debug\net6.0\ZZBase.dll"'
15:30:59.145 [Information] 38960 Started previewer process for '"C:\Projects\AvaTest\ZZBase\bin\Debug\net6.0\ZZBase.dll"'. Waiting for connection to be initialized.
15:30:59.368 [Information] 38960 Connection initialized
15:30:59.368 [Error] 38960 <= "Unhandled exception. System.InvalidOperationException: Unable to create AppBuilder from type \"ZZBase.Program\". Input type either needs to have BuildAvaloniaApp -> AppBuilder method or inherit Application type."
15:30:59.380 [Error] 38960 <= "   at Avalonia.AppBuilder.Configure(Type entryPointType)"
15:30:59.399 [Error] 38960 <= "   at Avalonia.DesignerSupport.Remote.RemoteDesignerEntryPoint.Main(String[] cmdline)"
15:30:59.400 [Error] 38960 <= "   at Avalonia.Designer.HostApp.Program.Main(String[] args)"

Additional context

No response

finlaybob commented 11 months ago

Adding small MVE zip for reproducing the issue

AvaTest.zip