How to use Avalonia with WSL Ubuntu Linux? #11608
Replies: 5 comments 2 replies
-
Foreget the prev. comment. The issue is linked already. So in that case, please update to RC1 and also try to run the App without debugger. |
Beta Was this translation helpful? Give feedback.
-
I have in the meantime created and tested a sample MVVM RC candidate app but it shows the same problem, under WSL Ubuntu 22 (where I did install gedit to have GTK support) the Window "frame" comes up shortly, then vanishes, and the console shows a segmentation fault, under WSL Ubuntu 20 (also with gedit installed to have GTK support) the Window shows up and the app seems to work, only on closing the app window the console (also) show a segmentation fault. This is all done with release builds, so no debugger involved. I also went to the trouble to install a complete Ubuntu 22 Desktop in a Windows 11 Hyper-V VM, there everything Avalonia Desktop related works (haven't tried RC there yet), so this problem seems with some configuration/dependency of Ubuntu WSL I just might lack the right clue to solve or prevent (to have on the one hand the needed GTK dependencies installed but not mess up the installation to then run into segmentation faults). |
Beta Was this translation helpful? Give feedback.
-
No, the packages mentioned there are already installed; what I additionally did to get a file dialog was to install a GTK tool like Where I don't install |
Beta Was this translation helpful? Give feedback.
-
Avalonia uses the xdg-desktop-portal to provide native file choosers, see https://wiki.archlinux.org/title/XDG_Desktop_Portal. |
Beta Was this translation helpful? Give feedback.
-
How to get ubuntu-24.04 and Avalonia on WSL: In windows command line run:
The following commands are all from the wsl linux shell.
the dotnet 8 installation can be verified with
to run avalonia programs you need a few additional dependencies:
|
Beta Was this translation helpful? Give feedback.
-
In #11554 I reported problems to use OpenFileDialog with a Windows 11 WSL Ubuntu 22 installation as my intent to do so resulted in an error
Unhandled exception. System.InvalidOperationException: Neither DBus nor GTK are available on the system
.I inferred from the comments and the error message that additional packages needed to be installed under WSL Ubuntu Linux to have that worked and initially though that installing gedit is one way to have (I think) GTK on the system.
But in the end on a closer look it turns out that, at least in my tests, that makes gedit run without problems under both WSL Ubuntu 20 and 22 but for AvaloniaUI apps I get segmentation fault errors, under Ubuntu 20 only when closing the app, but with Ubuntu 22 it is not even possible to start up an app successfully, the window frame shows up, but then dies and the segmentation fault shows up in the console.
That is, after some testing, not happening in my own apps code but happens with just the app created by the template e.g.
dotnet new avalonia.mvvm
.And the segmentation fault happens then (after installing gedit in the hope to add GTK dependencies) with both Avalonia 10 or preview 11 apps (I have not tried the 11 RC so far).
Perhaps it is just my lack of understanding of how cleanly install the
DBus nor GTK
dependencies for WSL Ubuntu Linux, without ending up with segmentation faults for Avalonia desktop apps.Any hints appreciated.
Beta Was this translation helpful? Give feedback.
All reactions