How access System.Windows.Forms by Powershell on Linux (Ubuntu)

I am developing a GUI with Powershell on Ubuntu (via Virtual Box) but I am not able to use System.Windows.Forms:

I installed Mono-devel,
I searched apt-file search System.Windows.Forms.dll retrieving 12 different version,
I copied the dll version 4.8 in the script directory,
I run the command Add-Type -AssemblyName System.Windows.Forms
The version 4.8 tells

Add-Type: Could not load file or assembly 'System.Windows.Forms, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Reference assemblies cannot be loaded for execution. (0x80131058)

The previous ones tells:

Add-Type could not load file or assembly ‘<Unknown>’ Index not found. (0x80131124)


I’m not a fan of PowerShell GUIs so I never felt the urge to create one so I actually don’t have experiences on this particular topic. But I wouldn’t expect a Windows exclusive library like System.Windows.Forms.dll to work on Linux ever. :thinking:

PowerShell core (version 6 and up) is based on dotNet core what does not have Windows dlls. :man_shrugging:t3:

1 Like

Yup, not supported on Linux

1 Like

Mono has a System.Windows.Forms.dll.
Some time ago my powershell script (de)generate a form.

Have you tried loading the assembly from file?

Add-Type -AssemblyName '/opt/somefolder/somedll.dll'

More info:

Thanks tonyd
I tried , I found some dlls, but they were rejected.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.