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

Event Generation in AvaloniaVS Causes Preview to Crash #402

Open
kadir-ince opened this issue Oct 11, 2023 · 5 comments
Open

Event Generation in AvaloniaVS Causes Preview to Crash #402

kadir-ince opened this issue Oct 11, 2023 · 5 comments
Labels

Comments

@kadir-ince
Copy link

Describe the bug

The preview crashes as soon as an event is generated. The preview only comes back to life after building the project. Until then, the preview remains in a crashed state.

Recording.2023-10-11.090303.mp4

To Reproduce

Open a AvaloniaUI project in Visual Studio.
Use the Avalonia for Visual Studio extension to generate an event.
Observe that the preview crashes immediately after the event is generated.

AvaloniaVS plugin version

11.4

Avalonia version

11.0.2

Visual Studio version

17.8.0 Preview 3.0

Relevant log output

09:10:01.497 [Information] 0 Starting previewer process for '"C:\Users\kince\Desktop\AvaloniaUI\AvaloniaApplication1\AvaloniaApplication1\bin\Debug\net7.0\AvaloniaApplication1.dll"'
09:10:01.513 [Information] 2960 Started previewer process for '"C:\Users\kince\Desktop\AvaloniaUI\AvaloniaApplication1\AvaloniaApplication1\bin\Debug\net7.0\AvaloniaApplication1.dll"'. Waiting for connection to be initialized.
09:10:01.664 [Information] 2960 Connection initialized
09:10:05.995 [Error] 2960 UpdateXamlResult error
System.Xaml.XamlException: ''/' is an unexpected token. The expected token is '='. Line 9, position 42.' Line number '9' and line position '42'.
09:10:06.539 [Error] 2960 UpdateXamlResult error
System.Xaml.XamlException: ''/' is an unexpected token. The expected token is '='. Line 9, position 42.' Line number '9' and line position '42'.
09:10:08.838 [Error] 2960 UpdateXamlResult error
System.Xaml.XamlException: 'Unable to find suitable setter or adder for property Click of type Avalonia.Controls:Avalonia.Controls.Button for argument System.Private.CoreLib:System.String, available setter parameter lists are:
System.EventHandler`1[[Avalonia.Interactivity.RoutedEventArgs, Avalonia.Base, Version=11.0.2.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b]] Line 9, position 39.' Line number '9' and line position '39'.

Additional context

No response

@kadir-ince kadir-ince added the bug label Oct 11, 2023
@maxkatz6
Copy link
Member

It is required to recompile C# project in order to see any changes in the previewer.
Extension should disable the previewer until user completes his handler method and recompiles the project. With a hint message in the place of the previewer.

@maxkatz6
Copy link
Member

Alternatively, extension can force recompilation which isn't always a desired solution.

@Takoooooo
Copy link
Contributor

It is required to recompile C# project in order to see any changes in the previewer. Extension should disable the previewer until user completes his handler method and recompiles the project. With a hint message in the place of the previewer.

It works without recompilation in WPF. Do we have any options to make that work as it does in WPF?

@maxkatz6
Copy link
Member

Do we have any options to make that work as it does in WPF

No. Well, we can inject an empty event handler into the assembly, but I feel like it will cause more conflicts between original and modified assemblies.

Keep in mind that WPF previewer didn't actually run the application, but only previewed the XAML.

@HydrogenC
Copy link

HydrogenC commented Mar 25, 2024

However, it doesn't even fix even after I recompile the project.

The previewer says invalid markup and the error list says Unable to find suitable setter or adder for property Click of type Avalonia.Controls:Avalonia.Controls.Button for argument System.Private.CoreLib:System.String, available setter parameter lists are: System.EventHandler1[[Avalonia.Interactivity.RoutedEventArgs, Avalonia.Base, Version=11.0.2.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b]].

I swear that my function signature is correct and the code is able to run without exceptions.
It works normally only after I restarted the whole VS.

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

4 participants