Xamarin GTK on Linux: "DllNotFoundException: libglib-2.0-0.dll "

Viewed 426

I am trying to run a Xamarin test application on a fresh install of Ubuntu 20.04.2

On a windows 10 machine, I am cloning this repo:

https://github.com/jsuarezruiz/xamarin-forms-gtk-movies-sample

Compile it in Visual Studio 2019, it runs perfectly on android and windows GTK

Then I copy the contents of bin/Debug folder to my Linux machine and try running it with mono, it throws an exception:

Unhandled Exception:
System.DllNotFoundException: libglib-2.0-0.dll assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) GLib.Marshaller.g_utf16_to_utf8(char*,intptr,intptr,intptr,intptr&)
  at GLib.Marshaller.StringToPtrGStrdup (System.String str) [0x00034] in <d973ca9f8b494b789fba7fe0ad040b14>:0 
  at GLib.Global.set_ProgramName (System.String value) [0x00001] in <d973ca9f8b494b789fba7fe0ad040b14>:0 
  at Gtk.Application.SetPrgname () [0x0000d] in <35293b6aa2744433b0e2f41f34e699d5>:0 
  at Gtk.Application.Init () [0x00001] in <35293b6aa2744433b0e2f41f34e699d5>:0 
  at Movies.GTK.Program.Main (System.String[] args) [0x00043] in <87211febe55c459f869a2b0842e037c3>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: libglib-2.0-0.dll assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) GLib.Marshaller.g_utf16_to_utf8(char*,intptr,intptr,intptr,intptr&)
  at GLib.Marshaller.StringToPtrGStrdup (System.String str) [0x00034] in <d973ca9f8b494b789fba7fe0ad040b14>:0 
  at GLib.Global.set_ProgramName (System.String value) [0x00001] in <d973ca9f8b494b789fba7fe0ad040b14>:0 
  at Gtk.Application.SetPrgname () [0x0000d] in <35293b6aa2744433b0e2f41f34e699d5>:0 
  at Gtk.Application.Init () [0x00001] in <35293b6aa2744433b0e2f41f34e699d5>:0 
  at Movies.GTK.Program.Main (System.String[] args) [0x00043] in <87211febe55c459f869a2b0842e037c3>:0 

Obviously missing a "libglib-2.0-0.dll", which I am not sure how to install on Linux and where mono searches for it. So far I tried installing mono-devel, mono-complete, gtk-sharp2, libglib2.0-dev

1 Answers

After searching through mono logs I noticed that it's trying to access windows-specific dlls, so I tried setting library reference parameter "Copy Local" to false on these libraries:

  • atk-sharp
  • gdk-sharp
  • glade-sharp
  • glib-sharp
  • gtk-dotnet
  • gtk-sharp
  • pango-sharp

And it worked on ubuntu 18.04.3 LTS

Related