X11: System.Exception: Unable to initialize GTK on separate thread
See original GitHub issueDescribe the bug The exception in the title is thrown when opening a file dialog.
To Reproduce Create a new project using the Avalonia .NET Core App template. (NOT THE MVVM ONE). Here’s the relevant code that triggers the exception:
<!-- MainWindow.axaml -->
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="JGCodes.AvaloniaTest.MainWindow"
Title="Avalonia Test">
<Button Name="SpecialButton" Click="OnButtonClick">Open, sesame!</Button>
</Window>
// MainWindow.axaml.cs
using Avalonia.Controls;
using Avalonia.Interactivity;
namespace JGCodes.AvaloniaTest
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
public async void OnButtonClick(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new();
await ofd.ShowAsync(this);
}
}
}
Run the project, click the button, and receive the above exception.
Expected behavior A file dialog should appear.
Desktop (please complete the following information):
- OS: Linux (ArcoLinux, KDE, XWayland)
- Version 0.10.17
Additional context N/A
Issue Analytics
- State:
- Created a year ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
SSH X11 forwarding with sudo and missing magic cookies
After doing this, X11 forwarding works, but it's a non-optimal solution since the cookie ... RuntimeError: Unable to initialize GTK: could not open...
Read more >MessageDialog in separate thread - c++
I can't open that MessageDialog in the main thread, because then it is blocked and I can't do my calculations, so I wanted...
Read more >EM Server automatically going down - BMC Community
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable. at sun.awt.
Read more >Lunacy Linux version crashes when Saving
mrmikel@Debian:~$ lunacy Unhandled exception. System.Exception: Unable to initialize GTK on separate thread at Avalonia.X11.NativeDialogs.
Read more >How do I fix a "cannot open display" error when ...
8), opening an terminal in X11 and running xhost + , I then ssh -Y to my Ubuntu 10.04 VM (running on VMware...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Should be fixed with 11.0 previews, as we use FreeDesktop dialogs instead, when available. Also, GTK initialization was changed, which might also solve old issue, if FreeDesktop is not available.
Please let us know if it’s still a problem in 11.0 previews.
FWIW, my workaround. below the ViewModel code, use binding to the view model. You do need kdialog installed on KDE systems for this to work.
Here the ViewModel code
And here the helper class