Getting Started with AwesomiumSharp

Introduction

In this tutorial, we’ll show you how to get started using AwesomiumSharp, our official open-source .NET wrapper of Awesomium. The tutorial includes the steps you will need to take before you build any .NET application that uses Awesomium.

Checklist

Building AwesomiumSharp

  1. Install the Awesomium [v1.6.2] SDK using the default settings (should create a new folder on your Desktop). Skip this step if you have already installed the SDK.
  2. Open the SDK folder (it should be on your Desktop if you used default settings during installation)
  3. Go to wrappers\AwesomiumSharp and open the AwesomiumSharp.sln file with Visual Studio
  4. Right-click AwesomiumSharp in the Solution Explorer pane and click Build

    Building AwesomiumSharp

    Building AwesomiumSharp

  5. AwesomiumSharp.dll, Awesomium.dll and their dependencies should now be located in SDKFolder\wrappers\AwesomiumSharp\AwesomiumSharp\bin\Debug
  6. Close the AwesomiumSharp solution

Adding AwesomiumSharp to a Project

Follow the steps below, after you create a project for a .NET application:

  1. Right-click your project file in the Solution Explorer Pane and select Add Reference…
  2. Select Browse and add AwesomiumSharp.dll, it should be located in SDKFolder\wrappers\AwesomiumSharp\AwesomiumSharp\bin\Debug

    Adding Reference to AwesomiumSharp

    Adding Reference to AwesomiumSharp

Adding Awesomium files to a Project

In order to debug and deploy our application, we need to make sure that the necessary Awesomium executables and resources are deployed with our application. We can do this by copying the files in a Post-Build Event, but we prefer a better method that you can consider a prerequisite step before debugging and deploying any .NET application using Awesomium and AwesomiumSharp:

  1. Right-click your project file in the Solution Explorer Pane, click Add -> Existing Item
  2. Browse to SDKFolder\build\bin\release
  3. You probably can’t see any DLL files, so make sure to click the drop-down box next to the File Name textbox, and select All Files (*.*)
  4. Hold down Shift and Select the following files:
    • Awesomium.dll
    • AwesomiumProcess.exe
    • icudt42.dll
  5. Click the drop-down button near Add and select Add As Link

    Adding Awesomium files to the project as Link

    Adding Awesomium files to the project as Link

  6. Right-click your project name, click Add -> New Folder
  7. Name the folder ‘locales
  8. Right-click the folder you just created, click Add -> Existing Item
  9. Browse to SDKFolder\build\bin\release\locales
  10. Select ‘en-US.dll
  11. Click the drop-down button near Add and select Add As Link (just as we did for rest of Awesomium files above)
Setting 'Copy to Output Directory' for Awesomium files

Setting 'Copy to Output Directory' for Awesomium files

 

 

Before we continue, we have one more step: We need to tell Visual Studio to copy the Awesomium files we just added, to the Output Directory of our project. To do this, follow the steps below:

 

  1. Hold down Ctrl and Select the Awesomium files we linked to our application, in the Solution Explorer pane
  2. In the Properties pane, go to ‘Copy to Output Directory‘ and from the drop-down list select: ‘Copy if newer

 

 
Now, when you publish your application, all the correct dependencies will be copied along with your executable.

Setting Target CPU

Ever heard of BadImageFormatException? Awesomium is based on Chromium that has not yet been ported to 64-bit on Windows. Before we start struggling to find out what causes this exception, let’s go through this last, simple step and set the Platform target property of our project to x86 (instead of x64 or AnyCPU).

  • For a C# project, open your project’s properties and in the Build tab, set Platform target to x86.
    Target CPU C#

    Setting Target CPU for a C# project.

  • For a VB project, open your project’s properties and in the Compile tab, hit the Advanced Compile Options at the bottom. This will launch the Advanced Compiler Settings dialog. Set Target CPU to x86.
    Target CPU VB

    Setting Target CPU for a VB project.

And voila, you’re done! You are now ready to compile and run your application. Just add some code; you’ll be surprised to know how easy this is. You can start with a simple application to capture web-pages.

If you have any problems, let us know by posting your issue at our Support forums (see below).

Useful Resources

Also read...

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>