microsoft / dotnet

This repo is the official home of .NET on GitHub. It's a great starting point to find many .NET OSS projects from Microsoft and the community, including many that are part of the .NET Foundation.
https://devblogs.microsoft.com/dotnet/
MIT License
14.31k stars 2.21k forks source link

Net 6.x won't run under Wayland if you use Linux. #1341

Open DeafMan1983 opened 2 years ago

DeafMan1983 commented 2 years ago

I use Ubuntu 22.04 and It looks like it works fine with X11 but dotnet build/release -c [Release/Debug] then it happens if I have valid pinvoke from libwayland-client.so.0

Write create unsafe struct Display from wl_display then I write pinvoke for example [DLLImport("libwayland-client.so.0")] private unsafe static extern Display wl_display_connect(byte host_name);

I checked if wl_display doesn't run while I have checked echo $XDG_SESSION_TYPE I am using Ubuntu 22.04 - Wayland -> current. But it loads weird with X11 but Wayland won't run for C#

Example:

using XLib;
using Wayland;

namespace SampleXDP;

public unsafe class Program
{
    static void Main()
    {
        // Trying to check XDG_SESSION_TYPE if I use X11 or Wayland
        Console.WriteLine(Environment.GetEnvironmentVariable("XDG_SESSION_TYPE"));

        // Loading X11
        X11.Display* x11_display = X11.OpenDisplay(string.Empty);
        if (x11_display == null)
        {
            Console.WriteLine("Can't open to Display of X11!");
        }
        Console.WriteLine("Running X11...");

        X11.CloseDisplay(x11_display);
        Console.WriteLine("Closing Display...");

        // Loading Wayland
        WL.Display* wl_display = WL.DisplayConnect("");
        if (wl_display == null)
        {
            Console.WriteLine("Can't connect to Display of Wayland!");
        }

        Console.WriteLine("Wayland running");

        WL.DisplayDisconnect(wl_display);
        Console.WriteLine("Closed Wayland!");
    }
}

Result: image

But It happens. Is it bug in Net 6.0 or Electron 17 version? If I use Wayland under Ubuntu 22.04 I don't understand why does Net load weird with wrong XDP_SESSION while You ran with X11 library and shows works like XOpenDisplay, XCloseDisplay are working out. But Wayland can't do like it looks failed to run.

Do you have same bug? Let's know me what does it happen under Ubuntu 22.04 with Net 6.x?