Michael K
Michael K

Reputation: 21

Getting Awesomium to run on mono under linux

I'm attempting to get a program developed in C# that uses awesomium (console only) running on linux(mono).

I've downloaded and installed the latest Awesomium SDK 1.7.5.

# ldconfig -p | grep libawe
libawesomium-1-7.so.5 (libc6,x86-64) => /usr/lib/libawesomium-1-7.so.5

Inside my solution I've included the reference to Awesomium.Mono.dll. Inside the Awesomium.Mono.dll.config file I've done a dllmap to retarget for the linux OS.. maybe this isn't required?

<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<!-- Fix the target below to target the Awesomium native library -->
<dllmap dll="awesomium" target="libawesomium-1-7.so.5" os="linux"/>
<dllmap dll="awesomium" target="@executable_path/../Frameworks/Awesomium.framework/Versions/A/Awesomium" os="osx"/>
</configuration>

I'm currently receiving an error stating the dll cannot be found

Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for Awesomium.Core.WebCore ---> System.TypeInitializationException: An exception was thrown by the type initializer for Awesomium.Core.NativeMethods ---> System.TypeInitializationException: An exception was thrown by the type initializer for AweExceptionHelper ---> System.DllNotFoundException: libawesomium-1-7.so.5
  at (wrapper managed-to-native) Awesomium.Core.NativeMethods/AweExceptionHelper:RegisterExceptionCallbacks_awesomium (Awesomium.Core.NativeMethods/AweExceptionHelper/ExceptionDelegate,Awesomium.Core.NativeMethods/AweExceptionHelper/ExceptionDelegate,Awesomium.Core.NativeMethods/AweExceptionHelper/ExceptionDelegate,Awesomium.Core.NativeMethods/AweExceptionHelper/ExceptionDelegate,Awesomium.Core.NativeMethods/AweExceptionHelper/ExceptionDelegate,Awesomium.Core.NativeMethods/AweExceptionHelper/ExceptionDelegate,Awesomium.Core.NativeMethods/AweExceptionHelper/ExceptionDelegate,Awesomium.Core.NativeMethods/AweExceptionHelper/ExceptionDelegate,Awesomium.Core.NativeMethods/AweExceptionHelper/ExceptionDelegate,Awesomium.Core.NativeMethods/AweExceptionHelper/ExceptionDelegate,Awesomium.Core.NativeMethods/AweExceptionHelper/ExceptionDelegate)

Any advice?

Upvotes: 2

Views: 1446

Answers (1)

Jim
Jim

Reputation: 11

This is how I got Awesomium to work in Mono on Linux:

  1. Download and install (on Windows) the Awesomium SDK for Windows (awesomium_1_7_5_1_sdk_win).

  2. Find Awesomium.Mono.dll (for me C:\Program Files\Awesomium Technologies LLC\Awesomium SDK\1.7.5.1\wrappers\Awesomium.NET\Assemblies), copy to Linux and reference in your Mono project, making sure Local Copy is checked.

  3. Download the Awesomium SDK for Linux (awesomium_1_7_5_sdk_linux64) and extract.

  4. Copy the contents of bin to the operating directory of your project (e.g. bin/Debug).

  5. Rename libawesomium-1-7.so.5.0 to libawesomium-1-7.so.0.0.

Example code (typos fixed from documentation):

using System;
using Awesomium.Core;

class MainClass
{
    public static void Main (string[] args)
    {
        using (var webView = WebCore.CreateWebView( 800, 600 ) )
        {
            webView.Source = new Uri( "http://www.google.com" );

            webView.LoadingFrameComplete += ( s, e ) =>
            {
                if (!e.IsMainFrame)
                    return;

                BitmapSurface surface = (BitmapSurface)webView.Surface;
                surface.SaveToPNG ("result.png", true);

                WebCore.Shutdown ();
            };
        }

        WebCore.Run();
    }
}

Upvotes: 1

Related Questions