A Real WPF 4.0 WebBrowser

UPDATE 2: There’s an updated version of the demo based on Awesomium’s own .NET wrapper; read more here.

UPDATE: Be sure to check out the .NET wrapper now included with Awesomium!

I’ve updated my WPF Chromium WebBrowser for .NET 4.0 and Awesomium 1.6 RC1.  You can find the source code here on CodePlex.

Cjc.ChromiumBrowserDemo adds a couple of new features:

  • Zoom in / out buttons.
  • “Console” checkbox – Shows a console allowing you to execute arbitrary javascript on the page.

image

It currently has a few known issues:

  • Resizing the page (either directly or while rotating) can cause some flicker.  This should be improved by an upcoming Awesomium tweak.
  • Some javascript can cause the console to “die” and ignore subsequent statements.  Don’t use “document” or “window” on their own.  However it appears safe to use things like this:

    document.getElementById( ‘myElement’ ).style.background = ‘red’

To build the solution, make sure you also download Awesomium 1.6 RC1 (direct link) and place it in an Awesomium folder below the root.  Your folders should look something like this:

Cjc.WpfChromium.4.0
— Awesomium
—- build
—- docs
—- include
—- samples
— Cjc.AwesomiumWrapper
— Cjc.ChromiumBrowser
— Cjc.ChromiumBrowserDemo
— Cjc.WebSnapshot (optional)

I’ll aim to post a new ClickOnce demo in the next few days.

Open-mouthed smile

187 Comments

  1. Hello, Chris, and thank you for the release.

    Sadly, I have to report a bug which still prvents me from using it.

    First, I compile all the projects and run the Cjc.ChromiumBrowserDemo

    Then, I click the “New Window” button, which opens another MainWindow with the WebBrowser within.

    Then, I close the original MainWindow, and they both hang unresponsive then.

    Note, that opening even more MainWindow instances and closing the original one causes exceptions.

    Note, that everything works well as long as the first original MainWindow is kept open and running.

    Note, that Cjc.AwesomiumWrapper project compilation still requires some messy tweaking of the -ologo parameter to get rid of the compilation error under Visual Studio 2010.

    I suppose the problems are related to the same WebCore construction and destruction.

    Reply

  2. Hi Chris,

    fantastic, I’ve got it to compile and run now! (Using VS 2010 Professional Trial)

    With the goal of making a great thing even better, here are some reports:

    1) I got the error “error RC1106: invalid option: -ologo” when compiling the Cjc.AwesomiumWrapper project. This is emitted by the Resource Compiler (RC).

    My suspicion was that this option should have been ‘-nologo’, and indeed, when I go to the project properties -> Configuration properties -> Resources and set “Suppress startup banner” to “No”, then everything builds fine. My guess is that this is actually a bug in VS..

    2) when I try to open mainwindow.xaml in the VS editor, I get the following message in the editor window: “System.IO.FileNotFoundException Could not load file or assembly ‘Cjc.AwesomiumWrapper.dll’ or one of its dependencies. The specified module could not be found.
    at Cjc.ChromiumBrowser.WebBrowser.CompositionTarget_Rendering(Object sender, EventArgs e)
    (…. rest of stack trace)

    Does this work in your environment? No references are missing in the Cjc.ChromiumBrowserDemo project, and in the \bin\debug folder the 3 DLL’s are present. Which is logical since the program itself does run, just not in the editor. Maybe these DLL’s need to be loaded into the GAC for use at edit-time? Or is there another way?

    3) When I close the main window after opening a second window, I don’t get a hang but a crash: Null pointer exception in Cjc.AwesomiumWrapper.h at line 868: bool IsDirty() { return webView->isDirty(); }

    Hope this helps, and thanks!
    Lex

    Reply

    1. Lex – Thanks for the great feedback! 🙂 I’ll get all (most? 🙂 ) of these fixed in the next day or two. Certainly the WebBrowserManager class is flawed (WebCore itself is a singleton; I’m probably not handling it carefully enough).

      The VS/designer issue is just related to the location of the native DLLs (Awesomium/Chromium); I’ll look into that once the main bugs are fixed.

      Reply

  3. Hi Chris,

    I just downloaded your last WPF 4.0 WebBrowser + Awesomium 1.6 RC1 but I can’t manage to make it work. In fact, it compiles well given that I change the platform of the CjC.AwesomiumWrapper to vs100 but when the application is lauching, I get a “Attempted to read or write protected memory. This is often an indication that other memory is corrupt.” in

    void LoadURL( String^ url )
    {
    webView->loadURL( marshal_as( url ) );
    }

    I can’t find anything in all the comments that solved my issue 😦

    Do you know what I’m missing here?

    Reply

    1. Hi Pierre,

      Does it run ok if you leave the toolset version at v90 for Cjc.AwesomiumWrapper? Unfortunately having v90 is a requirement because both Awesomium and Chromium currently have dependencies on the v90 C++ runtime.

      If you have any ideas of other ways to resolve this, please let me know!

      Thanks for the feedback 🙂

      Chris

      Reply

      1. Hi Chris,

        Unfortunately, if I keep the v90 platform toolset, I get this message and it won’t compile :

        Error 5 error MSB8009: .NET Framework 2.0/3.0/3.5 target the v90 platform toolset. Please make sure that Visual Studio 2008 is installed on the machine. C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets 292 6 Cjc.AwesomiumWrapper

        I don’t have yet a solution for that, but I’m looking into things to make it work 😉

        Thx for your quick answering

        Pierre

      2. Pierre – I’d forgotten about the VS2008 requirement… Do you have an existing (compiled) Cjc.AwesomiumWrapper assembly you could reference instead? (I could mail a copy if it’ll help).

      1. Arf, in fact, it doesn’t work either with your AwesomiumWrapper.dll…

        Program is stuck at the :

        InitializeWebView( width, height );

        Not crashing yet, but still been waiting for a return for 5 minutes now.. :s

      2. Hi Chris,

        I got your sample nearly working, but it seems like the AwesomiumWrapper you send me isn’t working well actually. I don’t have a webpage in your sample because the WebCore Constructor throws an error…

        I installed VS 2008 to compile AwesomiumWrapper from your project, but I doesn’t compile, telling me it misses WebCore.h

        Pierre

      1. in fact, it is exactly this line :

        webViewListener = new WebViewListener();

        in which i cannot step that freezes the app.

        Thx for your time, hope you can guide me to solution soon 😉

      2. Hi Chris,

        I managed to have a working & easy to re-use sample of your wpf browser, but I have still one mighty bug. I can navigate in pages through links, but I’m not able to write any text in any textbox rendered in your browser… I tried focusing, but the thing is, I have no problem getting the focus on a textbox, but still no textbox get the inputs.

        Any idea about what’s happening there?

        Thx for your help and all your pretty good work 😉

        Pierre

      1. Personally I still get a NullReferenceException while closing the primary MainWindow of the demo with a secondary MainWindow running.
        It throws an exception because of trying to call webView->isDirty(); after webView has been disposed and nullified.
        Do you think nothing should be fixed at the WebBrowser code?
        Look at the call stack:

        Cjc.AwesomiumWrapper.dll!CjcAwesomiumWrapper::WebView::IsDirty() Line 868 + 0x11 bytes C++
        Cjc.ChromiumBrowser.dll!Cjc.ChromiumBrowser.WebBrowser.CompositionTarget_Rendering(object sender, System.EventArgs e) Line 244 + 0x1d bytes C#
        Cjc.AwesomiumWrapper.dll!.Awesomium.WebCore.__delDtor(uint ) + 0x27 bytes
        Cjc.AwesomiumWrapper.dll!CjcAwesomiumWrapper::WebCore::~WebCore() Line 1103 + 0x1d bytes C++
        Cjc.AwesomiumWrapper.dll!CjcAwesomiumWrapper.WebCore.Dispose(bool ) + 0x2b bytes
        Cjc.AwesomiumWrapper.dll!CjcAwesomiumWrapper.WebCore.Dispose() + 0x25 bytes
        Cjc.ChromiumBrowser.dll!Cjc.ChromiumBrowser.WebBrowserEnvironment.ReleaseWebCore() Line 109 + 0xe bytes C#
        Cjc.ChromiumBrowser.dll!Cjc.ChromiumBrowser.WebBrowserEnvironment.Purge(bool force) Line 84 + 0x42 bytes C#
        Cjc.ChromiumBrowser.dll!Cjc.ChromiumBrowser.WebBrowserEnvironment.OnExit(object sender, System.ComponentModel.CancelEventArgs e) Line 118 + 0xa bytes C#

    1. Koichi – The “secondard webbrowser” bugs you’ve found are still there; I’ve not had time to look at them yet (busy week). I can add you as a contributor to the project on Codeplex if you’d like to fix it (not sure how soon I can get back on it); email me your username and I’ll get it set up 🙂

      Reply

  4. Chris,

    Just a minor build event tip, for the xcopy post-build events you should wrap the source and destination in quotes to handle paths with spaces in them.

    Keep up the great work!

    Regards,
    Donovan

    Reply

  5. Chris, thank you for adding me!
    I have uploaded the fixed files.
    http://wpfchromium4.codeplex.com/SourceControl/changeset/changes/3482

    WebBrowserEnvironment.cs contains the most important change as it allows working with multiple windows within an application

    Cjc.AwesomiumWrapper.h addresses issue with combo boxes.
    http://wpfchromium4.codeplex.com/workitem/263
    Now the application doesn’t crash, but it doesn’t display expanded combo box items, though.

    I have addressed Awesomium support discussions with this issue.
    http://support.awesomium.com/discussions/problems/45-problems-with-select-tags-combo-boxes

    Reply

  6. Hi Chris,

    I’ve compile and looked at your sample and I am impressed with it. It will be nice to finally get rid of the WPF WebBrowser and reclaim the airspace it was taking up in my app.

    I am having a couple issues getting the chromium browser to compile and work in my project.

    Project Info:
    OS – Win7 x64
    IDE – VS 2010
    Target Framework – v4.0

    I have added the Cjc.AwesomiumWrapper and Cjc.ChromiumBrowser to my references.

    In my xaml window I have added the line:
    xmlns:cjc=”clr-namespace:Cjc.ChromiumBrowser;assembly=Cjc.ChromiumBrowser”

    I have also copied the dll, Awesonium.dll and icudt42.dll, into my output directory.

    I then place the following line into my window grid:

    I get the following error, that was reported above, in the Visual designer:

    System.IO.FileNotFoundException
    Could not load file or assembly ‘Cjc.AwesomiumWrapper.dll’ or one of its dependencies. The specified module could not be found.
    at Cjc.ChromiumBrowser.WebBrowser.CompositionTarget_Rendering(Object sender, EventArgs e)
    at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
    at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
    at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

    I can live with that error, but when I goto compile I receive the following error:

    The tag ‘WebBrowser’ does not exist in XML namespace ‘clr-namespace:Cjc.ChromiumBrowser;assembly=Cjc.ChromiumBrowser’

    Any suggestions? This can be replicated with just a from scratch WPF Application project.

    Thanks in advance.

    Reply

  7. Hey Chris,

    I’m really excited to try out this component as I think it will fill one of the big holes in my toolkit… unfortunately I cannot get it to work.

    I initially tried to build it and got: MSB6006: “CL.exe” exited with code 1073741515

    After changing the build target of the Wrapper to v100 it builds ok but crashes with an access violation at runtime:

    I have a suspicion this is something to do with the combination of VS2K10 and Win7 64bit… but not being a C++ guru I’m finding it hard to pin down exactly.

    FWIW I can’t get the basic Awesomium sample to run either.

    Maybe I can try again when Awesomium gets native 64Bit support.

    Thanks for developing this… hope to get to try it soon.

    regards
    Duncan

    Reply

      1. Duncan, sure, you should get either Visual Studio 2008 or the compiled DLL of AwesomiumWrapper.
        I suggest you to read the prevois comments of this entry above.

    1. Thanks Koichi… I did eventually get this to work but then looked into the source to try and find out why it was flickering… unless I’m mistaken all the rendering is done to a giant bitmap before being painted to the screen? Somehow that concept seems to be a very bad fit for the WPF world.

      Reply

      1. Duncan – Until there’s a native WPF WebBrowser available, it’s likely the best fit we have for now. Chromium & Awesomium deal with byte arrays; we just copy from those to a WriteableBitmap for display.

        Note there are some improvements in this area in the Awesomum 1.6-based WebBrowser (compared to the 1.5.1-based stuff). I’m sure there are many further optimizations that could be made too 🙂

      2. Duncan, things are not that bad, actually.
        The rendering updates pixel bytes of a locked bitmap data, then marks for updating it into video memory, and unlocks then.
        I have compared it with native WebBrowser based on Internet Explorer. With Internet Explorer based WebBrowser I’ve had to render each whole frame pixels, without knowing whether does it require updating. With WebKit, you can find out if there is a dirty region on the window, and if there is, update just that region, only when it’s really necessary.
        You might try and dive deeper into parsing each tag, though I bet the performance will only drop from the level where WebKit renders the window bitmap. Surely, it has to be very frustrating to discover that after spending months to wrap each tag handling.

  8. Hi Chris,

    we’re making good progress with the multi-touch browser we’re developing based on your component 🙂

    One question: in the previous version, the display of Flash content was working out of the box (e.g. in the Threedeemium demo app), but in the latest version I get messages that Flash needs to be installed on websites that need it (e.g. our own, see the link under my name).

    I’ve added these lines (marked with LvdS) to WebBrowserEnvironment.cs

    private static void CreateWebCore()
    {
    var config = new WebCoreConfig();

    // LvdS
    config.SetEnablePlugins(true);
    config.SetPluginPath(@”C:\WINDOWS\system32\Macromed\Flash”);

    webCore = new WebCore( config );
    (… etc)

    but to no avail. Do you know what to do to enable Flash?

    By the way, here’s a tip to others working with it: when you do a Release build (and nothing else), the program wil run but no web-content comes up. In the Task Manager you will see that no ‘AwesomiumProcess.exe’ appears (contrary to the Debug version)… The solution is to copy this file, along with icudt42.dll, awesomium.dll and the Locales and Dictionaries folders to your Release folder, that should do the trick.

    @Duncan, it seems that what you want is a web-browser that has a layout engine in native WPF. I agree that this may be the ultimate solution, but it would also be a _huge_ project to develop something like that. In the mean time, I am exceedingly happy with having an Open Source component that renders everything Chromium can render to a bitmap and paints this to the screen (at any angle) :-).

    Reply

    1. Lex – I’d noticed Flash and Silverlight weren’t working but haven’t dug into it yet… I’d figured it was just because I’d not called SetEnablePlugins, but apparently not! 🙂 Hmm… I’m thinking we might need to hit the Awesomium forums for this (also, I’d be surprised if we needed to specify a path to the plugin – looks kinda fragile… also like you said, v1.5.1 worked great out the box).

      Reply

      1. Koichi – Any version should work ok with combo boxes, assuming Chromium renders them itself (unlike older IE versions that used a windowed control)…

        The ‘Source code’ page on the original http://wpfchromium.codeplex.com (rather than wpfchromium4.codeplex.com) is all based on Awesomium 1.5.1. It’d be good to get that updated for .NET4 (and its improved/fixed WriteableBitmap). Let me know if you wanna do it 🙂

      2. Chris, of course any version should work OK with combo boxes, but unfortunately Awesomium 1.6RC fails that, which makes it unusable for my current project.
        I have tested on several implementations, including AwesomiumGL sample and the ChromiumBrowserDemo.
        If you click a dropdown box open and close the window, destroying the associated WebView will cause an exception. Please try it on any website. For example, the following one.
        http://www.w3schools.com/TAGS/tryit.asp?filename=tryhtml_option

        And I will see if I can update the WPFChromium for .NET 4.
        My problem is that I am poor at C++ coding, compared to C# coding, which might be a trouble when working on AwesomiumWrapper project, if that will be necessary.

        I need a stable reliable browser for WPF 4 myself, so I will surely put an effort into trying everything possible.

      3. Chris, alright, I wanna do it.
        Just give me some hint how am I supposed to do that.
        What should I start from?
        Currently, WPFChromium built from the SVN code quits at changing location in Debug compile mode and displays some text in new windows.
        Any hint?

      4. Koichi – I can look into it in a couple of days if you’re ok to wait… Otherwise the best way to tackle it is probably to start with the latest 1.6-based code. Take a copy of everything, replace the Awesomium folder with the 1.5.1 source and replace Cjc.AwesomiumWrapper with the old version too. After that you’ll just need to fix Cjc.ChromiumBrowser so it works with Cjc.AwesomiumWrapper. You’ll notice the intellisense often gets confused about the MC++ project (AwesomiumWrapper) and claims things aren’t defined when they are. Just repeat a compile – fix – compile pattern until t stops complaining. This way you shouldn’t need to touch any C++; all the changes will be to Cjc.ChromiumBrowser 🙂

  9. I was examining the old WPF Chromium project code again to refresh my memory, downloading the code from the SVN repository of http://wpfchromium.codeplex.com/ which is based on Awesomium 1.5.1

    Then I have noticed again, that it crashes at certain situations, mostly at navigating to any other website, but only within debug mode.

    Then I have recalled that I have stopped working on my port of Awesomium.NET based on http://speps.fr/awesomiumdotnet based on Awesomium 1.08 of 2009-12-20
    I have stopped working on that because it was crashing on some important websites.

    But now I have compared the behavior and figured out, that I have never tried compiling and running it in release mode.

    So I have done that, and everything works fine!
    My WPF4 application creates the System.Windows.Controls.UserControl based control with a background painting from a WebView rendered WritableBitmap, there I can navigate multiple pages, within multiple instances, and I can type Alt-Codes symbols into the text fields, and use Flash and Silverlight plugins, and call javascript and accept callbacks.

    By the way, what license was Awesomium 1.08 distributed with?

    I hope that Rémi Gillig will permit me to publish the code.

    Reply

    1. Koichi – I’m pretty sure Awesomium 1.08 didn’t have any significant licensing requirements… The release/debug issues I hit previously were caused by using the “wrong” debug/release build of Awesomium (earlier versions had Awesomium.dll and Awesomium_d.dll). Think that might be the issue here?

      Reply

  10. Chris, do you have any idea why I cannot set the proxy to “auto” I can only set the proxy (“myproxy:80”) but not read from the system using auto.

    Reply

  11. Hey, I’m curious if anyone else is noticing any memory issues with this?

    I have a fairly unique application that uses many of these controls.

    Even with the demo app, if you open a new window, then close the same window, the amount of memory used will increase and stay increased (looking at the task manager). Is this an indication something is not being released/destroyed correctly?

    After using the application for an extended period of time it has to be restarted or things start to act really strange. Curious if anyone else noticed this or shad some ideas for fixes.

    Thanks,
    Kyle

    Reply

      1. I’m using the 1.6 RC1 Version.

        It seems to be leaking around 4.5 – 5MB per Browser Control.

        I tried to run .NET memory profiler on it but my application locks a bit after startup in the profiler so I couldn’t get any decent results (probably due to the fact I have no idea how to use the memory profiler)

  12. Great work so far! Have some trouble with the WPF 4.0 version.

    Setup:
    VS2010 Ultimate / Windows 7

    Have added Cjc.AwesomiumWrapper.dll (from your binary) and Cjc.ChromiumBrowser.dll ( generated from compiling source ) to references of the project. Also added icudt42.dll and Awesomium.dll to the project root path.

    Compiling gives no errors and the application starts. After that, it throws an exception of the type:

    Could not load file or assembly ‘Cjc.AwesomiumWrapper.dll’ or one of its dependencies. The specified module could not be found.

    I have tried to put the dll’s in /Debug/ in the root , everywhere. Do you have any idea? Could it be that my compiled version of Cjc.ChromiumBrowser is corrupted in any way? Or the use of your Cjc.AwesomiumWrapper.dll ? Or what did i do wrong 😛

    Thanks

    Reply

    1. Michel – Typically “not found” errors are thrown when some of the Awesomium dependencies (icudt42 etc) aren’t in the same directory as the executable. Can you send me a list of the files in the bin directory?

      Also, are you using Awesomium 1.6 or 1.5.1?

      Reply

      1. Just got back from UK.

        Solved the problem by setting the “always copy” for the dependencies. That worked fine, thanks.

        Also, i’m having some problems with the performance. When loading a page when other controls are doing stuff ( move or something ), all other controls “freeze” when the browser load. I have turned Async loading on and off but doesnt make a difference. Is there a multi-threaded fix? Or something to fix?

  13. Hey Chris,

    I realize you got a lot goin on and now are taking a look at ‘Berkelium’, but I was wondering if you had plans to update this project to use Awesomium RC2 soon?

    Reply

  14. Hi Chris,

    I’ve got the ChromiumBrowserDemoworking in the VS2010 IDE. Hats off to you. You’ve done some great work here!

    So I’ve tried to I start my own project but I keep getting this when I try to run it:

    ‘FileLoadException – mixed mode assemby is built against v2.0.50727 of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.’

    I think I’ve got everything in the right location and all the references seem correct but I’m obviously doing something wrong. Any help would be much appreciated.

    Reply

  15. Thanks for the quick reply.
    Your suggestion doesn’t fix the problem. I’m fairly new to all this so I know it must be something I’m doing wrong.

    Here’s what I’m doing:

    – Start a new WPF Application (Debug, x86)
    – Add references to Cjc.AwesomiumWrapper.dll and Cjc.ChromiumBrowser.dll.
    – Copy awesomium.dll and icudt42.dll into the project debug folder.
    – Copy app.config from \Cjc.ChromiumBrowserDemo into my project folder.
    – Add ‘using Cjc.ChromiumBrowser’ to MainWindow.
    – Add ‘WebBrowser wb = new WebBrowser()’ in the Loaded event of the MainWindow.
    – Run the project. Problem.

    I really don’t want to waste your time with this. If a solution is not obvious I’ll probably resort to starting with a copy of your working Demo project.

    Reply

    1. Jack – Sorry it didn’t work. Your suggestion of starting with the demo sounds a good one. If it runs ok, it’ll be interesting (for me) to compare with the broken project to see what the differences are… 🙂

      Reply

  16. First Great work!
    I am trying to use the working demo project. After opening the project in Visual Studio 2008 Pro, I see that the demo project does not have the required dll set as references. As I am new to this, I am assuming, I need to do the following on the working demo project as well?

    – Add references to Cjc.AwesomiumWrapper.dll and Cjc.ChromiumBrowser.dll.
    – Copy awesomium.dll and icudt42.dll into the project debug folder.
    – Copy app.config from \Cjc.ChromiumBrowserDemo into my project folder.
    – Add ‘using Cjc.ChromiumBrowser’ to MainWindow.
    – Add ‘WebBrowser wb = new WebBrowser()’ in the Loaded event of the MainWindow.
    – Run the project.

    Reply

      1. thank you so much for the binaries! I will give this a shot and let you know how it works.

        Again, terrific work!

      2. I am getting this error, that it cannot create an instance of type WebBrowser

        Here is a screenshot:

        I really dont want to waste your time on this, but will be honored, if you can atleast have a look and suggest something.

        The code compiles fine, but because it throws that error in the designer, I cannot go to anylink when I have the following code

        browser.Navigate(“www.google.com”);
        browser.Focus();

        Only the parent window/container shows up.

        Thanks again.

      3. jiga – The component can be tricky to get working in the VS designer because of its dependency on the native Awesomium / Chromium DLLs. If you can find the path that .NET is searching for the DLLs in, you might be able to drop the Awesomium DLLs in there. Maybe using something like SysInternals’ FileMon might reveal where it’s looking,

        If you close the designer and just edit the XAML manually, can you get your app to run and show something?

        If still no luck, zip up your project or a quick sample and mail it to me (chromium@chriscavanagh.com). I’ll take a look asap.

    1. By manually editing XAML, and running the code. All it shows is just the Window object with nothing in the browser.

      here is the screen shot

      Reply

      1. Hi Chris,
        Dont mean to disturb you on this, but wondering if you had a chance to look at the sample code I sent you. 🙂

        happy thanks giving ..

      1. I have implemented more functions(like executeJavascriptWithResult,HttpInterceptor) in berkelium and for my convenience i renamed the project in Troymium. I will post it asap.

      2. Cool! I want my own “-ium” name too; was thinking of Cavanium 🙂

        How does it compare to Awesomium (for performance, ease of use etc), and any issues using it with VS2010?

        Chris

      3. Cavanium looks very good 😀
        I started a project with berkelium because i needed for a data resources interceptor ( i need to create complete offline pages). I asked khrona for data resources interceptor but they didn’t add it in the RC2.

        Dunno about performance but maybe awesomium is more intuitive. atm i’m using vs2008 because compilation in vs2010 doesn’t yet work. Really i have not tried compilation in vs2010 because it requires a lot of time! I spent more than a day with compilation in vs2008 😦
        I will let you know any news 🙂

      1. It seems working with NET4. I successful compiled the wrapper and the demo(winform) in VS2010 and i added none inside app.config. Tomorrow i will try it with WPF.

  17. So close!

    My goal was to find a browser that would allow me to show and manipulate Google Earth inside WPF (Google is dropping their COM support in favor of a JavaScript only API.)

    Thanks to the comment here, I was able to get your WPF Chromium Browser up purring like a kitten. (I also ran in to the WebCore issue, the -ologo issue, had to download both 2008 and 2010 of VS (I was using C# express), and I also ran in to that plug-in issue.)

    But finally it all worked, the plug-ins loaded, and I could even edit the XAML via Expression Blend without a hitch, BUT!… there was one last obstacle that thwarted me.

    Google Earth’s plugin rejects the render window entirely and instead renders in a separate space in the upper right corner:

    Doh!

    That GE window resizes appropriately to match the window, but just doesn’t want to go in there. A shame. GE in WPF would have been sweet!

    Reply

    1. Brian – Great news!…almost 🙂 Google Earth would definitely be nice.

      It’ll be interesting to see how things pan out with IE9 and Direct2D; maybe we won’t need anything like Awesomium to render to a surface, and maybe plug-ins like Google Earth will be able to play with IE’s Direct2D context directly… and just maybe we’ll be able to render an IE9 context in an app and apply whatever transformations we like… Totally speculative and maybe caffeine induced, but could be cool 🙂

      Reply

  18. First great work ! Your ChromiumBrowserDemo works fine.
    I’m currently trying to add Chromonium Browser to my project and I have some dificulties. After having add the useLegacyV2RuntimeActivationPolicy = “true” value to my ‘startup’ element. When I run my project I’ve these exception : http://img189.imageshack.us/img189/3292/wpfbrowser.png
    Do you know how i can fix this problem ?

    Thanks a lot and sorry for my bad English

    Reply

      1. This exception occurs directly on startup, I doesn’t press any keys.
        For informations, my application is in fact a desktop which loads plugins.
        So I’ve a library project name WebBroser.Plugin.dll which is loaded dynamically by the desktop application. And when I click on the buton to show the webbroser, this exception is thrown immediately.

  19. I can confirm berkelium/NET works very well in NET4 Full/Client Profile. No need to add nothing in app.config. I’m using my derived Troymium with wpf too.

    Chris doesn’t the Blog show recent comment anymore?!

    Reply

    1. Gigio – Is the source available? Can I post some links? 🙂

      Not sure on recent comments… I needed to change the theme [to another mostly random one] because the previous one messed up code snippets 🙂 Doesn’t look like there’s a “Recent comments” widget for this bad boy.

      Reply

  20. I’m sorry, I would have liked to release the source code but my company denied to release the code because it’s part of a project with Royalies 😦

    Reply

  21. Good Morning! I think you are sleeping now 😀
    I have talked to my boss and atm we can only release assemblies just for non-commercial use. At least you can see the power of berkelium/troymium before spend time wrapping it. I will post some links asap 😉

    Reply

      1. Hi, for a quick test i have imported and adapted code from your WPF browser 🙂 So ofc i used WriteableBitmap.
        I have commented some lines and maybe there is some useless code for berkelium/troymium.
        There are still some bugs and i should make a better zoom function.
        Here you can download troymium http://www.troydesign.it/software.html

  22. I have finally been able to try the latest (source) version for myself and it works quite well, resolving the biggest issue I had with the last version (no parallel browsing). I had to do a little tweaking for NET 3.5 support.

    I did have one crash similar to the ones already reported regarding “bool IsDirty()” but I got a “Attempted to read or write protected memory” exception. I am really looking towards a fix for this. I wonder if this is wrapper or Awesomium RC issue.

    I was also hoping for a richer API with this update. I need to provide back/forward capability but I must also be able to tell whether I can actually go back or forward. There doesn’t seem to be an API for this. Is this hard to add? I’d gladly do it myself with some help and pointers but I couldn’t find anything in Awesomium API as well…

    Thanks!

    Reply

    1. Oh, and one more thing I just noticed. Flash used to work before out-of-the-box. Now it doesn’t any more even with your unmodified Cjc.WPFChromium.4.0. What could be wrong?

      Reply

    2. Hello Alex, you could try troymium. I have embedded some history functions to beta2 that i will release after some bugfix. About flash sorry i don’t understand your problem.

      Reply

  23. We had some problems compiling chromium under 64bit system(memory leak). So atm we are using only W7 32bit. I will install W7 64bit on a second partition asap… i think next year 😀

    Reply

  24. Happy New Year everyone!

    I have successfully integrated the current WPF browser source code with my code base. I have even managed to make Awesomium RC2 working with a few tweaks. I still get random crashes here and there. I’ve eradicated some by tweaking WPF browser source and I am not sure if the remaining issues are Awesomium or WPF related.

    Anyway, the next hurdle I am about to jump is the scrolling problem heavily discussed here https://chriscavanagh.wordpress.com/2009/08/25/a-real-wpf-webbrowser/.

    Chris, you mentioned you’d check with Awesomium developers about the possible ways to get the virtual page dimensions. This was back in the age of v1.5. Are there any news in this respect?

    If not, how should one start tackling this problem? I want to at least impose width on the page, get rid of vertical scrollbar and put everything in a ScrollViewer.

    Reply

    1. Hi Alex,

      I’ve done something a little bit similar using javascript. I use it to save the scroll position of a page when my application is closed and the scroll back to that position when the application is reloaded. Here’s a couple of snippets that might be useful.

      To get return values from javascript (error handling and non-string return types omitted):

      private string executeJavascript(string command)
      {
      var futureValue = browser.ExecuteJavascriptWithResult(command);
      var value = (object)futureValue.GetWithTimeout( 1000 ).Value();
      return value.ToString()
      }

      For getting the current scroll position:

      string XOffset = executeJavascript(“window.pageXOffset;”);
      string YOffset = executeJavascript(“window.pageYOffset;”);

      For setting the scroll position:

      executeJavascript(“window.scrollTo(” + XValue + “,” + YValue +”);”);

      For removing scrollbars:

      browser.ExecuteJavascript(“document.documentElement.style.overflow = ‘hidden'”);

      Hope this helps a bit, I know it’s not exactly what you asked for but hopefully it might help someone out!

      Reply

    2. Troymium beta 2 is out 😉
      – Fixed some bugs.
      – Added HideScrollBars function and onScrollSizeChanged event.
      – Added History manager class.
      – Added Support for 64bit System.
      – Included Wrappers for .NET Framework 3.5 and 4.0.

      There are still some issues, i hope to solve in next beta 😉

      Reply

  25. Hi, when I try to run Cjc.ChromiumBrowserDemo
    it keeps saying the line 801 has a Memory exception error
    How can I solve this?
    void LoadURL( String^ url )
    {
    webView->loadURL( marshal_as( url ) );
    }

    Reply

      1. I am using the latest source code from codeplex and using Awesomium 1.6RC. So no hope to get it running? Thanks.

    1. Mark – It looks like you need “Name” instead of “name” as the attribute (XAML is case sensitive; Name is a standard XAML property).

      Note although it should work & run fine if you’re editing the XAML directly, the XAML designer is unlikely to work correctly (the WebBrowser will likely throw an error because it can’t find the native Awesomium + Chromium (C++) DLLs).

      Hope this helps!

      Reply

      1. Thanks. It worked.

        Is there a way to get the designer working? no biggie though.

        I was also wondering if you are able to set custom useragent in the control.

      1. Oh Thanks! I didn’t register the onclick even on the button. stupid me

        How does executejavascriptwithresult work, can you give me an example please. I tried

        Messagebox.show(browser.ExecuteJavascriptwithresult(“return document.body.innerHTML”,””).tostring());

        but it returned an empty messagebox

    1. I was using another implementation of Awesomium .NET port, but the idea was to register a callback, for example named “report”, subscribe to the OnCallback event, and then call javascript code like _WebView.ExecuteJavascript(@”javascript:Client.report(window.history.length);”);
      Then my callback event handler received the name of the callback used, namely the “report” and the list of arguments.
      I hope someone can comment more on using JavaScript callbacks with WPF Chromium.

      Reply

      1. Oh, the binaries i am using is of an older version and it doesn’t have webcoreconfig class in it and i can’t seem to compile the .net4 Project to get the dll’s.

        Can you or someone else please post the updated binaries, please.

      2. Mark, the compilation problem of wpfchromium4 has been widely discussed within this blog entry above, please refer to the previous comments of this discussion. Briefly, it requires to have both Visual Studio 2008 and Visual Studio 2010 installed on the machine.

    2. Thanks once again.

      So i got the dll’s and everything and it works great.

      I am trying to set a custom useragent by this code:
      CjcAwesomiumWrapper.WebCoreConfig.SetUserAgentOverride(“sd”);

      it returns the following error:
      Error 1 An object reference is required for the non-static field, method, or property ‘CjcAwesomiumWrapper.WebCoreConfig.SetUserAgentOverride(string)’ RH2\WpfApplication1\Window1.xaml.cs 102 13 WpfApplication1

      Please help. and Thanks in advance.

      Reply

      1. Mark, from the error message saying it looks to me that you are trying to call the non-static method SetUserAgentOverride as a static one, according to Google Search replies which I have got for that error message. Try to dig that.

  26. Hello Chris,

    A problem with multi browsers in a tab control. It has confused me 2 days. Appreciate for your help.

    I assign a Chromium browser to a TabItem content, and allow user to add more TabItem just like normal browsers, Chrome, IE, FireFox…

    The problem is that only the first browser control displaying pages successfully, all the other following added browsers display html code of pages instead of a web page. I tested several web sites.

    Please see below illustration:

    My Dll Version:
    .Net: 3.5
    Cjc: Build with the source code from http://wpfchromium.codeplex.com/, and changeset is 47331
    Awesomium: Tested 1.5 and 1.5.1

    What I found:
    If I typed a image address to open, the browser could display it, if a web site or web page, it failed.
    I referred your code of YouCube3(which includes more than one browsers), but did not find any clues.

    Thank you very much, and you could contact me by email: jihong.liu@gmail.com

    Reply

    1. I suspect this problem is caused by mimatched DLL files. Can any one share a set of matched DLL files to me? I need Release build version.
      2 Cjc dll and 2 Awesomium dll.

      Many thanks for your great help.

      Reply

      1. Jihong – Which version of Awesomium are you using? (sorry if you’ve already mentioned this). I’ve tried your sample project (getting same behavior as you on second tab; also, navigating back to the first tab can throw an access violation). I doubt it’s mismatched DLLs, but it’s possible you’ve got one of the “bad” versions of my WebBrowser (there are a few) that got into a mess with WebCore.

        (FYI corrected a typo in my response; I’d originally written URLs instead of DLLs – sorry! :] )

      2. I used Awesomium v1.5.1 SDK MSVC9, and build CJC browser from codeplex with changeset 47331.
        I also encountered the exception when switching among tabs more than 5 times. I need invest it further.

  27. Chris, Great job!

    One question, could you point a direction for me to find the original Awesomium 1.08 source code?

    It’s hard to find them online now. If anyone has it, please share them with me. I might be able to do something good about it, and share it with everyone.

    Mark

    Reply

  28. Has anyone gotten Berkelium and Berkelium Sharp to render in a WPF control? I’d like to use it in a project I’m doing. I’m currently using it in a WinForms project and I’m really liking how well it has worked out. Placing in a WPF would be even better… and to top it off, it’s a BSD license unlike Awesomium. Upon investigation it looks like Soren Dreijer has attempted it: http://social.msdn.microsoft.com/Forums/en/wpf/thread/613b0a40-9bbe-44d4-b7c3-c4b054569c54

    Reply

  29. Jim Leichliter, thanks. I am thinking about building a wrapper for Berkelium to place it in WPF. But don’t count on it too soon. Busy with other project right now.

    Reply

  30. On my web page displaying in Chromium, I have a javascript function that returns a bunch of HTML in a new window. But my new window is not popping up. Is there a way to allow JS to open a new window? Or a way to intercept the JS call and put the results into a new window in codebehind? Thanks! (and nice work Chris!)

    Reply

  31. Actually kind of a related question to my previous one- I can’t seem to get any popup window to work- is this not possible? I really need some control over what it pops up, but I cant seem to get ANY window.open to work. Am I missing the obvious? Thanks!

    Reply

  32. Having trouble! Trying to recreate the WPF 4.0 demo project but the browser content only displays part of the time. I have scoured the demo project properties, done side-by-side comparisons of the output directories, everything I can thing of, but to no avail. References are the same, versions are the same, etc.
    The demo project works without fail. When I run mine, most of the time it displays a blank window, but every once in a while it shows my html page (google) just fine. Totally at a loss.
    Stepped through the code a bit too, see that with the CompositionTarget rendering update, I see my google page okay, and then after the next render after arrange override, my content is gone.
    Im building this on a 64bit Win7 machine using vs2010. No problems with the build.
    Anyone have any suggestions? Really would like to get this going!

    Reply

    1. This problem persists- it appears as though the SourceProperty DP is losing its binding… so sometimes you see a blank screen and sometimes it works.

      Reply

  33. Just an FYI I found an issue at shutdown in WebBrowserEnvironment where the main UI thread could be in the middle of calling WebCore.Update and recurse back into WebBrowserEnvironment and trigger disposal of WebCore (either via the app exit handler running or via Update trigger the Unloaded event to fire which would end up calling WebBrowserEnvironment.Purge).

    This was resulting in an access violation. I ended up using some integer flags and interlocked instructions to do some lightweight locking in OnUpdate to track when Update is running and defer the disposal of WebCore until after Update returns.

    Reply

    1. Murphy – I’ve not tested it with Chinese characters. The wrapper does do some manipulation of keyboard events, but it should behave correctly. Are you able to determine if it’s a wrapper problem or an Awesomium issue? (if you try one of the native Awesomium demos, it should be possible to determine if they have the same keyboard issue).

      Reply

  34. Hi,

    Can anyone please send me a complete source code example that include all dlls. I spend a week but I cannot make it works. I tried click one application and other demo. It’s great. But when I used these dlls in my own project, There are many messy errors. I downloaded source code from codeplex, but no luck.
    It seems that there is many version around and they are not compatible with each other.
    Please help me out.
    P/s: Please send me an example that use DLLS which has backward and forward function.

    Thanks.

    Reply

      1. Yes, I tried it and see how it work. But unfortunately, it is not free :(.
        I also tried troymium, however, there are many errors too.

  35. Hi Chris! Can you please send me the whole project with Awesomium DLLs.. I can’t find the DLLs and I tried the “official” .NET Wrapper but it doesn’t give me the flexibility to build a MS Surface web browser that has manipulation capabilities

    Reply

  36. visual studio 2010 professional gave following errors
    Error 1 error MSB8009: .NET Framework 2.0/3.0/3.5 target the v90 platform toolset.
    Please make sure that Visual Studio 2008 is installed on the machine.
    f:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets 292 6 Ex1_03
    any help would bee highly appreciated.

    Reply

    1. bvddz – Have you tried the C# wrapper that’s now included with Awesomium? As I recall, at the time this was posted Awesomium itself required VS2008; are you using the latest version of Awesomium?

      Reply

  37. Is it possible to use Awesomium webbrowser control inside WPF Page .
    I tried to use this with a page and loads a Url , but its not showing the contents.

    This is the code i used. But the same works inside a WPF window.

    So can we use it with WPF Page ? anything extra need to make that works with WPF page?

    Reply

      1. Yes It works with WPF page and WPF window and a good control this one.
        My mistake in code makes it hidden 😦 .
        Can we use the same for Windows Phone apps ? Any support for WP7 and WP8 SDK’s at present

  38. Hi m I am using VS2012 .Net framework 4.5. I am unable to use the chromium control . Is it not compatible with .Net framework 4.5 ?

    Reply

    1. Joey – I haven’t looked at this recently so haven’t tested compatibility with VS2012 (but .NET 4.5 should be ok). Have you tried using Awesomium’s own .NET wrapper instead?

      Reply

Leave a reply to Koichi Senada Cancel reply