How to get the Chromium WebBrowser working with VS2010

Sep 10, 2010 at 8:49 PM

Hey, 

I had a hell of a time getting this going and working correctly, so i'll post how I did it.

 

The first step was I downloaded the source from the downloads page http://wpfchromium.codeplex.com/releases/view/49484 (Cjc.ChromiumBrowserDemo (.NET 4.0))

The second step is to download Awesomium 1.6 BETA B SDK from http://www.khrona.com/products/awesomium/download/ (it's located under experimental builds)

The third step is to change around the directory structure, because the VS2010 solution file expects Cjc.AwesomiumWrapper to be in a different location, and you would also get the error "Cannot open include file: 'WebCore.h': No such file or directory", to fix this without changing around where the solution expects files to be, I used the following directory layout structure.

You could change the path of where the solution expects it be, but i just changed my directory layout structure to this. (Extract the Awesomium files you downloaded into the Awesomium directory)

 

Chromium WebBrowser WPF\

      Cjc.WPFChromium.3.5\

            Cjc.AwesomiumWrapper\

            Awesomium\

                   bin\

                   include\

                   ...

      Cjc.WPFChromium.4.0\

            Cjc.ChromiumBrowser\

            Cjc.ChromiumBrowserDemo\

            Cjc.Websnapshot\

            Cjc.WPFChromium.4.0.sln

 

Now you should be able to open the solution fine and all the projects should load.  You can try compiling, although the next error I received was "error RC1106: invalid option: -ologo".  To fix this one, simply right click on the Cjc.AwesomiumWrapper, go to Properties -> Configuration Properties -> Resources, and change "Suppress Startup Banner" to "No".  Then go to Configuration Properties -> Linker, and change the same option "Suppress Startup Banner" to "No".

 

You can try compiling again, but the compiler will tell you that xcopy failed to copy the files from the Awesomium to the Cjc.ChromiumBrowserDemo output directory because our file structure is a bit different than what it expected, to fix this (assuming you're using the above directory structure exactly), right click on the Cjc.ChromiumBrowserDemo project, go to Properties -> Build Events, then change the "Post-build event command line:" to this string

xcopy "$(SolutionDir)..\Cjc.WPFChromium.3.5\Awesomium\bin\$(ConfigurationName)\*" "$(TargetDir)" /s /r /y

then do the same for the Cjc.WebSnapShot project (properties -> build events, change post build event command line to the above string)

 

If all goes well the solution should now build perfectly

 

If you want to add this WebBrowser control to your own project, the steps i took to get this working was...create a new solution. 

1. Create a new WPF Application

2. Add references to both Cjc.AwesomiumWrapper.dll, and Cjc.ChromiumBrowser.dll

3. In order to get my new project to work, I had to change the target framework from ".NET Framework 4 Client Framework", to ".NET Framework 4" (i don't know if there's a different work around for this, but this is how i got it to work)

4. Add an app.config file to your project and add the following inbetween the <configuration> tags

  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    <requiredRuntime version="v4.0.20506"/>
  </startup>

5. Now you need to copy the contents of Awesomium\bin\debug (or release, whatever configuration mode you are running) to your target directory, you can simply use windows and copy and paste these files, or you can use a Post-Build event and utilize the xcopy command to automatically copy the contents on each build (like above, but you might have to modify the xcopy command text depending on where your projects are located).  

6.  Your app should compile and run fine and display your new wpf browser control, I couldn't get the designer to work, but everything executes fine

 

Again, this is probably not the best or most optimal way of getting it to work, but this is the way I did it...and I thought i'd help others out if anyone out there is struggling (maybe i'm the only one that's bad at this kinda stuff ha!).  Also if I ever have to do this again I can look at this and see how the hell i got it to work right ;-)

 

-Kyle

 

 

 

 

 

Sep 10, 2010 at 10:18 PM

to fix the designer you can add the Cjc.AwesomiumWrapper.dll and the Cjc.ChromiumBrowser.dll paths to your environment variables (or drop them in the system32 folder or something similar)

Sep 11, 2010 at 8:12 PM

Thanks a lot for this, Kyle! :-) Exactly the pointers I needed after downloading the .NET 4.0 version today, and getting frustrated about it not building in my project right away. 

Sep 25, 2010 at 8:26 PM

Thanks kylegobel for the guidance to loading the solution.

I've attempted the same using steps with the

Awesomium v1.6 RC1 SDK Windows; MSVC9

and experienced a few exceptions and unclear how to overcome these.

 

Error 4 error C2661: 'Awesomium::WebCore::WebCore' : no overloaded function takes 6 arguments 
c:\users\developer\documents\cjc.wpfchromium.3.5\cjc.awesomiumwrapper\awesomium\Cjc.AwesomiumWrapper.h 878 
1 Cjc.AwesomiumWrapper

Error 3 error C2039: 'zoomOut' : is not a member of 'Awesomium::WebView' 
c:\users\developer\documents\cjc.wpfchromium.3.5\cjc.awesomiumwrapper\awesomium\Cjc.AwesomiumWrapper.h 818 
1 Cjc.AwesomiumWrapper


Error 2 error C2039: 'zoomIn' : is not a member of 'Awesomium::WebView' 
c:\users\developer\documents\cjc.wpfchromium.3.5\cjc.awesomiumwrapper\awesomium\Cjc.AwesomiumWrapper.h 816 
1 Cjc.AwesomiumWrapper

 

Any suggestions are appreciated.

Sep 25, 2010 at 8:45 PM
Edited Sep 25, 2010 at 8:48 PM

Yeah there were a couple changes from Awesomium 1.6 Beta 2 to Awesomium 1.6 RC1.

 

Here is a good thread by Sleepyhead on how to change the Cjc.AwesomiumWrapper project to make it work.

http://wpfchromium.codeplex.com/Thread/View.aspx?ThreadId=227902

 

I believe Chris is working on a new build that is updated to use Awesomium 1.6 RC1, and hopefully that will be released in the near future.

 

 

Sep 25, 2010 at 11:21 PM

Thanks for the reply and the link. 

 

I've followed Sleepyhead's suggests -the  deletion of both zoomOut and zoomIn  and adding the SetZoom.  Also, I've used the modification to the constructor  and it gets the build closer with an exception

Error 2 error LNK1181: cannot open input file 'Awesomium_d.lib' 
C:\Users\developer\Documents\Cjc.WPFChromium.3.5\Cjc.AwesomiumWrapper\Awesomium\LINK 

Cjc.AwesomiumWrapper

 

 

Sep 27, 2010 at 7:50 PM

If you look at Awesomium 1.6 RC1, you'll see the directory structure is a bit different, you'll have to change the paths for where the Cjc.AwesomiumWrapper expects Awesomium to be.