Using Gecko.WebControl on Mono

I’ve tried to use gecko.WebControl on Mono under Ubuntu Linux and I kept on getting:

Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for Gecko.WebControl ---> System.DllNotFoundException: /usr/lib/firefox/libgtkembedmoz.so
  at (wrapper managed-to-native) Gecko.WebControl:gtk_moz_embed_get_type ()
  at Gecko.WebControl.get_GType () [0x00000]
  at GtkSharp.GeckoSharp.ObjectManager.Initialize () [0x00000]
  at Gecko.WebControl..cctor () [0x00000] --- End of inner exception stack trace ---
  at <0x00000> 
  at SecondMessenger.gtk.MainWnd.initAdvertising () [0×00000]
  at SecondMessenger.gtk.MainWnd..ctor (SecondMessenger.SMClient client) [0×00000]
  at SecondMessenger.gtk.GTKClient.initUI () [0×00000]
  at SecondMessenger.SMClientManager.NewClient (System.String clientType) [0×00000]
  at SecondMessenger.SMClientManager..ctor (System.String clientType, System.Collections.Generic.List`1 accounts, System.Stringc) [0×00000]
  at SecondMessenger.Program.Esegui (System.String[] args) [0×00000]
  at SecondMessenger.Program.Main (System.String[] args) [0×00000]

That’s why even if the /usr/lib/firefox/libgtkembedmoz.so library is there is not visible to the LD_PATH.

So I’ve tryed different solutions and i wrote this shell script:

if test -n "$MOZILLA_FIVE_HOME"; then
    MOZILLA_HOME=$MOZILLA_FIVE_HOME
elif test x/usr/lib/firefox != x; then
    if [ -f /usr/lib/firefox/chrome/comm.jar ]; then
            MOZILLA_FIVE_HOME=/usr/lib/firefox
            MOZILLA_HOME=$MOZILLA_FIVE_HOME
    fi
elif [ $(which xulrunner 2> /dev/null) ] > /dev/null ; then
        MOZILLA_FIVE_HOME=`getdirectory xulrunner`
        MOZILLA_HOME=$MOZILLA_FIVE_HOME
elif [ $(which mozilla 2> /dev/null) ] && grep MOZILLA_FIVE_HOME= "$(which mozilla)" > /dev/null ; then
        MOZILLA_FIVE_HOME=$(grep MOZILLA_FIVE_HOME= $(which mozilla) | cut -d '"' -f 2)
        MOZILLA_HOME=$MOZILLA_FIVE_HOME
elif [ $(which firefox 2> /dev/null) ] && grep MOZILLA_FIVE_HOME= "$(which firefox)" > /dev/null ; then
        MOZILLA_FIVE_HOME=$(grep MOZILLA_FIVE_HOME= $(which firefox) | cut -d '"' -f 2)
        MOZILLA_HOME=$MOZILLA_FIVE_HOME
fi

if [ -n $LD_LIBRARY_PATH ]; then
        export LD_LIBRARY_PATH=$MOZILLA_HOME:$LD_LIBRARY_PATH
else
        export LD_LIBRARY_PATH=$MOZILLA_HOME
fi
export MOZILLA_FIVE_HOME
export MOZILLA_HOME
export LD_LIBRARY_PATH

exec /usr/bin/mono --debug ./SecondMessenger.exe "$@"

The last line execute my program (SecondMessenger.exe) and you can change it with your program name.

Unfortunately this solution doesn’t work under Mac OSX :-( if you have any suggestion send it to me.

Enjoy,
Roberto.

Tags: , ,

One Response to “Using Gecko.WebControl on Mono”

  1. pkdaly Says:

    Hi Roberto,

    Thanks for the script. I modified it slightly so that it can fall-back on the seamonkey package. In my case, I run OpenSUSE 10.3 and the latest firefox packages don’t include libgtkembedmoz.so.

    Here’s what I have:


    if test -n "$MOZILLA_FIVE_HOME"; then
    MOZILLA_HOME=$MOZILLA_FIVE_HOME
    elif test x/usr/lib/firefox != x; then
    if [ -f /usr/lib/firefox/chrome/comm.jar ]; then
    if [ -f /usr/lib/firefox/libgtkembedmoz.so ]; then
    MOZILLA_FIVE_HOME=/usr/lib/firefox
    MOZILLA_HOME=$MOZILLA_FIVE_HOME
    elif [ -f /usr/lib/seamonkey/chrome/comm.jar ]; then
    if [ -f /usr/lib/seamonkey/libgtkembedmoz.so ]; then
    MOZILLA_FIVE_HOME=/usr/lib/seamonkey
    MOZILLA_HOME=$MOZILLA_FIVE_HOME
    fi
    fi
    fi
    elif [ $(which xulrunner 2> /dev/null) ] > /dev/null ; then
    MOZILLA_FIVE_HOME=`getdirectory xulrunner`
    MOZILLA_HOME=$MOZILLA_FIVE_HOME
    elif [ $(which mozilla 2> /dev/null) ] && grep MOZILLA_FIVE_HOME= "$(which mozilla)" > /dev/null ; then
    MOZILLA_FIVE_HOME=$(grep MOZILLA_FIVE_HOME= $(which mozilla) | cut -d '"' -f 2)
    MOZILLA_HOME=$MOZILLA_FIVE_HOME
    elif [ $(which firefox 2> /dev/null) ] && grep MOZILLA_FIVE_HOME= "$(which firefox)" > /dev/null ; then
    MOZILLA_FIVE_HOME=$(grep MOZILLA_FIVE_HOME= $(which firefox) | cut -d '"' -f 2)
    MOZILLA_HOME=$MOZILLA_FIVE_HOME
    elif [ $(which seamonkey 2> /dev/null) ] && grep MOZILLA_FIVE_HOME= "$(which seamonkey)" > /dev/null ; then
    MOZILLA_FIVE_HOME=$(grep MOZILLA_FIVE_HOME= $(which seamonkey) | cut -d '"' -f 2)
    MOZILLA_HOME=$MOZILLA_FIVE_HOME
    fi

    if [ -n $LD_LIBRARY_PATH ]; then
    export LD_LIBRARY_PATH=$MOZILLA_HOME:$LD_LIBRARY_PATH
    else
    export LD_LIBRARY_PATH=$MOZILLA_HOME
    fi
    export MOZILLA_FIVE_HOME
    export MOZILLA_HOME
    export LD_LIBRARY_PATH

    pwd

    exec /usr/bin/mono --debug ./SecondMessenger.exe "$@"

Leave a Reply

You must be logged in to post a comment.


 
Roberto Rocco Angeloni is proudly powered by WordPress
Entries (RSS) and Comments (RSS).