Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
finlaybob opened this issue Oct 6, 2023 · 1 comment
Labels

Comments

@finlaybob
Copy link

finlaybob commented Oct 6, 2023

Describe the bug

Same issue as Rider Plugin
ForNeVeR/AvaloniaRider#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

  • Create a new solution
  • Create a console app, ZZBase
  • Create an avalonia .net app ZZUi
    • change ZZUi.csproj OutputType from WinExe to Library
    • Make Program public
    • Remove [STAThread] Attribute from ZZUi.Program.Main
  • Reference ZZUi from ZZBase
  • Call ZZUi.Program.Main(args);

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 finlaybob added the bug label Oct 6, 2023
@finlaybob
Copy link
Author

Adding small MVE zip for reproducing the issue

AvaTest.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant