.Net framework application for 6.4 BSP

Dear support,

Hello, I am currently trying to migrate my old application that is running on BSP 2.8b7. In order to test the procedure, I have developed a simple HelloWorld application.
mono-test
However, when I attempt to run it using mono, I am encountering the following issues:

root@colibri-imx6-11101965:~/test# mono test.exe

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'System.Windows.Forms.XplatUI' threw an exception. ---> System.ArgumentNullException: Could not open display (X-Server required. Check your DISPLAY environment variable)
Parameter name: Display
  at System.Windows.Forms.XplatUIX11.SetDisplay (System.IntPtr display_handle) [0x003d0] in <93691e59f439433484aaf50c07423456>:0
  at System.Windows.Forms.XplatUIX11..ctor () [0x00077] in <93691e59f439433484aaf50c07423456>:0
  at System.Windows.Forms.XplatUIX11.GetInstance () [0x00019] in <93691e59f439433484aaf50c07423456>:0
  at System.Windows.Forms.XplatUI..cctor () [0x000c0] in <93691e59f439433484aaf50c07423456>:0
   --- End of inner exception stack trace ---
  at System.Windows.Forms.Application.EnableVisualStyles () [0x00006] in <93691e59f439433484aaf50c07423456>:0
  at test.Program.Main () [0x00001] in <d081c7dc415b47e4903a14d4ea56db9d>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'System.Windows.Forms.XplatUI' threw an exception. ---> System.ArgumentNullException: Could not open display (X-Server required. Check your DISPLAY environment variable)
Parameter name: Display
  at System.Windows.Forms.XplatUIX11.SetDisplay (System.IntPtr display_handle) [0x003d0] in <93691e59f439433484aaf50c07423456>:0
  at System.Windows.Forms.XplatUIX11..ctor () [0x00077] in <93691e59f439433484aaf50c07423456>:0
  at System.Windows.Forms.XplatUIX11.GetInstance () [0x00019] in <93691e59f439433484aaf50c07423456>:0
  at System.Windows.Forms.XplatUI..cctor () [0x000c0] in <93691e59f439433484aaf50c07423456>:0
   --- End of inner exception stack trace ---
  at System.Windows.Forms.Application.EnableVisualStyles () [0x00006] in <93691e59f439433484aaf50c07423456>:0
  at test.Program.Main () [0x00001] in <d081c7dc415b47e4903a14d4ea56db9d>:0
root@colibri-imx6-11101965:~/test#

i have added mono to my BSP using Yocto and it seems to be fine :

root@colibri-imx6-11101965:~/test# mono --version
Mono JIT compiler version 6.12.0.182 (tarball Sun 24 Dec 2023 10:28:00 AM UTC)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       normal
        Notifications: epoll
        Architecture:  armel,vfp+hard
        Disabled:      none
        Misc:          softdebug
        Interpreter:   yes
        LLVM:          supported, not enabled.
        Suspend:       preemptive
        GC:            sgen (concurrent by default)
root@colibri-imx6-11101965:~/test#

Could you please assist me in figuring out the issue?
i am using : colibri IMX6 based on 6.4BSP with Colibri-iMX6_Reference-Multimedia-Image-upstream-Tezi_6.5.0-devel-20231224113403+build.0.tar Yocto tag and iris career board

Hi @me_ahani98 !

Could you please share the output of tdx-info? (reference: Getting Device Information with Tdx-Info | Toradex Developer Center)

From the error log you shared, there is this message:

You can check your environment variables using the printenv command.

Best regards,

hi dear @henrique.tx
yes of course :

root@colibri-imx6-14972705:~# tdx-info

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           6.1.33 #7 SMP Mon Dec 18 11:17:13 +0330 2023
Kernel command line:      enable_wait_mode=off galcore.contiguousSize=50331648 root=PARTUUID=8d4d91aa-02 ro rootwait fec_mac=00:14:2d:e4:77:21 consoleblank=0 no_console_suspend=1 console=tty1 console=ttymxc0,115200n8 fbmem=8M
Distro name:              NAME="TDX Wayland with XWayland Upstream"
Distro version:           VERSION_ID=6.5.0-devel-20231223074754-build.0
Distro variant:           -
Hostname:                 colibri-imx6-14972705
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Colibri iMX6DL/S on Colibri Evaluation Board V3
Toradex version:          0017 V1.1B
Serial number:            14972705
Processor arch:           armv7l
------------------------------------------------------------

and this is DISPLAY var value :

root@colibri-imx6-14972705:~# echo $DISPLAY
:0.0

Hi @me_ahani98 !

Thanks for the information.

Let’s then do some sanity checks?

I have here by my side a Verdin iMX8MP Q 4GB WB IT V1.0B on a Dahlia V1.1C running the Reference Multimedia Image (downstream) from BSP 6.4.0-build.8

root@verdin-imx8mp-06849036:/proc/764# tdx-info

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           5.15.129-6.4.0+git.67c3153d20ff #1 SMP PREEMPT Wed Sep 27 12:30:36 UTC 2023
Kernel command line:      root=PARTUUID=298bca9d-02 ro rootwait console=tty1 console=ttymxc2,115200 consoleblank=0 earlycon
Distro name:              NAME="TDX Wayland with XWayland"
Distro version:           VERSION_ID=6.4.0-build.8
Hostname:                 verdin-imx8mp-06849036
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Verdin iMX8M Plus WB on Verdin Development Board
Toradex version:          0058 V1.0B
Serial number:            06849036
Processor arch:           aarch64
------------------------------------------------------------

Although not quite the same as you, I expect the things I am asking you to check to be the same. If not, please use the latest quarterly release (6.4.0-build.8) as base for your image as nightly/monthly releases are pre-releases and perform the checks again.

  1. Check if weston is present on your system
root@verdin-imx8mp-06849036:~# file $(which weston)
/usr/bin/weston: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=425ef4225da49f007ba59b0555cfab7c59e8f10a, for GNU/Linux 3.14.0, stripped
  1. Is weston being executed?
root@verdin-imx8mp-06849036:~# ps aux | grep weston
root         764  5.5  1.2 663612 50576 tty7     Ssl+ 12:24   0:43 /usr/bin/weston --modules=systemd-notify.so
root         781  0.0  0.2  42064 11436 tty7     S+   12:24   0:00 /usr/libexec/weston-keyboard
root         782  0.1  0.5  51612 21184 tty7     S+   12:24   0:00 /usr/libexec/weston-desktop-shell
root        1062  0.0  0.0   2960  1308 pts/0    S+   12:37   0:00 grep weston
  1. Does the weston in execution has XWayland enabled?
    3.1. Let’s check the weston.ini
root@verdin-imx8mp-06849036:~# cat /etc/xdg/weston/weston.ini | grep -i xwayland
xwayland=true

3.2. Let’s check weston logs using journalctl (in my case, nothing too exciting)

root@verdin-imx8mp-06849036:~# journalctl -u weston.service
Dec 27 12:24:17 verdin-imx8mp-06849036 systemd[1]: Starting Weston, a Wayland compositor, as a system service...
Dec 27 12:24:18 verdin-imx8mp-06849036 systemd[1]: Started Weston, a Wayland compositor, as a system service.

3.3. Let’s also check the information from the /proc so we can see if weston was able to find the XWayland lib.

root@verdin-imx8mp-06849036:~# grep -niP xwayland /proc/$(pgrep -f $(which weston))/maps
160:ffffa1310000-ffffa1324000 r-xp 00000000 b3:02 10770                      /usr/lib/libweston-10/xwayland.so
161:ffffa1324000-ffffa1333000 ---p 00014000 b3:02 10770                      /usr/lib/libweston-10/xwayland.so
162:ffffa1333000-ffffa1335000 r--p 00013000 b3:02 10770                      /usr/lib/libweston-10/xwayland.so
163:ffffa1335000-ffffa1336000 rw-p 00015000 b3:02 10770                      /usr/lib/libweston-10/xwayland.so
  1. Please also share your complete printenv. Just in case :slight_smile:
root@verdin-imx8mp-06849036:~# printenv
SHELL=/bin/sh
SYSTEMD_COLORS=0
EDITOR=vi
PWD=/home/root
LOGNAME=root
HOME=/home/root
WAYLAND_DISPLAY=/run/wayland-0
SSH_CONNECTION=::ffff:192.168.10.1 46438 ::ffff:192.168.10.36 22
QT_QPA_PLATFORM=wayland-egl
TERM=screen-256color
USER=root
DISPLAY=:0.0
SHLVL=1
PS1=\u@\h:\w\$
SSH_CLIENT=::ffff:192.168.10.1 46438 22
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
SSH_TTY=/dev/pts/0
OLDPWD=/proc/764
_=/bin/printenv

Please share your outputs so we can try to understand what could be wrong.

Best regards,

I believe I have found the issue. It is due to a missing line: “xwayland=true”. After adding this line, my application is now functioning properly.
thanks for your assistance my friend

best regard
Mehdi

Hi @me_ahani98 !

Thanks for the feedback. Great to know that it worked for you :smiley:

To know more about how to configure Weston, you can refer to the Working with Weston on Torizon OS | Toradex Developer Center article. In there, you will find reference to weston.ini’s documentation with detailed information about how to customize Weston’s appearance and behavior.

Have a nice day!