A Real WPF WebBrowser

UPDATE 3: Check out the .NET wrapper now included with Awesomium!

UPDATE 2: New version available for .NET / WPF 4.0 here!

UPDATE: Source code available!  See post here.  Fixed keyboard / Javascript bug :)  Added some sample pixel shader effects! (including HatchingEffect by Charles Bissonnette).  If you need Awesomium_d.dll (for debug builds) you can get it here.

Being able to render and interact with webpages within WPF opens up some great opportunities.  While WPF already includes a WebBrowser, it’s just a wrapper around IE’s ActiveX control.  Unfortunately this prevents it playing nicely with WPF’s layout system 😦

Mixing Google’s Chromium project, a great wrapper called Awesomium and a little WPF pixie dust, we finally have one 🙂 :

WPF Chromium Control

You can try the ClickOnce application here.  Source is available on CodePlex (discussed here).  You should find it works great with Flash and Silverlight (assuming plug-ins already installed) but currently it might choke on XBAPs and Java applets.

If you prefer to run the binaries locally, you can get them here 🙂

image

image

For more examples, and an important note about VS2010, be sure to check out Sacha Barber’s related post.

For more fun, have a look at YouCube 3!

DotNetKicks Image

297 Comments

  1. Definitly, you’re the best 🙂
    .. Hmm.. And.. Are you going to port Flash to WPF, too, so that we can go Youtube ? 🙂

    Reply

  2. Very nice. Had wondered about a WPF browser myself.

    Performance seems decent. Any thoughts on that?

    Is is possible WPF could be better than GDI (or whatever firefox/chrome use natively) for browser rendering?

    Reply

  3. Jack / Jerimiah – I’ve been impressed with the WriteableBitmap performance. I toyed with using RTB but gave up pretty quickly (sorry J! My first attempt failed so I wussed out)… maybe WPF will eventually get Silverlight’s Raw AV 😉

    Reply

  4. Jason – Yes there is, but I’ve not looked in much detail at it yet. Awesomium has a mechanism for passing objects to the browser and calling Javascript methods. I’ve not exposed those on my wrapper yet, but probably will do soon 🙂

    Reply

  5. Paul – Right; it’s using a couple unmanaged DLLs, but they render directly to memory (and eventually a WriteableBitmap). Be sure to try it with Flash & Silverlight content too… 🙂

    Reply

  6. It’s great work!

    It is very fast and works with Flash and Silverlight.

    However, some Silverlight apps using WebClient(by HTTP Post or Get) at Application_Initialize procedure may not work well.

    Downloading Xap file succeeds but it may not work fully.

    Reply

  7. There is error:

    Cannot create instance of ‘WebBrowser’ defined in assembly ‘Cjc.ChromiumBrowser, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Exception has been thrown by the target of an invocation. Error at object ‘grid’ in markup file ‘Cjc.ThreeDeemium;component/window1.xaml’ Line 19 Position 10.

    can you help me?

    Reply

  8. Hi Chris Cavanagh
    i’m download your program from
    http://wpfchromium.codeplex.com/

    This is InnerException

    Visual Studio Debugger
    Troubleshooting Exceptions: System.Reflection.TargetInvocationException
    The exception that is thrown by methods invoked through reflection.

    thanks.

    Reply

  9. tung – Could you send me a screenshot of the Exception helper? Make sure the native DLLs are present in the current folder at runtime (debug or release) – they won’t automatically be pulled in like regular assemblies.

    Reply

  10. I also downloaded the source code on Aug. 31, and I found that there was a missing file in the browser project (Awesomium_d.dll). That is the debug version for Awesomium. If you change to the Release version on the .NET solution/projects, everything runs.

    Reply

  11. BobTLO – Good point. Awesomium_d.dll is around 50MB so it wasn’t practical to put that on Codeplex. You could build it yourself if you have all the Awesomium and Chromium source. Alternatively you could just dig around online until you find the latest pre-built DLLs:

    1) Download 3rd.zip.001 – 003 here: http://forum.quest3d.com/index.php?topic=67161.45
    2) Merge them into one zip:

    copy /b 3rd.zip.001 + 3rd.zip.002 + 3rd.zip.003 3rd.zip

    3) That should have everything you need 🙂 (sorry it’s a hack; hopefully the situation will improve soon).

    Reply

  12. Hi Chris Cavanagh

    I’m download and paste it in Debug and it run.
    Thanks for help me.

    First i think Awesomium_d.dll file not important so i was delete it.

    BobTLO – Thanks your imformation

    Reply

  13. Hi Chris,

    I’m about to try this component. I think it’s interesting and I think you have done a great job to find other solution beside using the webbrowser control. It’s pretty annoying, blocking the view of other wpf controls such as drop down menu, etc.

    I just download the source code (wpfchromium-27825.zip). and i saw that beside the awesomium_d.dll is missing. there are others that missing too: app.config and DeleteMe.cs. can i delete those missing files from the project or we need them too just like the awesomium_d.dll?
    btw, will this component work under xbap partial trust?

    thanks.

    Reply

  14. j3nonk – Thanks for pointing those files out. I’ve removed DeleteMe.cs and added app.config to SVN. You’ll need to get Awesomium_d.dll elsewhere (see below); you only need that to run a debug build:

    1) Download 3rd.zip.001 – 003 here: http://forum.quest3d.com/index.php?topic=67161.45
    2) Merge them into one zip:

    copy /b 3rd.zip.001 + 3rd.zip.002 + 3rd.zip.003 3rd.zip

    It’s likely it’ll need full trust because it’s running native code. If deploying a certificate is an option, this might help: http://blogs.microsoft.co.il/blogs/maxim/archive/2008/03/05/wpf-xbap-as-full-trust-application.aspx

    Hope this helps!

    Reply

  15. Hi Chris,

    It work. thanks for your support.
    But, there is a problem in the design view.
    When i open Window1.xaml, the design view can’t be displayed. Problem loading, the error is: Could not create an instance of type ‘WebBrowser’.
    Am i missing something?

    Thanks.

    Reply

  16. j3nonk – It’s probably the missing Awesomium_d.dll; you should place it somewhere Visual Studio can find it…

    Meanwhile I’ll look into making the WebBrowser control behave better on a design surface.

    Reply

  17. hi Chris Cavanagh

    i built your program in VSS2008 and run it ok

    but when i bring it to other computer and turn on it can’t run, when i run it,the program close automatic.

    but when i setup VSS2008 in that computer and run program again, it ok.
    i don’t understand. you can help me.
    thanks.

    Reply

  18. tung – Can you confirm all the required DLLs are in the working directory, and that the machine has .NET 3.5 SP1 installed?

    Try opening the ClickOnce app on this page. It should install any prerequisites. You can easily create a ClickOnce install for your own project too (remember to make sure the Awesomium.dll and icudt38.dll files are included in the deployment).

    Reply

  19. hi Chris Cavanagh , my programe was built on .NET 3.5 SP1, use WPF. webbrower is a one of screen of programe.

    when i click to open web form it turn of that form.
    (include Awesomium.dll, Awesomium_d.dll and icudt38.dll )

    but i install VSS2008 it run normal. i try to many computer and result the same.

    Reply

  20. and this is error :

    EventType : clr20r3 P1 : web.exe P2 : 1.0.0.0 P3 : 4aa1c9ec
    P4 : presentationframework P5 : 3.0.0.0 P6 : 488f142e P7 : 6259
    P8 : e1 P9 : system.windows.markup.xamlparse

    Reply

  21. tung – Sorry, I misread your comment. Can you send me your VS project? (or exe I can run). Try attaching to the DispatcherUnhandledException event (in your App class) and see if that catches anything.

    It could be there’s an exception being thrown on another thread and not caught… By default that would shut down your app; instead you can catch it and then pass the error to the main/UI thread.

    Also make sure if you’re responding to any events raised by the WebBrowser control, use the Dispatcher if you indend to update the UI (I’ll probably change my WebBrowser control to do this itself).

    Reply

  22. Chris Cavanagh – my os 32bit,

    does the app crash as soon as you run it- yes

    when i try catch:
    try
    {
    InitializeComponent();
    }
    catch (Exception e)
    {
    MessageBox.Show(e.Message.ToString());
    }

    in xaml:

    there a message :

    Cannot create instance of ‘WebBrowser’ defined in assembly ‘Cjc.ChromiumBrowser, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Exception has been thrown by the target of an invocation. Error at object ‘grid’ in markup file ‘Cjc.ThreeDeemium;component/window1.xaml’

    but i include (Awesomium.dll, Awesomium_d.dll and icudt38.dll ) in project and debug

    and final: when i install VSS2008 for debug it run ok. other computer no install vss2008 only .net 3.5sp1 error appear

    Reply

  23. I ran into problems that seem to be similar to what tung is facing. I had to download the awesomium_d.dll, and ensure it was put in the right place, then I ran into the cannot create an instance of WebBrowser issue.

    I traced the problem back to the source code and found that it had to do (at least in my case) with a line of code in the file Cjc.ChromiumBrowser.WebBrowser.cs.

    There is a line where ‘bitmap’ is set equal to a new WriteableBitmap with (width, height, 96, 96, pixelFormat, null) being passed into the constructor. I found that when height and width were zero an error was thrown and the program crashed.

    To remedy this all one has to do is set the height and width in the xaml file, something I had not been doing previously.

    This seems like a quick and dirty solution, as there should be a way to make it fill the grid/tab/whatever control element it is placed in. I’m pretty new to xaml so that is the only solution I’ve come up with so far.

    Reply

  24. Hi Chris, i’m writing a wpf application to display several media contents at time and i tried your work.
    However i get 2 errors using multiple browser instances + flash on the same form.
    1) webView.LoadURL(); / .LoadHtml(): I wrap an swf into htm… using the first and opening the html file it works, else it creates only the first swf instance.
    2) Opening the same swf file 2 times application crashes without any error hint.

    Any idea about this?
    thanks

    Reply

  25. Hi Chris,

    Is there any way to use a html string as input to the control – like WebBrowser.NavigateToString ?

    Cheers,

    Wayne

    Reply

  26. wayne – If you look at the underlying Cjc.AwesomiumWrapper, you can call LoadFile, LoadURL or LoadHTML. I only exposed the LoadURL so far (as Navigate) but it’d be easy to extend… (I’ll probably modify the WebBrowser control, but you could grab the source and add it if you prefer).

    Reply

  27. Davide – I tried your app and had around 4 browsers running before it died… Can you get a call stack and paste it here?

    If it’s in the Managed C++ (or worse, native C++) I’ll probably go get the Awesomium & Chromium source and take a closer look (I was lazy and used prebuilt binaries so far).

    Reply

  28. hi Chris Cavanagh : i’m find cause, but i don’t know why.

    When i copy your dll Cjc.AwesomiumWrapper.dll to my project and bring it to other computer int run ok.

    i compare two dll your size is 122368, and my size 138752, can you suguest anything?

    Reply

  29. tung – Could you email me both DLLs? If you add an assembly reference to Cjc.AwesomiumWrapper.dll to your project (instead of the project reference) does it all behave correctly?

    Are you compiling a release or debug build?

    I looked at the project you sent; currently Cjc.AwesomiumWrapper isn’t set to build (in Configuration Manager)… Is this deliberate?

    Reply

  30. Sorry Chris. No call stack… VS 2008 is unable to catch the failure. vshost is killed by system and application quits. No way to debug and disassembly doesn’t help.
    I’ll let you know…

    Reply

  31. Myapp has already an UnhandledException Handler but it doesn’t catch anything. System Event log only says “appcrash” no more details. The solution finder on vista suggest me there’s a flash plugin problem.
    Maybe i can wait until the awesomium.dll 1.5 🙂

    Reply

  32. Hi Chris,
    Great example and am having fun with the code at the minute.
    However, I am having a problem with shortcut keys i.e. the control does not seem to recognise ctrl+(+) to zoom in on the content.
    It would be really cool if the control supported this Chrome feature.
    Can this be done by tweaking your example, or does it go deeper into the awesonium library?

    Conor.

    Reply

  33. Conor – Awesomium exposes a few methods like Zoom, Copy, Paste etc. Curretly they’re not visible through my wrapper, but obviously they’d be easy to add. You’d just need to attach your own KeyDown/KeyUp handlers to call them 🙂

    Reply

  34. Hi!
    Great job, Chris!
    I was starting to write a WPF Chromium wrapper for my MS thesis, when I found your project and Awesomium: thank you!!
    I’m trying to embed the WebControl in a WPF touchscreen interface. In order to let the user easily scroll a web page, it would be better to use a re-styled scroll-bar instead of the standard one.
    Is there a way to do that with WPF styling on your control? I already tried to override the standard styles, and also to disable the scrollbars, but it doesn’t work… Are the scrollbars generated by Awesomium?

    Reply

  35. Gianni RG – Awesomium (or perhaps Chromium itself) generates the scrollbars, so right now we’re pretty restricted. At some point I’ll probably build Chromium from source (everything so far was from prebuilt Awesomium binaries) and see what level of control it offers. I’d assume it’s plenty, but I’ve not looked at any of their source yet… 🙂

    Reply

    1. Thank you for the reply!

      I had supposed so… 😦

      I’m a bit in a hurry with deadlines for my MS thesis, so I have no time to look at Chromium sources these days.

      Anyway I think I will continue the WPF Touch Interface project after graduation, in order to include a full-touchable browser. If I discover something, I’ll let you know…

      Reply

  36. Gianni RG – Another option (actually a dirty hack) would be to hand Awesomium an oversize bitmap that could fit “any” page height… As long as AllowAsyncRendering=false, calling WebView’s Render method should return you the area that was updated… Potentially you could initialize a Rect to 0,0 at the start of navigation, then stretch it to fit each successive render… Very very nasty hack, but it may be adequate in the (very) short-term…

    Reply

  37. Hi Chris,
    I get the latest version of your code and now seems it works fine with multiple flash pages.
    However there’s a weird thing… using moving animations it seems that mouse events are not handled properly.
    You can get a demo on http://www.prenassi.it/sysdata/PlayerMSP.v1.rar there’s an example file to load and run. Often after animations browser loose interactive capabilities, if you try rightclick context menu appears in anomalous position.
    P.S. I needed to put some “if(webView != null)” on AttachEventHandlers() delegates in WebBrowser.cs

    Reply

  38. Davide – Thanks for the update. I wasn’t able to get your exe to browse anything (I loaded the included XML file, but it didn’t appear to do anything). I’ll apply the fixes you suggested for the ( webView != null ) checks.

    Fyi the browser right-click isn’t really supported (yet). AwesomiumWrapper just sends the mouse events to the browser; currently Chromium is displaying its own window so it’d be tricky to align that with the WPF content. We’d need to take a closer look at Chromium & Awesomium to figure out the best way to handle it.

    Reply

  39. Davide – Ah I tried that, but it popped up a dialog showing a NullReferenceException 😦 …:

    Eccezione non gestita System.NullReferenceException: Object reference not set to an instance of an object.

    at MediaSpreaderClient.Parser.XmlPalimpsestParser.ReadPalimpsestAttributes(XmlNode palimpsestNode, IPalimpsestWorkspace workspace, OperationQueue queue)

    I’ve mailed a screenshot…

    Reply

  40. Hi,
    Great job Chris! I am looking to get rid of the old browser component for months!!

    One question though. Which .net framework your control depend on? 3.5?
    My app is 3.0 SP1 and I would like to keep it this way if possible… Will your control work on 3.0?

    Thanks

    Reply

  41. BenCause – The demo is built against 3.5SP1, but there’s a fair chance it’ll work with 3.0 too. First try using the Cjc.ChromiumBrowser in your 3.0 project and see if it likes it. If not, you might need to recompile Cjc.ChromiumBrowser (which might need some tweaks for 3.0, like removing LINQ statements or anonymous delegates). Cjc.AwesomiumWrapper should work without changes/compiling, but let me know if that’s not the case.

    If you’re able to upgrade to 3.5, you’ll probably benefit from the WPF performance improvements that were made. How much are you tied to 3.0?

    Hope this helps!

    Reply

  42. Thanks Chris! I will try that and get back to you.
    About 3.0, it is more a commercial issue than a technical one. I am trying to minimize the size of the overall download and installation time for my users… If I could get rid of all dependencies to the framework I would but unfortunately Microsoft did not provide any linker.

    If you have any ideas on how to optimize my deployment I would be glad to hear :-)!

    Thanks

    Reply

  43. hi Chris.
    I am trying to use your control in my app and getting the “Cannot create instance of ‘WebBrowser’ ” exception. I am running the application in release mode, so it shouldn’t be connected to the missing dll. when I run your demo – it works fine. when I use the dll for my app – it doesn’t initialize.
    I checked and saw the crash happens in the static constructor, when the webCore is populated.
    I guess I am missing something that you did, some property that must be initialized or something. can you help me to figure out what I am missing?
    Thanks a lot

    Reply

    1. I found the inner exception saying “The specified module could not be found. (Exception from HRESULT: 0x8007007E)”. this is strange since I am running in release mode

      Reply

    1. Thanks Chris.
      I had to move all dlls to the release directory of my application and now it works.
      For the benefit of other developers I want to add that it is important to set the Source property of the browser before using it, or else you will get the “You need to pass a non-null String” exception.

      Thanks again. this works great!

      Reply

  44. Wow! thanks for the quick fix!
    Chris, 2 more questions:
    1. I tried playing YouTube videos in the RealBrowser and that worked fine. But when I try to display only the video player and not the full YouTube page, it doesn’t work – the window stays blank. I tried the URLs in regular Chrome browser and it worked fine so i am not missing any plugins. what do you think?
    2. I did what you recommended in this thread and added the methods for LoadHTML and LoadFile, and that also works OK. But my app has to display UTF-8 characters, for different languages, and I saw that when I use these 2 methods the browser doesn’t respect that (with LoadURL it works fine). is there a possiblilty that the LoadHTML doesn’t support UTF-8?

    Reply

  45. mohoch:
    1) I’ll look into it…
    2) I’ve made some changes that *should* handle UTF8 ok, but haven’t tested it yet. If you try it (latest source on Codeplex) it’d be great if you could let me know if it works or not 🙂 Thanks!

    Reply

    1. Thanks Ill check it out.
      I added these 2 methods in the WebBrowser class, just under the Navigate method

      ///
      /// Displays a string as HTML in the browser
      ///
      /// the HTML
      public void LoadHtml(string html)
      {
      if (webView != null) webView.LoadHTML(html);
      }
      ///
      /// Reads an HTML file located on the local macine
      ///
      /// the physical path of th file
      public void LoadFile(string path)
      {
      if (webView != null) webView.LoadFile(path);
      }

      Reply

  46. Hi Chris.
    Thanks for the fixes.
    We are using the latest version and something weird happened – the links are not working any more. I will try to use the clix.h file with an older version and I will report to you tomorrow.

    Reply

  47. mohoch – Very odd… Here’s a few questions:

    1) Is that in your own app or the WebBrowser demo I posted?
    2) Do mouse events otherwise work as expected? (hovering over links highlights them etc)
    3) If you tab through the links and hit enter, does it navigate?
    4) Does this happen for every site?

    Meanwhile I’ll check for anything I might’ve broken.

    Reply

  48. 1. its in my app
    2. not all events are working as expected. on hover the cursor not always getting the right style.
    3. the Tab and Enter thing works sometimes, mainly for inputs and not for anchors
    4. the one I tried all had the same problem

    Reply

  49. Hi Chris.
    1. The link problem was solved when I removed the event handler for the “ReceiveTitle” event. maybe the event is broken as you said.
    2. Does the browser support “target:_blank”? it doesn’t seem to work on my side. maybe there is a way to add it.
    3. is there a way to cancel navigation after it starts?
    4. I am trying now to add scrollbars on the container of the browser. the problem is that the browser always gets the size of the container itself. is there a way of making its width and height be the full width and height of the content?

    Reply

  50. mohoch:
    1) I’ll take a closer look at the code…
    2) It doesn’t support opening new windows; it’s likely Awesomium doesn’t expose that (yet; version 1.5 is due “soon”)
    3) Not yet, but maybe with Awesomium 1.5… 😉
    4) Again, Awesomium is handling this. I can think of a few hacks that might work (rendering to oversize image and using a ScrollViewer)… the difficulty is finding the rendered page size. Similar answer to (2) and (3) – Awesomium doesn’t currently expose it…

    It’s looking like Awesomium 1.5 will be released Real Soon Now…

    Reply

  51. tung – Thanks! I tried it a few times with that url but couldn’t get it to crash 😦 Could you try it again (in Visual Studio; debug build) and see if you can get a stack trace? It’ll help me narrow down where the exception’s thrown. Thanks again!

    Reply

  52. i’m writing a program in WPF

    my program has a window webbrower and i use web control of VSS, it ok but my programme has a function rotate screen so webbrower also tranfrom
    but it not support in VSS, so i search in google and find your programme , that bring me much attention.

    but currently there are some errors that I do not know how handle. that is keyboard input and some site interrupt programme with any size windows.

    you can give me any advice?
    respectfully

    Reply

  53. Everything goes well…there is still one annoying thing..tooltips within the browser are always shown with the same orientation, regardless how the browser is rotated

    Reply

  54. Radu – Actually that’d be pretty easy to change if you wanted (and didn’t mind tweaking WebBrowser.cs a bit). It uses WPF’s regular Tooltip, but it’d be straightforward to change it to your own element (as a child of the WebBrowser it’d rotate/transform with it). Let me know if you need any help navigating the source code… 🙂

    Reply

  55. Hi,

    You made an awesome work !!! Thank you very much for it !!! We can now have fun with the browser in WPF. This is priceless.

    Unfortunately, I found a strange behavior with the DragonFly Autodesk’s website : http://dragonfly.labs.autodesk.com/#index=home
    The site works well on Chrome, but when I test it with Cjc.ThreeDeemium, it stops at 100%.
    Do you have any idea why it hangs on chromium and not on chrome ?
    Thanks again for your work !!!

    Reply

  56. Hi

    Thank you for your work!

    How I can get current snapshot of WebBroswer control? Is it possible to catch it at 10-25 fps speed?

    I want to capture it to video file… Have really good DirectShow experiense, now want to get frames from browser. With Flash that’s not possible with standard IE control.

    Thank you!!!

    Reply

  57. Laurent – If you open the WPF browser as an app (from Start menu instead of ClickOnce from page) do you still get the same problem? (works for me from Start menu, but not browser)…

    Reply

  58. Hi Chris

    No, I want to use WebBrowser control, so, user must use it as real browser, click on links or Flash control buttons and so on.

    So, I want to use WebBrowser and capture snapshots from it.

    I checked console sample, but it’s doesn’t show how to do that with WebBrowser control.

    Reply

  59. Hey! Great work on gathering quite a few loose ends to get some real browser power into WPF. I have finally overcome some starter problems and I have one tiny question:

    My test application will connect to a local server over HTTPS, this means I have a self-signed certificate that won’t automaticly be accepted by the browser. Connecting to a server with a real certificate loads the page just fine, but I get a white page on my localhost connection. Any ideas about where to start looking in your code, awesomium or chromium? Any helpers would be much apreciated.

    Reply

  60. Chris, I’m using RenderTargetBitmap to get frames now but not sure that it can provide required speed for video capture… Maybe your wrapper can provide better/correct way?

    Reply

  61. Hello Chris,
    I’ve tried the install from this page : http://www.chriscavanagh.com/chris/Cjc.ThreeDeemium/publish.htm
    If I start from web browser or from the start menu, when I click on the Get Started button, it loads until 100% is displayed, then, after 3 seconds, the inner part of the window gets black, and the mouse cursor shape change to the “busy” animation (the animated blue circle of Vista).
    I’ve updated the source code from codeplex, build it, then tried the Cjc.Chromium, and it still hangs….
    I’ve paused the execution, and I noticed that the browser is stopped at the following method : in the AwesomiumWrapper.h file, WebView class, method : Render, line of code 424 : Rect^ result = gcnew Rect();
    It also works on google chrome v. 3.0.195.27.
    Do you have any idea of what happens ?
    Thanks in advance,
    Laurent.

    Reply

  62. Roman – Have you tried WriteableBitmap? That’s what the WebBrowser control uses internally (might expose it as a property too as I recall). Create the WriteableBitmap once (resize it as your window/container resizes) and just let AwesomiumWrapper write to it. Awesomium is fairly efficient in only updating the “changed” parts of the bitmap (use the Rect that Render returns to determine where to update).

    Reply

  63. Hi Chris,

    the language asia can’t input in webbrowser, can you tell me how does it fix.

    i input korean language ex: 화ㅂㅈ댁셔 ㅎㄴ앟 ㅘㄱ샐 인뎋
    but it does not appear (i type in google site).

    Reply

  64. Ian – It’s a WPF control wrapping a C++ library (Awesomium + Chromium). Currently scrollbars are rendered by the C++ as part of the bitmap (based on the size constraints given). If Awesomium could tell us its current virtual page size we could size a bitmap appropriately and do the scrolling in WPF instead. I’ve mailed Awesomium’s author to see if this could be added.

    Reply

  65. Roman – Sorry for my slow reply… I’ve added a “ContentChanged” event to the WebBrowser control, and also exposed “Bitmap” as a read-only DependencyProperty. The updated source is on CodePlex but I’ve not tested it at all, so looks like you’re now a beta tester 😉

    If you use the ContentChanged event, ContentChangedEventArgs includes a Rect property describing the updated region (or the entire region if EnableAsyncRendering=true).

    Let me know if it helps! 🙂

    Reply

  66. Roman – You’ll still need to figure out how to get the content from the WriteableBitmap, but that should be pretty straightforward.

    Another way to capture the browser image is with RenderTargetBitmap. Just create one and call its Render method, passing it the WebBrowser control. However using the new Bitmap property should be more efficient 🙂

    Reply

  67. Ho Chris,

    this is just awesome 🙂

    I am just embedding Chromium in my next release of my client for Google Reader (as the frame control is just a mess…).

    I am curious if the embedded DLLs in your example app are the most current ones? If not could you provide them as a compiled download as my VS Express is unable to compile mixed C++ and C# 😦

    With the DLLs I am currently using I stumbled across a strange error – everything seems to be fine – I am able to render anything I like, follow links by clicking on them and so on. But if I double click anywhere with the control it crashes my app – any idea…?

    Can’t believe how fast Chromium is – seems I need to change my default browser now 😉

    Reply

  68. Sven – Those are the latest binaries we can currently get. However, Awesomium 1.5 is due imminently (and has been for some time 😉 ) so hopefully that’ll improve things.

    As for double-clicking, I shamefully admit I’ve never tried double-clicking my control 🙂 I’ll go kick it around and see if it’s something I can fix 🙂

    Reply

  69. Strange enough there is no stacktrace even if I start it in debugging – I just get the Winsows “vhost.exe has stopped working” alert and then it simply ends. But I have some data in the EventLog I put at the end of this comment. Additionally I am just uploading my full project right now to Codeplex so if you want you can see it live in a few minutes at http://desktopgooglereader.codeplex.com/SourceControl/ListDownloadableCommits.aspx

    Event Log:

    Faulting application name: DesktopGoogleReader.vshost.exe, version: 9.0.30729.1, time stamp: 0x488f1c9b
    Faulting module name: Awesomium.dll, version: 0.0.0.0, time stamp: 0x4a0e61b7
    Exception code: 0xc0000005
    Fault offset: 0x001fba5f
    Faulting process id: 0xc34
    Faulting application start time: 0x01ca5f19eb29e751
    Faulting application path: C:\Users\Sven\Documents\Development\Desktop Google Reader\DesktopGoogleReader\bin\Debug\DesktopGoogleReader.vshost.exe
    Faulting module path: C:\Users\Sven\Documents\Development\Desktop Google Reader\DesktopGoogleReader\bin\Debug\Awesomium.dll
    Report Id: 5f8fa3cb-cb0d-11de-8a04-00164192cd67

    *******************************

    Fault bucket , type 0
    Event Name: APPCRASH
    Response: Not available
    Cab Id: 0

    Problem signature:
    P1: DesktopGoogleReader.vshost.exe
    P2: 9.0.30729.1
    P3: 488f1c9b
    P4: Awesomium.dll
    P5: 0.0.0.0
    P6: 4a0e61b7
    P7: c0000005
    P8: 001fba5f
    P9:
    P10:

    Reply

  70. Project now uploaded to http://desktopgooglereader.codeplex.com/SourceControl/ListDownloadableCommits.aspx – if you have a Google Reader account you could login, change within the preferences to use Chromium (please login first – just fixed a bug there after upload) and play a little bit in the content area – I normally get crashes quite fast when reading full articles and double (or more) clicking in the Browser.

    If you like you can get me at Google Talk with PidginSnarl@googlemail.com 🙂

    Reply

  71. Roman – I’ve still not tested it :$ But it’s likely Bitmap will be null until the first render happens… Try attaching to the ContentChanged event and see if Bitmap is non-null by then…

    Reply

  72. You did great job..

    But here are the things that you may want to consider..

    Awesomium is no longer open source. The author of Awesomium wrote about this in this post http://princeofcode.com/blog/?p=267.

    But according to the comment of this post, he said that old version of his library will remain under LGPL (No commercial )..

    future release started from 1.5 might not be free.

    Good luck,

    Reply

    1. Yeah, that is a bummer. Because of this, I’ve had to steer clear of Awesomium because the price is ridiculous ($2900).

      Reply

  73. Michael, Roman – Adam’s made a few comments lately about Awesomium licensing. We’ll need to see how it pans out. At least what we have already is “ok” for most non-commercial stuff (obviously it’ll fall behind as Chromium/Awesomium evolves). For more serious stuff you’d probably want a license anyway. Alternatively someone could take the most recent [Awesomium] LGPL source and bring it up to date with Chromium, then maintain it as a separate project. I’d be happy to keep this WebBrowser up-to-date with that; we just need someone to volunteer for the C++ stuff 😉 (I’ve served my time already; happily a hazy memory).

    Reply

  74. Commercial license is ok, I just worried about your wrapper future. I hope it’ll support latest awesomium features and so on.

    Reply

  75. Hi Chris

    Sorry, but Bitmap property always null, I do not understood how to fix it. Please give me small sample with Bitmap correct usage or something like it.

    Reply

  76. Actually, what I think is that somone bring most recent [Awesomium] LGPL source and port it the managed code.

    so, it allows a lot of .NET developers to contribute the project.

    Reply

  77. Hi, could you perhaps post a compiled version of the latest release of the wrapper and browser on Plex? I’m having a hell of a time trying to compile the C++ stuff, would be much appreciated, thanks!

    Reply

  78. Hello. Thanks for a great app, nice to not be restricted to IE for internal app web browsing.

    Is there any methode to capture the html \ stream of the webpage after it has been loaded?

    Reply

  79. Chris, how I can contribute some code? I wrote update that allow me to get current image as byte[] without memory copiing…

    Reply

  80. Great work Chris – I really love having the option to use Chromium instead of IE within my Google Reader. Did you have time to have a look in my DoubleClick problem?

    And could you upload the compiled anywhere as I only have VS Express and can’t compile cross language projects (C++ *or* C#).

    Once again thanks – planning to release my first official version with your WebBrowser included tomorrow 🙂

    Reply

  81. Sven – Sorry for my slow reply. Your Google Reader is awesome 🙂 I installed it and get the same double-click problem. I’ll try running it from source and see if I can narrow down the problem…

    Reply

  82. Great work Chris!

    Are there equivalents of InvokeScript and ObjectForScripting for working with the HTML?

    Thanks, Meekal

    Reply

  83. Meekal – Sorry for my slow reply; I’ll take a look. Are you using binaries from the ClickOnce deployment or have you rebuilt the WebBrowser from source? The source includes several fixes to the ExecuteJavascript functionality that are probably missing from the current binaries…

    Reply

  84. Really, I need start point, I’m still newbie in WPF, i think I can use RaiseEvent or something like it.

    I can click using some other ways, but can’t emulate mouse moving, enter/leave and so on.

    Reply

  85. Hi

    Any way to move horizontal/vertical scrollbars in code? Or it’s UIElement specific feature, not Browser control unmanaged thing?

    Reply

  86. Hi again,

    could you give me / us a 32 and 64 Bit dll as I would like to deliever my Google Reader for “Any CPU”. When referencing your Wrapper I get

    Referenced assembly ‘Cjc.AwesomiumWrapper.dll’ targets a different processor than the application.

    And starting on a Windows 7 with 64 Bit causes

    Cannot create instance of ‘WebBrowser’ defined in assembly ‘Cjc.ChromiumBrowser, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Exception has been thrown by the target of an invocation. Error at object ‘BorderChromium’ in markup file ‘DesktopGoogleReader;component/uielements/mainwindow.xaml’.
    at System.Windows.Markup.XamlParseException.ThrowException(String message, Exception innerException, Int32 lineNumber, Int32 linePosition, Uri baseUri, XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type objectType)
    at System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext, Int32 lineNumber, Int32 linePosition, String message, Exception innerException)
    at System.Windows.Markup.BamlRecordReader.CreateInstanceFromType(Type type, Int16 typeId, Boolean throwOnFail)
    at System.Windows.Markup.BamlRecordReader.GetElementAndFlags(BamlElementStartRecord bamlElementStartRecord, Object& element, ReaderFlags& flags, Type& delayCreatedType, Int16& delayCreatedTypeId)
    at System.Windows.Markup.BamlRecordReader.BaseReadElementStartRecord(BamlElementStartRecord bamlElementRecord)
    at System.Windows.Markup.BamlRecordReader.ReadElementStartRecord(BamlElementStartRecord bamlElementRecord)
    at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
    at System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord)
    at System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment()
    at System.Windows.Markup.TreeBuilder.Parse()
    at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
    at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
    at DesktopGoogleReader.MainWindow.InitializeComponent() in q:\Dev\Projects\Desktop Google Reader\DesktopGoogleReader\UIelements\MainWindow.xaml:line 1
    at DesktopGoogleReader.MainWindow..ctor() in Q:\Dev\Projects\Desktop Google Reader\DesktopGoogleReader\UIelements\MainWindow.xaml.cs:line 58
    at DesktopGoogleReader.AppController.Start(IEnumerable`1 initialData, IReader reader) in Q:\Dev\Projects\Desktop Google Reader\DesktopGoogleReader\Controllers\AppController.cs:line 75
    12/16/2009 14:22:21: Exception has been thrown by the target of an invocation.
    at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
    at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
    at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
    at System.Activator.CreateInstance(Type type, Boolean nonPublic)
    at System.Windows.Markup.BamlRecordReader.CreateInstanceFromType(Type type, Int16 typeId, Boolean throwOnFail)
    12/16/2009 14:22:21: The type initializer for ‘Cjc.ChromiumBrowser.WebBrowser’ threw an exception.

    12/16/2009 14:22:21: Could not load file or assembly ‘Cjc.AwesomiumWrapper, Version=1.0.3572.17999, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. An attempt was made to load a program with an incorrect format.
    at Cjc.ChromiumBrowser.WebBrowser..cctor()

    Reply

  87. Sven – Currently I only have 32bit builds of the Awesomium DLLs, and the latest source I’ve found is already out of date 😦 Hopefully the situation will improve with Awesomium 1.5.

    Reply

  88. Hey there, Chris!

    I noticed the AwesomiumWrapper seems to crash when running it in Debug mode viewing the site http://www.goteborg.com

    When you drag the mouse over the green box saying “Boka online”, the WPF Chromium Browser just shuts down due to a user-defined breakpoint. I can’t seem to find why this happens. Can you?

    Anyhow, the browser seems to be working well while in Release mode. Thanks for your great effort!

    /Sebastian

    Reply

  89. Hi Chris,
    This is a great utility. I am facing a problem. The Ready event is not being fired in my application. Do you have any idea what might be wrong, or what is causing it.

    I have being tring it since a long time, but couldn’t find a solution.

    Any help would be appreciate.

    Thanks,
    Tushar

    Reply

    1. Tushar – Do yuo have the latest source from CodePlex, or are you using the binaries? Reason I ask is the binaries (zip & ClickOnce demos) aren’t quite as up-to-date…

      Do you have a sample project you could send me? (just something simple to highlight the problem; could email to blog at chriscavanagh.com)

      Reply

  90. Hi Chris,

    Thanks for the great powerful version of Chromium in WPF!

    I’ve downloaded the libraries and the ThreeDemium source example. implemented the browser in my app which works great on my computer but when I try to build a setup file using .net setup project and installed it on another computer the browser crashes indicating a xaml parse error: “Cannot create instance of Cjc.Chromium”.

    All 4 dll’s exists in the installed directory: Cjc.ChromiumBrowser.dll, Cjc.AwesomiumWrapper.dll, Awesomium.dll, icudt38.dll.

    Even more, .net 3.5 sp1 is installed on that machine, and still the browser crashes.

    Any more dependencies I’m missing? and Idea’s how to solve this issue?

    Thanks!!
    Daniel

    Reply

  91. Hi Chris,

    I’m using the release version tough I have the _d.dll there aswell. I’ve tried the ClickOnce installer and it doens’t work.

    Also checked the EventViewer but nothing new there:

    The program Cjc.Chromium3D.exe version 1.0.0.0 stopped interacting with Windows and was closed. To see if more information about the problem is available, check the problem history in the Action Center control panel.
    Process ID: 1368
    Start Time: 01caa896d10c43d3
    Termination Time: 11
    Application Path: D:\Users\yanco\AppData\Local\Apps\2.0\R5E1T3QZ.8RC\94YQZLBW.5DD\cjc…tion_0000000000000000_0001.0000_596d63f0d71c001b\Cjc.Chromium3D.exe
    Report Id: 90586070-148a-11df-a632-00241ddf7af6

    I might mention that I’m using windows 7 and also other .net programs that uses Chromium doesn’t work like (AwesomiumDotNetDemo).

    Please advise

    Daniel.

    Reply

    1. Hi,

      I think I found the problem. I was building the WPF for Any CPU, when the Cjc.AwesomiumWrapper.dll release sized 107KB is built for X86, Thus building my application in X86 solved this issue.

      There is also another version of the AwesomiumWrapper sized 188KB which doesn’t work with the X86 release.

      I hope to find or build a wrapper that would be able to work with AnyCPU.

      Thanks for your help…

      D

      Reply

  92. Hi Chris,

    One more question please.

    Is there a way to set the transparency alpha level of the background instead of just setting isTransparency to true/false?

    so that the background would be partially transparent and not completely cut off?

    Thanks

    D

    Reply

    1. Daniel – Awesomium doesn’t allow you to set an opacity/alpha level (at least not when I last looked). However, there’s nothing preventing you putting the WebBrowser inside another WPF control (Grid, Border etc) and giving that a partially transparent background…. Does that help?

      Reply

  93. Hi, Chris

    First of all, thanks for developing this nice control.
    We are using it inside a WPF application and works fine for local addresses but we couldn’t access any internet location. We think the problem is caused because the control is using an incorrect proxy configuration. Is it possible to specify the proxy settings used by the control?

    Thanks in advance.

    Reply

  94. Hi Chris,
    I have encountered another issue with the control.

    I have been using this control in one of my apps. There is a WPF window, which hosts only the webbrowser control and a button.
    The window reads the value from the db and sets it to the browser control.

    Recently what I have noticed is that at times, the html content is not dispalyed. But if you want for sometime and reopen the same window, it displays the content.

    I guess the Ready event is not being fired.

    Has anyone else faced this problem ?

    Thanks,
    Tushar

    Reply

    1. Tushar – Are you using the latest version of the WebBrowser control, and are you using the binaries or building directly from the source on Codeplex? (source is more recent; more likely to have bugfixes… if any 🙂 )

      Reply

  95. Hi Chris!

    I’d like to know how can I open the link below in your browser:

    (This link is a .swf (flash) file that plays a specific youtube video.)

    It plays nicely on Chrome, but not on your WPF browser. Do you know why?

    Thanks in advance

    Reply

  96. Hi Chris,

    can I interact with you control to fire events? e.g. can I fill a form and press submit button programmatically?
    Thanks.

    Reply

  97. Hi Chris,
    thank you for putting so much effort into this.
    I’d like to ask something, too.
    I’m declaring the webbrowser control in xaml, NOT setting a source. When I try to set the source afterwards via Navigate() it first navigates to the desired URL and switches back to about:blank immediately. But when I set the source to about:blank in Xaml and try to Navigate() afterwards it’s working fine. Odd 🙂

    Reply

  98. First of all, Great job!!!

    I would like to capture navigation events and then decide if I want to continue, cancel or start URL in a new window, hence launch a new webBrowser component.

    I believe I should implment this in a method that subscribes to the BeginLoading() event, but I am not sure how to cancel a loading and how to read the URL that was clicked on the web page.

    Reply

    1. Anders – You’re probably on the right track… Let me know if you figured it out already; otherwise I can kick it around in a test project if it’ll help 🙂

      Reply

  99. I actually have not solved this one yet. After looking at other browser implementations I learned that while it is relatively easy to capture a browsing event within the same browser, it is for the default c# webbrowser pretty complicated to capture a navigation that trigger an external browser to be started. That will require some hooks into the original C++ methods. I felt I needed to understand the default browser first before knowing what to look for here. Do you believe that this browser can capture and intercept both clicks that result in change of local URL as well as clicks that result in opening external pages?

    Reply

  100. Chris – Thanks for the guidance. After looking at this, it seems like the external links are in fact super easy to solve, as awesomium fires the event ‘onOpenExternalLink’ when an extenal link is about to open. Hence you can decide to create a new instance of awesomium or cancel it or change the URL of the running instance. However, for links that will load in the running instance of awesomium it seems to me that while the event ‘onBeginNavigation’ provides the URL clicked, it does not give an opportunity to set ‘e.Cancel’ or ‘e.Processed=true’ like you do with the C# or WPF browsercontrol. Hence I can’t seem to be able to cancel the click made. Do you think I am reading this correctly?

    Reply

    1. Hi Anders,
      We faced the same problems you are having and you are right, there is no (easy) way to cancel navigation… the work around we chose is like you to use “onOpenExternalLink” for external links and to use “onChangeCursor” for the other links.

      OnChangeCursor gives you the link of the target page if the link were clicked so this is what we do: we capture the URL and make it open in the user default browser, blocking the clicks to awesomium when onChangeCursor gives a non-null URL

      I hope it helps!

      Reply

  101. BenjoTLV: Great suggestion, I’ll start testing that right away. Thanks!!
    Chris: Thanks for the invite. I’d love to help with what I can. For sure, if I change anything in your WPF browsercontrol it would be so much more effective to share that with others.

    Reply

  102. BenjoTLV – your suggestion sounded very straight forward, but I’m afraid that I don’t quite understand how to implement it. I believe what needs to happen is that a new event must be added in WebBrowser.cs (same section as the existing events like BeginLoading is located). Then the event must be raised inside the method “InitializeWebView”, similarly to how BeingLoading is raised. Once this is done, we can subscribe to the event from the WPF class that creates an instance of the WebBrowser class. Inside the ‘InitializeWebView’ method I identified the section that is executed when the OnCursorCursor happens (it’s called ‘changeCursor’ in webViewListener). So far so good. I am however clueless as to how I can dig a URL out of that parameter. The other events like BeginLoading has nice parameters it receives, so all in all much easier to deal with and extend. I’ll keep researching now when I know this can be done, but if you have can still find your implementation, I’d be very interested into seeing it.

    Reply

  103. BenjoTLV – I think I am on to it now. The event to look for is not OnCursorChange or ChangeCursor but OnChangeTargetURL. That event is also fired when a mouse is hovering over a link, but this event contains the URL 🙂 This is starting to look very promising!!

    Reply

    1. Absolutely right Anders, sorry for the mistake!

      Chris, I’ll be happy to be a contributor but I am not sure I will bring a lot! I will send you my codeplex details shortly anyway

      Reply

  104. I have a reproducible crash.
    1) Goto CNN.com.
    2) Click on the flash advertisement to the right (some car purchase commercial). This will start loading the advertisement.
    3) click “back” and the application blows up.
    I don’t know why. How would you like reports like these to be shared? through codeplex or this blog?

    Reply

  105. Another issue is google apps. It loads email OK, but if you click on documents or calendar, the browser hands. No crash though, it just hangs. Strange since this is based on google chrome’s browser… I do seem to recall, that google apps is using some javascript that in some cases are not supported, at least on iphone/iPad it is not

    Reply

    1. Anders – More likely to be a bug in my code… There’s a small bit of funky stuff going on when WebBrowser is told about the url changing; it changes its Source property to match, with a flag aimed to prevent an infinite loop… I’ve seen a couple sites (Netflix was one I think) that got into an infinite redirect to themselves; should be an easy fix for us though 🙂

      Reply

  106. I see a similar hanging when trying to stream netflix video (not quite the same though, as the loading animation is not running in this case). Still I’m unable to debug my way to see anything truly wrong there. The back button still works although response time is slowed down, so something is taking a lot of cycles. Oh well, not the biggest of issues at this moment

    Reply

    1. Anders – Some issues might be fixed by Awesomium 1.6. There’s an alpha available, but I’ll probably wait until it’s released before updating WebBrowser/AwesomiumWrapper… Unless you wanna do it? 🙂

      Reply

  107. Chris – I don’t think I have the skills to do a full integration, but I can extend things a little here and there. I noticed on Adams’s pages that 1.6 is still having some crashes, so we are properly better off with what we have for now. At present it seems WPF WebBrowser with Awsomium has enough features to implement my first demo. I have not decided what the next steps are after the demo.

    Reply

  108. Hi Chris,

    First of all KUDOS on your great wrapper!
    It’s really awesom(ium)….

    I would appreciate your help with the following issue:
    In general, when I browse to non-flash websites, I get pretty good results performance-wise.
    Trying to browse to flash websites is a different story…
    While the flash websites themselves load just fine, the cpu load is extremly high.
    For example-
    http://www.blizzard.com (a heavy flash based website),
    steadily consumes between 40%-50% cpu…
    I should mention that I’m using a modern quad-core computer runnig windows-7.
    When browsing to the same website using other borwsers (IE8/Firefox/Chrome), I get about 20%-25% cpu load – about a half…

    Is this a known issue? if so, is it related to your wrapper or to the awesomium?
    Is the performance dependent on the type of flash plugin installed in the system?
    Should the new version (1.6) of awesomium improve the situation?
    I’ve done some research, and it seems there is some bug in the writableBitmap class in Dot.net 3.5, that might affect performance – do you happen to know anything about this?

    Sorry for bombarding you with all these questions…
    Thx again for your hard work!

    yanco

    Reply

  109. yanco – my understanding is that this is not due to the wrapper but to awesomium. The reason being that the technical solution relies on rendering the browser to a bitmap in memory and then copying the part of the bitmap that has changed into an image that is then rendered by the graphics card. This means that when you are rendering an image of the entire browser, you can apply nice effects like the one Chris demonstrates so well with his wrapper.

    This all works splendid when the web page is having few changes, but if the page is having a lot of changes, you will end up copying a lot of bits around in memory. This is a pure CPU task and that is why you see large spikes in CPU utilization.

    As far as I can tell, there is really no way around it. This is the price you must pay to be able to do fancy GPU manipulations like the one WPF allows you do to.

    Possibly there is one way to get it faster, and that is to bypsass WPF alltogether, and write this direct to the GPU using DirectX. You could consider doing this is C++ or if that is too tricky for you do it in C# with SlimDX. I have had very positive experiences with SlimDX. It is a truly stable framework. Awesomium however has a lot of small errors errors here and there, but it is a much younger product and will likely mature and get a lot better quickly.

    Reply

  110. yanco/Anders – There is a known bug in 3.5’s WriteableBitmap that could be influencing things. I was going to wait for Awesomium 1.6 before updating, but it might be worth updating it now and converting to .NET 4 at the same time…

    Reply

  111. Chris/Anders – Thank you for your quick responses!
    I will try to upgrade to .NET 4 and report the results.
    Regarding the technical side- do you actually render only the part of the bitmap that changed,
    or is the entire bitmap rendered?

    Reply

  112. Yanco – while I don’t KNOW the answer, I believe that one of the nice properties of awesomium is that like in remote desktop & VNC, only the portion of the browser thast changed is updated. I don’t know if Chris implemented that in the wrapper, but I suspect it. If only the portion changing is updated, that would explain why flash is resulting in poor performance, as the whole section of the page with the flash will have to update even if only a small section of the flash window changed. Reason being, that the flash is seen by awesomium as ONE component, and hence result in a large overhead for small changes. A better system for bitmap based browsers would require deep integration into flash, and properly not possible without talking with Adobe. (maybe google is talking with them about that……who knows)

    Reply

    1. Rafa – The wrapper is currently built against Awesomium 1.5.1. When Awesomium 1.6 is released (it’s been alpha for some time) it’ll be using the latest version of Chromium, which has much better HTML5 support.

      I recommend you contact Adam at http://www.khrona.com/ and find out when the next Awesomium release will be 🙂

      Reply

  113. Hello,

    nice work here, Chris. I was wondering on a couple of issues.. One of awesomium features is “Custom-Response Pages” that allows to configure a custom page to be displayed in case of server error codes. Is there anyway to access this feature through your wrapper ? Also, if the source property it set to a local file url, like “file:///c:/Documents/….”, and the local file doesn’t exist, is there anyway to be notified ?

    Thanks,
    Francisco

    Reply

    1. Francisco – It’s likely I’ll wait until Awesomium 1.6 is released before I change the wrapper, but it’s pretty trivial to do if you don’t mind working with the source a little. All you need to add is a thin wrapper in AwesomiumWrapper.h (use an existing method for an example of string marshaling etc) and a corresponding method in WebBrowser.cs. Let me know if you want me to add you as a project developer on CodePlex – http://wpfchromium.codeplex.com 🙂

      Reply

  114. Hello Chris,

    thank you for the proposal. I think i’ll accept it. I’m considering using your code so i’ve been testing it. I have found a couple of issues here. Maybe you would like to discuss them.

    Francisco

    Reply

  115. Nice work, Chris! I have a problem here. It does not support Asia language input. Do you have any suggestions?

    Reply

  116. Hi Chris,
    I am using your component to load html and flash banners into a WPF app and integrate them correctly in my UI. I am facing the following problem: the flash banners slow down the UI significantly and make it unresponsive for a couple of seconds.

    After some research, I discover that I cannot create multiple threads on a single WPF window so this is a no go but I was wondering if it was possible to force the “writeablebitmap” control itself to run on a separate thread… Is it possible? do you happen to know how to do that?:-)

    Thanks

    Reply

    1. Hi benjoTLV – Awesomium supports an asynchronous rendering mode (and WebBrowser exposes it). Have you tried that? The downside would be Awesomium would no longer send “partial” view updates (so the whole WriteableBitmap would be refreshed).

      As for threads, you could certainly keep Awesomium on a separate thread but any accesses/updates to WPF controls would need to be marshaled to the UI thread. You can do this using Dispatcher.BeginInvoke (WebBrowser uses this for for a few things).

      Or we could follow the iDevice example and just not support Flash 🙂

      Reply

      1. Thanks Chris for the advice but I really need flash :-)!
        BeginInvoke worked but getting user interaction with it makes the solution an overkill… I think I can live with the rendering delay for now!
        Hopefully 1.6 will be fast enough so the UI freeze will be less noticeable.
        Did you decide about using 1.6 Beta? I think final 1.6 is not planned before at least a month.

        Thanks

  117. I’m having difficulties trying to integrate this into a project. What do I need, and what do I need to do with it? I’d love to build a project or two using this control. 😉

    Kudos for the work man!

    Reply

    1. dawmail333 – For WPF, you’ll need to reference Cjc.ChromiumBrowser and Cjc.AwesomiumWrapper. You’ll also need to make sure the C++ DLLs are in the same folder at runtime (Awesomium.dll (Awesomium_d.dll if a debug build) and icudt38.dll).

      I’ll have another version publiished soon that uses .NET 4 and Awesomium 1.6 (currently beta); it has several more external dependencies, but that should gain you process isolation 🙂

      Hope this helps!

      Reply

      1. Thanks, I think I’ll wait for that. I couldn’t get it to work in VS2010 though, even at design time.

      2. Can we pleeeeeeasssssee get designer-friendliness? It just keeps on giving me a ‘file not found’ exception whenever I try to use the designer with one of these controls…

        On the plus side, it’s simply _AWESOME_ for a project I’ve been meaning to do!

      3. Thank you!

        It’s not as easy in VS2010 though, because they deprecated that method in the post. I ended up having to add an entry to the system ‘PATH’ variable, and put the DLL’s in there. Didn’t work until I restarted the computer though.

    1. Mr Yang – (Sorry for earlier reply; posted to the wrong place). Yes it’s possible to interact [indirectly] with Silverlight content from the control by injecting/running Javascript on the page (see WebBrowser’s ExecuteJavascript methods). From there you could call methods exposed by the Silverlight app, and possibly access named elements in the Silverlight object tree.

      Reply

  118. Hi Chris,

    You have one of the longest Comments I have ever seen.

    with the IE Webbrowsercontrol I can get its HTMLDocument as an object.

    is that exposed here?

    Reply

    1. David – The object model isn’t exposed directly, but you can invoke Javascript functions and set up callbacks fairly easily… What are you wanting to do?

      Edit: Yeah the thread is getting pretty long… At this rate we’ll need a forum 🙂

      Reply

  119. Hi Chris, and wow thanks for replying so quick.

    I agree a forum could be in order. I most likely will be using this as I want a transparent, windowstyle = none form and currently the Webbrowser control seem to go transparent too.

    Thus I am currently moving everything accross.

    I use the HTMLDocument for things like scrolling in the webpage and removing the scrollbars eg with the webbrowser control

    myWB.Document.documentElement.style.overflow = “hidden”

    myWB.Document.body.Scroll = “no”

    myWB.Document.parentWindow.scrollBy(0, mouse_x)

    Thanks in advance David

    Reply

    1. David – You could call all those with the ExecuteJavascript method (just one string separated by semicolons should work). FYI something to be aware of with Awesomium 1.6 I’ve noticed – although it has a SetTransparent option I’ve not been able to get it working properly yet… Is this a feature you depend on? (I could be using it wrongly or it could be an Awesomium 1.6 bug… either way shouldn’t be impossible to resolve).

      Reply

  120. Hi Chris,

    I am not sure I understand this “just one string separated by semicolons should work” but let me try it when I am home first.

    I see you are keen to get your wrapper going well. That is great. I dont think you have anything to worry about the transparency.

    By transparency I mean where the mainwindow is made transparent. From what I understand (limited) the IE Webbrower is made a child of the mainwindow. As the main window is transparent so too is the child. Thus MS did not make a real WPF Webbrowser control they just used the old one with all its warts and legacy problems.

    I have already tested a c# example (os u2consult i htink) where I made “AllowsTransparency=”True”” of the main window and sure enough IE is made transparent but Chromium is still there YEH.

    I do have one other thing to work on and that is I want to make Chromium work with a proxy so that I can take my resulting app to work as well. At work we have IE and it has proxy settings. But lets see what I can do about that.

    Reply

  121. Brilliant stuff, but I’m now faced with being slugged $5000 to have an actual browser in my WPF app because Microsoft is lazy. ARGH!

    Reply

  122. Hey Chris,

    awesome work! Thank you very much for sharing it with the community.

    I have a question regarding the licensing topic:
    As far as I can tell your latest release only is compatible with Awesomium v1.6.

    Is that correct?

    The latest changeset which is compatible with Awesomium v1.08 (which is the last LGPL version of Awesomium) is 36744. Right?

    You’re not maintaining a separate branch that is compatible with v1.08 as well, are you? Do you think your latest changeset will compile against 1.08?

    Thank you for your time,
    Kevin

    Reply

    1. Kevin – I’m only maintaining the latest version (and then only minimally; help is always appreciated). It’d be great if someone wanted to branch the LGPL-based version and run with that, but it’s unlikely to be me… Are you volunteering? 🙂

      Reply

      1. Unfortunately 1.08 does not support the callback functionality satisfying… therefore it is not an option anymore and we have to stick with 1.6.

  123. Just posted this somewhere else on this page.. sorry if I repost:

    Is it possible to retrieve the DOM of a loaded page? Thank you

    Reply

    1. Kevin – You can call javascript methods on the page through the WebBrowser, and you can register callbacks that the page can call… Only simple values (and maybe small objects as a dictionary) get passed.

      If you’re working with the older version (and LGPL Awesomium source) you might have more options and be able to manipulate the DOM a bit more…

      Reply

      1. Hey Chris,

        how exactly does that work? Could you give me a simple example?
        Let’s say I only want to execute javascript in the website which returns a simple string back to my browser.

        At first I would go with the LGPL version of Awesomium. As soon as I find features in your latest versions that are not available in the older ones I will update them and inform you about the changes.

        Kevin

      2. For anyone else who is looking into this, here is how to get DOM access:

        browser.Callback += (s, args) =>
        {
        var c = args; //do whatever you like

        };

        browser.CreateObject(“YourObject”);
        browser.SetObjectCallback(“YourObject”, “YourCallback”);

        string js = “var meta = document.getElementsByTagName(\”meta\”);”;
        js += ” YourObject.YourCallback(meta.length);”;
        browser.ExecuteJavascript(js, string.Empty);

        Kevin

  124. Hi Chris,

    First of all: thanks for making the excellent (or should I say.. awesome!) WPF wrapper for Awesomium. I haven’t gotten it to compile with VS2010 yet, but I’m sure this can be figured out when the time comes.

    For now I only have one question: suppose we want to employ (multiple) Chromium browsers on a single multi-touch display, do you know if there is a way for us to detect that the user has clicked on an edit control (or editable combobox) so that we can pop up an on-screen touch-keyboard?

    Best regards,
    Lex

    Reply

    1. Lex – FYI there’s a VS2010 version on Codeplex (http://wpfchromium.codeplex.com/releases/view/49484), although it’s based on Awesomium 1.6 beta and still has a few bugs.

      I’ve had a few requests for input & focus notifications/events. Ideally this would be provided by Awesomium itself, so it’s probably worth posting the question on the Awesomium support forum (http://support.awesomium.com). However, it might also be possible by running a bit of Javascript (through WebBrowser’s ExecuteJavascript method) to attach a callback to all the input elements on the page… I’ve not tried this, but it might work 🙂

      Reply

  125. I converted my dll that creates the WPF Chromium WebBrowser to VS2010 – & I am linking in to the awsomium & cjc.ChromiumBrowser dlls I keep crashing at the following line when I enter in a URl & it navgiates to it:
    browser.Navigate(GetUrl());
    When I debug I get into the dll code & here is where it crashes:
    if ( webView != null ) webView.LoadURL( url );
    Any suggestions

    Reply

  126. I wish I had a callstack , I did try taking down the latest release but was unable to get it running -Any other suggestions would be greatly appreciated – it definately appears to be some configuration issue – but not sure

    Reply

  127. Hi Chris,

    Absolutely marvelous work! I know the work horse is Awesomium but nevertheless, all I have seen is absolutely brilliant.

    I wanted to adapt your 2D WPF browsing to a sample app of my own but I am having several serious issues. I would appreciate it if you could comment on them.

    1. First of all, none of the sources I have downloaded seem to contain Awesomium sources. Basically, nothing will build without those and even though you say these are also included, there are none. I thought this was not a big problem as I knew where to look but none of the Awesomium sources I have tried built everything correctly. I get build errors in the wrapper. So, how to get the correct version of Awesomium sources in order to build WPF browser? I can only assume you removed them because of licensing issues.
    2. I want to build my own copy because I am having trouble with just merely using binary version. From the user perspective WebBrowser works perfectly but I am having trouble specifically with WebBrowser.Cursor property (actually UIElement.Cursor). When I run the app, all is well and visual cursor changes appropriately as I hover over various page elements. But if I try to bind to Cursor property for my own purposes, it is “null” at first and immediately as the actual mouse cursor changes, it turns to Cursors.None – and stays that. Still, the visual cursor is updated correctly. What is the cause of this discrepancy?
    3. Is there any way of distinguishing background from an input text box and a link, other than interpreting Cursor property.

    Thanks!

    Reply

  128. Hi Chris,

    I’m using WPF Chromium v4.0 and I can’t change the input language to a foreign language like Asian and middle eastern languages, I also tried Navidemo and it’s the same. Do you have any input on this matter? where should I continue research?

    Thanks!!!

    Reply

  129. Hey Chris

    I’ve been looking for a wpf browser for a while now and I got very excited when i stumbled upon your blog, I downloaded all the code and Awesomium1.6 RC2. I get the following errors when i build:

    Error 1 error C2259: ‘CjcAwesomiumWrapper::DelegatingWebViewListener’ : cannot instantiate abstract class c:\projects\libraries\cjc.chromiumbrowserdemo\cjc.awesomiumwrapper\Cjc.AwesomiumWrapper.h 449 1 Cjc.AwesomiumWrapper
    Error 2 error C2039: ‘zoomIn’ : is not a member of ‘Awesomium::WebView’ c:\projects\libraries\cjc.chromiumbrowserdemo\cjc.awesomiumwrapper\Cjc.AwesomiumWrapper.h 816 1 Cjc.AwesomiumWrapper
    Error 3 error C2039: ‘zoomOut’ : is not a member of ‘Awesomium::WebView’ c:\projects\libraries\cjc.chromiumbrowserdemo\cjc.awesomiumwrapper\Cjc.AwesomiumWrapper.h 818 1 Cjc.AwesomiumWrapper
    Error 4 error C2661: ‘Awesomium::WebCore::WebCore’ : no overloaded function takes 6 arguments c:\projects\libraries\cjc.chromiumbrowserdemo\cjc.awesomiumwrapper\Cjc.AwesomiumWrapper.h 878 1 Cjc.AwesomiumWrapper

    I am guessing its bc I downloaded the RC2 version of Awesomium instead of RC1 but I couldn’t find RC1 in their site anymore….Do you have any ideas how I can get around the errors?

    thanks!

    Reply

  130. Hi Chris,
    I use the .NET 4.0 version of the Webbrowser. Regardless I get the same error as Andrea.
    “Error 1 error C2259: ‘CjcAwesomiumWrapper::DelegatingWebViewListener’ : cannot instantiate abstract class ”
    It’s a pitty that the compilation of the project is so COMPLETELY FRUSTRATING.

    Reply

    1. the solution to your problem is missing the implementation of some methods in the file Cjc.AwesomiumWrapper.h. These methods are:
      – RequestDownload
      – RequestFileChooser
      – GetScrollData
      – JavascriptConsoleMessage

      implementation is a bit tangled so I leave the class code to only copy and paste.

      Go to see in post Rtylerdurden http://wpfchromium.codeplex.com/discussions/227902. there I leave a complete code

      Greetings

      Reply

  131. Hi Chris,

    How can I interact with the web page like click on a link or type a work into a textbox. I see your demo can do it but I cannot make it work.

    Thanks.

    Reply

  132. Hi Chris,

    We made all efforts to try the latest Awesomium and the AwesomiumSharp Wrapper that comes with it (as mentioned in your Update 3), but their code is buggy as s*** – exceptions all over the place, even in simplest scenarios, random VS crashes… We have the impression that Awesomium gets worse with each release (actually, my team only refers to it as “Awfullium”, by now).

    Any good/suggested way for going back to your WPFChromium wrapper and Awesomium 1.5? That seems to be the latest halfway stable version.

    Thanks, Guido

    Reply

    1. gstercken – Sorry you’re having trouble with Awesomium 😦 I’ve not used it for a while so didn’t realize it was buggy. If you can find a copy of Awesomium 1.5.1 somewhere, it should be possible to get the .NET 3.5 version of my wrapper working: http://wpfchromium.codeplex.com/. It was pretty stable, but obviously won’t have much in the way of HTML5 support.

      Have you tried some of the alternatives like Troymium?

      Reply

  133. Hi Chris,
    Do you still support about your project.

    I just download your project, download and install Awesomium 1.66.

    But When I build the project Cjc.AwesomiumWrapper, just only this project, on VS 2008, net framework 3.5 version. I get the same error as Tom.

    Error 1 error C2259: ‘CjcAwesomiumWrapper::DelegatingWebViewListener’ : cannot instantiate abstract class e:\surface sdk\cjc.chromiumbrowserdemo (.net 4.0)\cjc.awesomiumwrapper\Cjc.AwesomiumWrapper.h 504 1 Cjc.AwesomiumWrapper

    Could you help me to fix this library?

    Thanks,
    Phong.

    Reply

    1. Phong – This is a pretty old project and I doubt it’ll work with the latest Awesomium version. Have you tried using the .NET Wrapper included with Awesomium? It’ll have much more functionality than this one…

      Reply

      1. Hi Chris,

        Right now, my problem is that we have project build by ms surface 2.0, and I try to add the web browser awesomium to surface, but I cannot

        I already reviewed some projects in Wrapper, and I tried to use the AwesomiumSharp project to build the library dll, then add to my project (add a window (WPF) to surface), but it caused error.

        If I use your projects to build library Cjc.AwesomiumWrapper, it will happen the above error.

        Can you help me to solve the problem??

        Thanks,
        Phong.

  134. Phong – Awesomium (and the Cjc.AwesomiumWrapper assembly) both need VS2008 to compile successfully (this is actually a Chromium restriction as I recall). After this the assemblies can be used in VS2010 projects.

    Reply

  135. Hi Chris,

    On Awesomium.net, the error is throw XAMPParserException, when I tried to add the window or control into surface file.xaml (not window).

    And about the Awesomium, I built the project on VS2008 with net framework 3.5, but I received the error on file Cjc.AwesomiumWrapper.h, in constructor method of WebViewListener class, the detail of error is Error 1 error C2259: ‘CjcAwesomiumWrapper::DelegatingWebViewListener’ : cannot instantiate abstract class.

    Can you help me here?

    Thanks a lot,

    Phong.

    Reply

    1. Phong – Not sure why you’re getting the XAMLParserException. I’ve created an updated version of my project that uses Awesomium 1.6.6 (it assumes you’ve run the Awesomium installer you’ve installed to the default location under Program Files). You can get the source & binaries here: http://dl.dropbox.com/u/6684256/Blog/Cjc.AwesomiumDotNetDemo.zip

      Let me know if this works or not (requires VS2010). It *should* do almost everything the previous demo did (rotation, effect etc). I wasn’t able to get Flash running, but then the standard Awesomium.net demo didn’t show Flash either (I didn’t dig into it).

      Reply

  136. I got the below error when i build the latest source. ‘Cjc.ChromiumBrowser.WebBrowser’ does not contain a definition for ‘EnableAsyncRendering’ D:\Bowser\youcube3-76924\Window1.xaml.cs 179 5 Cjc.Chromium3D

    Could you please help?

    Reply

Leave a reply to gstercken Cancel reply