VS Windows 2022 17.1.
I have an xamarin app that runs on Android, iOS, macOS and UWP.
Now I added a GTK project following this description
I want to create a self-contained bundle. To do that I run
mkbundle TimeDateCalculator.gtk.exe --simple -o timedatecalculator --cross mono-6.6.0-ubuntu-18
on windows or
mkbundle -o timedatecalculator --simple TimeDateCalculator.gtk.exe --config /etc/mono/config --machine-config /etc/mono/4.5/machine.config
in wslg.
That results in this:
ERROR: Unable to load assembly `netstandard' referenced by `/mnt/d/Users/eigil/projects/xamarinProjs/TimeDateCalculator/TimeDateCalculator/TimeDateCalculator.gtk/bin/Release/TimeDateCalculatorDll.dll'
To try to solve that I added
<Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<Private>True</Private>
</Reference>
to the .gtk.csproj file.
Now mkbundle TimeDateCalculator.gtk.exe --simple -o timedatecalculator --cross mono-6.6.0-ubuntu-18
gives Generated timedatecalculator
!
BUT when I run the bundled app in wslg (ubuntu 21.10) this is the result:
Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.
File name: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.
File name: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
How do I solve that problem ? I tried to change the gtk project Target framework from .NET Framework 4.8
to .NET Framework 4.7
but then I get this
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'Gtk.Container' threw an exception. ---> System.DllNotFoundException: gtksharpglue-2 assembly:<unknown assembly> type:<unknown type> member:(null)
at (wrapper managed-to-native) Gtk.Container.gtksharp_gtk_container_get_focus_child_offset()
at Gtk.Container..cctor () [0x00000] in <35293b6aa2744433b0e2f41f34e699d5>:0
--- End of inner exception stack trace ---
at Gtk.Bin..ctor (System.IntPtr raw) [0x00000] in <35293b6aa2744433b0e2f41f34e699d5>:0
at Gtk.Window..ctor (Gtk.WindowType type) [0x00000] in <35293b6aa2744433b0e2f41f34e699d5>:0
at Xamarin.Forms.Platform.GTK.FormsWindow..ctor () [0x00000] in <71d70d813d7b4bdea41b4cca10cb7120>:0
at TimeDateCalculator.GTK.MainClass.Main (System.String[] args) [0x00011] in <856f5c6c1d224ab1a01e487cfe143ff6>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'Gtk.Container' threw an exception. ---> System.DllNotFoundException: gtksharpglue-2 assembly:<unknown assembly> type:<unknown type> member:(null)
at (wrapper managed-to-native) Gtk.Container.gtksharp_gtk_container_get_focus_child_offset()
at Gtk.Container..cctor () [0x00000] in <35293b6aa2744433b0e2f41f34e699d5>:0
--- End of inner exception stack trace ---
at Gtk.Bin..ctor (System.IntPtr raw) [0x00000] in <35293b6aa2744433b0e2f41f34e699d5>:0
at Gtk.Window..ctor (Gtk.WindowType type) [0x00000] in <35293b6aa2744433b0e2f41f34e699d5>:0
at Xamarin.Forms.Platform.GTK.FormsWindow..ctor () [0x00000] in <71d70d813d7b4bdea41b4cca10cb7120>:0
at TimeDateCalculator.GTK.MainClass.Main (System.String[] args) [0x00011] in <856f5c6c1d224ab1a01e487cfe143ff6>:0