Getting Started with AwesomiumSharp
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.
- Microsoft Visual Studio 2010
- Awesomium [v1.6.2] SDK
- 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.
- Open the SDK folder (it should be on your Desktop if you used default settings during installation)
- Go to wrappers\AwesomiumSharp and open the AwesomiumSharp.sln file with Visual Studio
- Right-click AwesomiumSharp in the Solution Explorer pane and click Build
- AwesomiumSharp.dll, Awesomium.dll and their dependencies should now be located in SDKFolder\wrappers\AwesomiumSharp\AwesomiumSharp\bin\Debug
- Close the AwesomiumSharp solution
Adding AwesomiumSharp to a Project
Follow the steps below, after you create a project for a .NET application:
- Right-click your project file in the Solution Explorer Pane and select Add Reference…
- Select Browse and add AwesomiumSharp.dll, it should be located in SDKFolder\wrappers\AwesomiumSharp\AwesomiumSharp\bin\Debug
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:
- Right-click your project file in the Solution Explorer Pane, click Add -> Existing Item
- Browse to SDKFolder\build\bin\release
- 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 (*.*)
- Hold down Shift and Select the following files:
- Click the drop-down button near Add and select Add As Link
- Right-click your project name, click Add -> New Folder
- Name the folder ‘locales‘
- Right-click the folder you just created, click Add -> Existing Item
- Browse to SDKFolder\build\bin\release\locales
- Select ‘en-US.dll‘
- Click the drop-down button near Add and select Add As Link (just as we did for rest of Awesomium files above)
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:
- Hold down Ctrl and Select the Awesomium files we linked to our application, in the Solution Explorer pane
- In the Properties pane, go to ‘Copy to Output Directory‘ and from the drop-down list select: ‘Copy if newer‘
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.
- 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.
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).