OSx mono gtk hello world. An exception was made for Gtk.Container

An attempt to use hello world examples in Mono after a new installation. Tried an example of GTK, as stated in [ http://www.mono-project.com/docs/getting-started/mono-basics/†[1] :

mcs hello.cs -pkg:gtk-sharp-2.0
mono hello.exe

and I get the following:

> 2014-11-21 21:45:29.629 mono[45107:1731007] *** WARNING: Method
> userSpaceScaleFactor in class NSView is deprecated on 10.7 and later.
> It should not be used in new applications. Use convertRectToBacking:
> instead. 
> 
> Unhandled Exception: System.TypeInitializationException: An exception
> was thrown by the type initializer for Gtk.Container --->
> System.DllNotFoundException: gtksharpglue-2   at (wrapper
> managed-to-native)
> Gtk.Container:gtksharp_gtk_container_get_focus_child_offset ()   at
> Gtk.Container..cctor () [0x00000] in <filename unknown>:0    --- End
> of inner exception stack trace ---   at Gtk.Bin..ctor (IntPtr raw)
> [0x00000] in <filename unknown>:0    at Gtk.Window..ctor (WindowType
> type) [0x00000] in <filename unknown>:0    at Gtk.Window..ctor
> (System.String title) [0x00000] in <filename unknown>:0    at
> Hello.Main () [0x00000] in <filename unknown>:0  [ERROR] FATAL
> UNHANDLED EXCEPTION: System.TypeInitializationException: An exception
> was thrown by the type initializer for Gtk.Container --->
> System.DllNotFoundException: gtksharpglue-2   at (wrapper
> managed-to-native)
> Gtk.Container:gtksharp_gtk_container_get_focus_child_offset ()   at
> Gtk.Container..cctor () [0x00000] in <filename unknown>:0    --- End
> of inner exception stack trace ---   at Gtk.Bin..ctor (IntPtr raw)
> [0x00000] in <filename unknown>:0
>    at Gtk.Window..ctor (WindowType type) [0x00000] in <filename
> unknown>:0 
>       at Gtk.Window..ctor (System.String title) [0x00000] in <filename unknown>:0 
>       at Hello.Main () [0x00000] in <filename unknown>:0

Any idea what causes it?

+4
source share
3 answers

Jonathan Prior answered very well on the Xamarin forum . These bits from his answer helped me:

You are not exporting $ DYLD_LIBRARY_PATH or $ DYLD_FALLBACK_LIBRARY_PATH so that it can be found.

...

, libgtk-quartz-2.0.0.dylib , /Library/Frameworks/Mono.framework/Libraries, /usr/lib ( - ).

, mono hello.exe :

export DYLD_FALLBACK_LIBRARY_PATH=/Library/Frameworks/Mono.framework/Versions/Current/lib:/lib:/usr/lib
0

,

"userSpaceScaleFactor NSView 10.7

GTK. GTK , Apple .

Apple Dev re userSpaceScaleFactor

A script, . chmod + x.

#!/bin/zsh
export DYLD_FALLBACK_LIBRARY_PATH=/Library/Frameworks/Mono.framework/Versions/Current/lib:/lib:/usr/lib

mono $1.exe
0

Ubuntu16/CentOS7: System.DllNotFoundException: gtksharpglue-2

GTK # Xamarin.Forms GTK Linux. , . https://docs.microsoft.com/en-us/xamarin/xamarin-forms/platform/other/gtk?tabs=windows

GTK VS-2017 Win, GTK Project Win . GTK, Linux-Ubuntu16, .

spsuser @ubuntusrv: ~/ /Boxview/ $ sudo mono BasicBoxView.GTK.exe

: System.TypeInitializationException: 'Gtk.Container' . ---> System.DllNotFoundException: gtksharpglue-2 at ( ) Gtk.Container.gtksharp_gtk_container_get_focus_child_offset() Gtk.Container..cctor() [0x00000] <94f79862491ff0b0b5b0: --- Gtk.Bin..ctor(System.IntPtr raw) [0x00000] <94f79862491c46b0bf711bc40f7608a5>: 0 Gtk.Window..ctor ( Gtk.WindowType) [0x00000] <94f798640f7b6b8b8646b6647b660 0 Xamarin.Forms.Platform.GTK.FormsWindow..ctor() [0x00000] <4bad12fcff0f409181b1aa48e034f579>: 0 BasicBoxView.GTK.Program.Main(System.String [] args) [0x00014a0a0a9aa0a0a] 0a0a0aa0aa0a0a0eaaaaaaaaaaaaaaaaaaaaaaaaaaa_aa.aa0a0a0a0e0a0e0a0a0a0a0a0a0a0a0b0d0d0b0d0b0b0b0b0b0b5d2d0b2c5c0b2b2c5c5c0b1b2c0b1dc0b0b1d1d0b0d1d0b1c. 0d. 0x2.a0. 0a. 0a. 0. [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: 'Gtk.Container' . ---> System.DllNotFoundException: gtksharpglue-2 at ( ) Gtk.Container.gtksharp_gtk_container_get_focus_child_offset() Gtk.Container..cctor() [0x00000] <94f79862491ff0b0b5b0: --- Gtk.Bin..ctor(System.IntPtr raw) [0x00000] <94f79862491c46b0bf711bc40f7608a5>: 0 Gtk.Window..ctor ( Gtk.WindowType) [0x00000] <94f798640f7b6b8b8646b6647b660 0 Xamarin.Forms.Platform.GTK.FormsWindow..ctor() [0x00000] <4bad12fcff0f409181b1aa48e034f579>: 0 BasicBoxView.GTK.Program.Main(System.String [] args) [0x00014a0a0a9aa0a0a] 0a0a0aa0aa0a0a0eaaaaaaaaaaaaaaaaaaaaaaaaaaa_aa.aa0a0a0a0e0a0e0a0a0a0a0a0a0a0a0b0d0d0b0d0b0b0b0b0b0b5d2d0b2c5c0b2b2c5c5c0b1b2c0b1dc0b0b1d1d0b0d1d0b1c. 0d. 0x2.a0. 0a. 0a. 0. spsuser @ubuntusrv: ~/Desktop/Boxview/Debug $

$ sudo find /usr/ -name  libgtksharpglue-2*
[sudo] password for spsuser: 
/usr/lib/cli/gtk-sharp-2.0/libgtksharpglue-2.so
/usr/lib/x86_64-linux-gnu/libgtksharpglue-2.so
/usr/bin/lib/libgtksharpglue-2.so
/usr/bin/lib/libgtksharpglue-2.la

/usr/bin/lib/libgtksharpglue-2.a

DLL /etc/mono/config.

PATH gtk-sharp-2.0.

spsuser @ubuntusrv: ~/ /Boxview/ $ echo $ PATH/home/spsuser/bin: /home/spsuser/.local/bin: /usr/local/sbin: /usr/local/bin: /usr/sbin : /USR/: /SBIN:/: /USR/: /USR//://: /usr/lib/cli/gtk-sharp-2.0/: /USR/ /Lib

, . , . Win. Ubuntu, .

https://github.com/jsuarezruiz/xamarin-forms-gtk-samples - Xamarin.Forms, Win, Linux. , , , .

0
source

All Articles