ConsoleGuiTools icon indicating copy to clipboard operation
ConsoleGuiTools copied to clipboard

WSL - Unhandled Exception when executing Out-Gridview command

Open MaximoTrinidad opened this issue 5 years ago • 8 comments

Description: In Windows Subsystem for Linux (WSL) the following exception occurs when executing the Out-Gridview command:

dir | select name | out-gridview

Exception message:

Unhandled Exception: System.TypeInitializationException: The type initializer for 'OutGridView.Application.AvaloniaAppRunner' threw an exception. ---> System.Exception: XOpenDisplay failed
   at Avalonia.X11.AvaloniaX11Platform.Initialize(X11PlatformOptions options)
   at Avalonia.Controls.AppBuilderBase`1.Setup()
   at OutGridView.Application.AvaloniaAppRunner.BuildAvaloniaApp() in D:\a\1\s\src\OutGridView.Gui\AvaloniaAppRunner.cs:line 34
   at OutGridView.Application.AvaloniaAppRunner..cctor() in D:\a\1\s\src\OutGridView.Gui\AvaloniaAppRunner.cs:line 31
   --- End of inner exception stack trace ---
   at OutGridView.Application.Program.Main(String[] args) in D:\a\1\s\src\OutGridView.Gui\Program.cs:line 26

Environment:

Windows 10: WSL 1 (Windows Build 1903) and 2 (Windows 10 Insider Build 18985) - Linux Ubuntu 18.04

PowerShell 7 Preview.4

Microsoft.PowerShell.GraphicalTools v 0.2.0

OG_03_2019-09-23_11-47-36

MaximoTrinidad avatar Sep 23 '19 16:09 MaximoTrinidad

WSL will have to be special cased. It's the only scenario where we want the Windows code path to fire when we run within Linux.

Since WSL has no screen, this exception is expected. However, thanks to WSL being able to launch Winoows processes, we can take advantage of that to get this feature.

TylerLeonhardt avatar Sep 23 '19 20:09 TylerLeonhardt

I've seen some blog posts (not from Msft) on enabling x-windows on WSL which could make this work, but this is really outside the scope of this module for now.

SteveL-MSFT avatar Oct 02 '19 16:10 SteveL-MSFT

@SteveL-MSFT

Yes! But it only works on WSL-1 and not for the insider edition WSL-2. I think this is due to the fact that it uses a VM (at least is my understanding).

MaximoTrinidad avatar Oct 02 '19 18:10 MaximoTrinidad

@MaximoTrinidad yeah, that makes sense since WSL-1 was going through the NT Kernel and effectively was a Windows app while WSL-2 is a VM. I don't see this being supported in WSL-2.

SteveL-MSFT avatar Oct 02 '19 21:10 SteveL-MSFT

@SteveL-MSFT

I just hope that in the future will work. I'll keep praying for it!

:)

MaximoTrinidad avatar Oct 02 '19 21:10 MaximoTrinidad

Please feel free to close this issue if the bottom line is that won't be supported. Thanks!

MaximoTrinidad avatar Oct 02 '19 21:10 MaximoTrinidad

The can be addressed as a feature. We just need to test for WSL and launch the Windows exe instead of the linux exe as that should work. Not sure if PassThru will work though.

TylerLeonhardt avatar Oct 02 '19 22:10 TylerLeonhardt

@TylerLeonhardt

As a Feature for WSL-2! That would be nice.

Keep in mind! It works in WSL-1 Windows 10 RTM with Windows Xserver. This is Great!!

WSL-1_Outgridview_2019-10-03_10-55-48

MaximoTrinidad avatar Oct 03 '19 14:10 MaximoTrinidad

The Windows Subsystem For Linux Preview natively provides an X-server, so this remains important.

RokeJulianLockhart avatar Aug 24 '22 11:08 RokeJulianLockhart

@andschwa This should be closed as won't fix since it's for the Avalona version.

tig avatar Aug 24 '22 12:08 tig