Xamarin.forms: [Bug] Xamain.GTK on Raspberrian does not work

Created on 17 Mar 2020  ·  6Comments  ·  Source: xamarin/Xamarin.Forms

Description

Loading a Xamarin,Forms application on Raspberrian where mono and gtk2 has been installed generates unexpected errors.

Steps to Reproduce

  1. Create a Xamarin forms application with GTK support.
  2. In total NuGet references are setup as follows:
    image
  3. Build and copy output folder to Raspberry PI 2 using Raspberrian OS.
  4. Run on Raspberry PI using mono

Expected Behavior

Application runs!

Actual Behavior

Application does not run.
At first dllmaps needs to be added and the following has been added to /etc/mono/conf:

<configuration> 
    <dllmap dll="libglib-2.0-0.dll" target="libglib-2.0.so.0" os="linux"/> 
    <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so.0" os="linux"/> 
    <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.so.0" os="linux"/> 
    <dllmap dll="gtksharpglue-2" target="/usr/lib/cli/glib-sharp-2.0/libglibsharpglue-2.so" os="linux"/> 

Still the following happens:

Unhandled Exception:

System.TypeInitializationException: The type initializer for 'Gtk.Container' threw an exception. ---> System.EntryPointNotFoundException: gtksharp_gtk_container_get_focus_child_offset

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 () [0x

gtk needs-info ❓ needs-repro ❔ unverified bug

All 6 comments

Awesome trying Forms on a Raspberry Pi @JensNordenbro!

Did you see this FAQ? It says that you need to have GTK# 2.12, are you sure you are using that? It seems some kind of version mismatch somewhere

@jfversluis ; I will try this tomorrow!

"Add / Remove Software" says "GTK# 2.10 suite, CLI bindings for GTK+" is installed. It says that this is the gtk-sharp2-2.12.40-2 version. I do not have GTK# 3.0 installed so it should not be in conflict.

Adding what follows to the section in /etc/mono/config made it work in the end.

<dllmap dll="libglib-2.0-0.dll" target="libglib-2.0.so.0" os="linux"/> 
<dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so.0" os="linux"/> 
<dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.so.0" os="linux"/> 
<dllmap dll="gtksharpglue-2" target="/usr/lib/cli/gtk-sharp-2.0/libgtksharpglue-2.so" os="!windows"/> 
<dllmap dll="glibsharpglue-2" target="/usr/lib/cli/glib-sharp-2.0/libglibsharpglue-2.so" os="!windows"/>   
<dllmap dll="libpango-1.0-0.dll" target="libpango-1.0.so" os="!windows"/> 
<dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-x11-2.0.so" os="!windows"/> 
<dllmap dll="libatk-1.0-0.dll" target="libatk-1.0.so" os="!windows"/> 
<dllmap dll="pangosharpglue-2" target="/usr/lib/cli/pango-sharp-2.0/libpangosharpglue-2.so" os="!windows"/> 
<dllmap dll="gdksharpglue-2" target="/usr/lib/cli/gdk-sharp-2.0/libgdksharpglue-2.so" os="!windows"/> 
<dllmap dll="libgdk_pixbuf-2.0-0.dll" target="libgdk_pixbuf-2.0.so" os="!windows"/> 

@jfversluis , why do I need to do this? All these assemblies seems to be centered around the GTK, Xamarin, Mono entourage. I understand technically why but it just seems that this should not be necessary.
Am I building this in some strange ways? (Others have hade the same problem!)

I'm not that familiar with our GTK backend, maybe @jsuarezruiz has an idea?

Glad you got it to work though!

This type of question is best asked on a question and answer site, like the Forums or StackOverflow. Thanks!

Was this page helpful?
0 / 5 - 0 ratings