Quick Start Guide for Binary Release of CefSharp?

5,695 views
Skip to first unread message

Nicholas Pappas

unread,
Nov 13, 2012, 6:15:57 PM11/13/12
to cefs...@googlegroups.com
I downloaded the latest stable binary release and am trying to include a simple browser window in my WPF application.  Unfortunately I've not found any documentation on which DLLs I need to include (just CefSharp.Wpf?) and how to include the web viewer.

Currently I am including CefSharp.Wpf, and trying to create an instance to the WebView control.  I'm getting several errors, which I'm assuming are coming from a need to include additional references or my lack of setting something up.

What do I need to do in order to just provide a simple browser view in my WPF application?

Thank you.

anthony...@gmail.com

unread,
Nov 13, 2012, 6:21:20 PM11/13/12
to cefs...@googlegroups.com
Information on runtime files is here: https://groups.google.com/d/msg/cefsharp/sgQY_9omyd4/mRQYSCEPePkJ
> --
>
> You received this message because you are subscribed to the Google Groups "CefSharp" group.
>
> To view this discussion on the web visit https://groups.google.com/d/msg/cefsharp/-/nJsRcwRgruUJ.
>
> To post to this group, send email to cefs...@googlegroups.com.
>
> To unsubscribe from this group, send email to cefsharp+u...@googlegroups.com.
>
>
> For more options, visit this group at http://groups.google.com/group/cefsharp?hl=en.
>
>
>
>

Nicholas Pappas

unread,
Nov 13, 2012, 6:45:06 PM11/13/12
to cefs...@googlegroups.com
I've read the post and added "CefSharp" and "CefSharp.Wpf" to my References, but "icudr.dll" and "libcef.dll" will not load into References.  How should I reference them in Visual Studio?  Currently I just copied them over to my Debug directory.

In the control I'm including the browser window in I added this to the constructor:

            var settings = new CefSharp.Settings
            {
                PackLoadingDisabled = true,
            };

            if (CEF.Initialize(settings))
            {
                // instantiate your WebView here
            }

In the XAML I include the namespace:

xmlns:cs="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"

and then the control:

<cs:WebView x:Name="ContentBrowser" />

In my XAML I get the following error:

Error 21 The type 'cs:WebView' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

Is this because not dealing correctly with  "icudr.dll" and "libcef.dll", or am I missing something else?

Thank you very much!

anthony...@gmail.com

unread,
Nov 13, 2012, 6:50:43 PM11/13/12
to cefs...@googlegroups.com
On , Nicholas Pappas <nwpa...@gmail.com> wrote:
> I've read the post and added "CefSharp" and "CefSharp.Wpf" to my References, but "icudr.dll" and "libcef.dll" will not load into References.  How should I reference them in Visual Studio?  Currently I just copied them over to my Debug directory.

Yeah they just need to be in the same directory as the .exe that you are building and running. As for the XAML, Visual Studio's designer can't add controls from assemblies that contain a mix of managed and unmanaged code. You will have to instantiate the WebView control and add it to your view hierarchy programatically. Take a look at the CefSharp Wpf example app.

--Anthony

Nicholas Pappas

unread,
Nov 13, 2012, 7:12:34 PM11/13/12
to cefs...@googlegroups.com
I'll start to take a closer look at it.  The reference to CefSharp.Example and the ExamplePresenter have thrown me at the moment -- lots of stuff going on.

My application is dead simple at the moment, just needing to load a saved URL into a browser and let it display (no interaction).  Is there an example you know of out there that shows this?

Thank you.

anthony...@gmail.com

unread,
Nov 13, 2012, 7:22:23 PM11/13/12
to cefs...@googlegroups.com
Oh, my bad. It's the WinForms control that doesn't work in the designer. Example of inserting the web view into a xaml layout is here: https://github.com/ataranto/CefSharp/blob/master/CefSharp.Wpf.Example/MainWindow.xaml#L49


On , Nicholas Pappas <nwpa...@gmail.com> wrote:
> --
>
> You received this message because you are subscribed to the Google Groups "CefSharp" group.
>
> To view this discussion on the web visit https://groups.google.com/d/msg/cefsharp/-/Gdncl4bmDnMJ.

Nicholas Pappas

unread,
Nov 13, 2012, 8:58:12 PM11/13/12
to cefs...@googlegroups.com
I'm still getting some errors that are stumping me.

I still get the following error in my XAML, concerning the CefSharp.Wpf DLL:

Error 19 Unable to load the metadata for assembly 'CefSharp.Wpf'. This assembly may have been downloaded from the web.  See http://go.microsoft.com/fwlink/?LinkId=179545.  The following error was encountered during load: Could not load file or assembly 'CefSharp.Wpf, Version=1.19.0.41833, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

I've gone to the website listed and followed the instructions, but still it appears.  The error refers to unlocking the DLL from the file's Property dialog.

When I attempt to run in Debug mode (it will try to run, not just stop me on an error), I get an exception coming from the class where the WebView is defined.  In my XAML I declare it:

<cs:WebView x:Name="ContentBrowser" />

Then in the constructor I call the initialization:

var settings = new CefSharp.Settings
{
    PackLoadingDisabled = true,
};

if (CEF.Initialize(settings))
{
    // instantiate your WebView here
}

When the control is loaded an exception is thrown from the constructor.  It doesn't give me any specifics.

Am I still missing something?  Do I have to use a presenter class (like the CefSharp.Example), or am I missing a different setup step?

Thank you for your help!!

anthony taranto

unread,
Nov 13, 2012, 9:46:55 PM11/13/12
to cefs...@googlegroups.com
No, the presenter class is just a way to share code between my Wpf and WinForms example apps.

Please send me a listing of the directory that contains your .exe file after you have built your application and before you try to run.

--
You received this message because you are subscribed to the Google Groups "CefSharp" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cefsharp/-/BOR_vReQjVcJ.

Nicholas Pappas

unread,
Nov 13, 2012, 10:36:09 PM11/13/12
to cefs...@googlegroups.com
Success... almost!  I was able to get it running in a new application all by itself.  I moved the appropriate code over to my destination app and...

System.BadImageFormatException was unhandled
  Message=Could not load file or assembly 'CefSharp, Version=1.19.0.41824, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

After looking around it sounds like this is caused with a different in x86 and x64 platform.  Do I need to be running in x86?

I am using the MVVM Light framework, which doesn't seem to like me changing that stuff around.  I tinkered with some of the x86 settings and my BadImageFormatException went away, but several other pieces of my application choked.  *sigh*

What can I do to get around this error, if anything?

Thank you again!

Nicholas Pappas

unread,
Nov 14, 2012, 12:30:29 AM11/14/12
to cefs...@googlegroups.com
Got it!  Almost...

I had to create a new application in Visual Studio and slowly import all my files, so I could run it as an x86 application.  I don't know why my old project refused to let me do that, but everything is loading up now.

My last (gosh, I hope) is loading a local file.  Can I do this?  I've been able to load a remote file, but the file I want to load is local to the application directory.  I'd like to use it if possible.

Thank you for all the help!!

Nicholas Pappas

unread,
Nov 14, 2012, 1:15:24 AM11/14/12
to cefs...@googlegroups.com
... and my local file is loading!  Woohoo!

Thank you for the help.

Jibin Mathew

unread,
Feb 20, 2013, 1:02:32 AM2/20/13
to cefs...@googlegroups.com
Hi Nicholas Pappas , I ma still getting the error "Unable to load assembly......". Steps i followed 
-> Open new project  (framework -4 )
->  Copy 2 dlls icudt,libcef to bin folder .
->  Add reference to 2 dll CefSharp.dll and CefSharp.WPF.dll 

But when i add xmlns:cs="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf" to xaml it shows error . How to you get out of it? It would be nice to attach a sample project also PLease help to get out of it

Brandon Peterson

unread,
Jul 29, 2013, 10:25:28 PM7/29/13
to cefs...@googlegroups.com
Any chance you might share your dead simple solution? I have the same need and since the github site (from what I can tell) lacks a basic get started doc or class overview, I'd hope to avoid all the trouble you went through. I realize this thread is a bit old, but still relevant. Thanks!

Per Lundberg

unread,
Jul 30, 2013, 1:00:38 AM7/30/13
to cefs...@googlegroups.com
Hi,

One, reasonably easy way:

1) Download the binary release (or download the source from Github, it's quite stable if you take the master branch which is the default).
2) Set the startup project to be either CefSharp.WinForms.Example or CefSharp.Wpf.Example (right click in Visual Studio).
3) Press F5 to run it.
4) Look in the top-most folder under Debug (or Release), depending on which configuration you are running. There you see the list of files needed (including libcef.dll, icudt.dll etc). CefSharp.Example.* is the stuff you can delete; basically everything else is what you will need.

The trouble with this is that when you make a project of your own, you basically have to make sure these files are copied in to your bin\Debug folder. This can reasonably easy be done using a post-build command (xcopy) or similar.

We all know the instructions for a "quick start" with CefSharp isn't that great at the moment. If anyone wants to write a better "quick start" guide, please do so, and add it to the wiki (it should be publicly editable). Hopefully we will be able to simplify this process a lot in the future when we adopt NuGet.

Best regards,
Per

Tad Vinci

unread,
Aug 18, 2013, 5:46:11 PM8/18/13
to cefs...@googlegroups.com
I tried the steps below and get an error of "A first change exception of type 'System.Runtime.InteropServices.COMException' occured in Microsoft.VisualStudio.HostingProcess.Utilities.dll with version 1.2.5.3. I'm using visual studio 2012.

I also tried creating a new project with .net 4.0 since it doesn't sound like cefsharp works with 4.5? I'm using vb.net. I added "CefSharp" and "CefSharp.Wpf" to  References. I copied the libcef.dll and icudt.dll per the FAQ. I also tried to include xmlns:cs="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf" in the xaml, but it complains that it can't find the reference for some reason. Instead I just did the following in the code-behind - just trying to make it work:

Imports CefSharp
Class MainWindow

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Dim settings As New CefSharp.Settings
        settings.PackLoadingDisabled = True
        If CEF.Initialize(settings) Then
            Dim web_view As New CefSharp.Wpf.WebView
            grid1.Children.Add(web_view)
        End If

    End Sub
End Class

I get the following error when trying to debug.
'The invocation of the constructor on type 'WpfCesSharp4._0.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '5'.

per.lu...@ecraft.com

unread,
Aug 20, 2013, 1:49:07 AM8/20/13
to cefs...@googlegroups.com
Hi,

That's a bit weird. Does it work when you run the .exe files in the 1.25.3 Release folder? (using the .zip with the binary release)
I mean, can you run the CefSharp.Wpf.Example from there?

Best regards,
Per

Tad Vinci

unread,
Aug 20, 2013, 6:03:15 PM8/20/13
to cefs...@googlegroups.com
The exe in the release folder works. The screen is a bit fuzzy on it but I assume it's because of the item that is over-layed.

Per Lundberg

unread,
Aug 22, 2013, 1:26:06 AM8/22/13
to cefs...@googlegroups.com
OK. What is the exact number of files in your project's bin\Debug folder, after building in Visual Studio? Please provide a full list of all the files.

Best regards,
Per

Tad Vinci

unread,
Aug 24, 2013, 8:25:45 AM8/24/13
to cefs...@googlegroups.com


Files in folder:

CefSharp.dll
CefSharp.Wpf.dll
icudt.dll
libcef.dll
WpfCesSharp4.0.exe
WpfCesSharp4.0.pdb
WpfCesSharp4.0.vshost.exe
WpfCesSharp4.0.vshost.exe.manifest
WpfCesSharp4.0.xml

Errors in Immediate window:

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.VisualStudio.HostingProcess.Utilities.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
A first chance exception of type 'System.Xaml.XamlObjectWriterException' occurred in System.Xaml.dll

Application.g.vb
    '''<summary>
    '''Application Entry Point.
    '''</summary>
    <System.STAThreadAttribute(),  _
     System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
     System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")>  _
    Public Shared Sub Main()
        Dim app As Application = New Application()
        app.InitializeComponent
        app.Run ##############This is highlighted
    End Sub

Error in popup

'The invocation of the constructor on type 'WpfCesSharp4._0.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '5'.



Per Lundberg

unread,
Aug 25, 2013, 3:57:04 PM8/25/13
to cefs...@googlegroups.com
Hi,

Please try to add the "locales" folder with a en-US.pak file, to see if it makes any difference.

Best regards,
Per

Tad Vinci

unread,
Aug 27, 2013, 7:45:08 AM8/27/13
to cefs...@googlegroups.com
Nope, still not working.

Per Lundberg

unread,
Aug 28, 2013, 4:05:53 PM8/28/13
to cefs...@googlegroups.com
OK. Try using procmon.exe to see if it gives you any ideas. Also, the Visual Studio exception details (expanding on the exception object when you get this exception) might give any hints.
If you like, you can also publish your project somewhere on the web so that someone of us could take a look at it and try it for ourselves. CefSharp works for a lot of people so I'm quite sure we will be able to resolve this.

Best regards,
Per

Tad Vinci

unread,
Aug 30, 2013, 3:41:22 PM8/30/13
to cefs...@googlegroups.com
I'm sure it works. I'm new to WPF so I could have easily messed something basic up. I've been using geckofx but they don't really have a solution for wpf. I've posted it here http://sourceforge.net/projects/cefsharpexample/   Does cefsharp work with .net 4.5 or still just 4.0?

Per Lundberg

unread,
Sep 3, 2013, 3:30:50 PM9/3/13
to cefs...@googlegroups.com
Hi Tad,

I checked your project - it turned out you didn't examine the exception details carefully enough. When I got that same XamlParseException that you did, I clicked "View Detail". I then expanded the exception object and saw that the InnerException had this message in it "{"Could not load file or assembly 'CefSharp, Version=1.25.0.25466, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."}"

This is caused by the program being compiled for "Any CPU" but CefSharp is (for the moment) x86 only. So you need to modify under "Compile" in the Project Properties the "Target CPU" and set it to x86.  Then you will get the following exception instead. ;)

{"Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.":Nothing}

The reason for this is exactly as it said - that version of CefSharp (1.25.0) is .NET 2.0 only. Try upgrading to CefSharp 1.25.3 instead and it should work better.


Oh, one more thing, very much off-topic but nonetheless... I really recommend against using VB.NET as the programming language of choice. Of course you can use it if you like, but the vast majority of .NET applications are written in C# and I think people in general tend to favor it over VB.NET. I tend to refactor VB.NET applications written by other people to C# whenever I have the opportunity... :)

Best regards,
Per

Tad Vinci

unread,
Sep 3, 2013, 7:32:22 PM9/3/13
to cefs...@googlegroups.com
It works! Thanks. When I see the browser, everything is kind of fuzzy is there someway to fix that? I tried UseLayoutRounding="True" and RenderOptions.BitmapScalingMode="NearestNeighbor" on the window as mentioned here http://stackoverflow.com/questions/5645274/image-in-wpf-getting-blurry but it didn't work.

I would have never guessed it was .net 2.0. I would think that would be more than a minor X.XX.3 version upgrade. :) Will there be a .net 4.5 version soon? I had seen the incorrect format previously somewhere else too. It's good to know what that means now.

After going bracket-less and semicolon-less, it's hard to switch back. It reminds me too much of C. :)

Per Lundberg

unread,
Sep 4, 2013, 12:23:22 AM9/4/13
to cefs...@googlegroups.com
Hi,

Great that you got it working. The fuzziness I haven't seen myself actually, so that is quite strange. It could be that it has to be fixed in the actual WebView control (it has an embedded image which contains the rendered browser content). Do you get the same with the Wpf.Example provided with CefSharp? Anyway, feel free to make a GitHub issue about tha tone.

You're right that moving from 2.0 to 4.0 is a bit major to be taken in a "minor" point upgrade like 1.25.0 to 1.25.3. However, the versioning scheme is like this: 1 = CEF1 (as opposed to CEF3). 25 = Chromium 25 (as opposed to 27 or 29 coming up), and 3 = the fourth release (0 = the first) of that kind.

So, I don't really know what else it could have been numbered. :)

Regarding .NET 4.5; that is just a minor upgrade of the .NET 4 platform (like .NET 3.0 3.5 is a minor upgrade to .NET 2.0). You should be able to use .NET 4.0 controls in a .NET 4.5 app without problem. I don't think we can force .NET 4.5 on all our users yet.

Finally, regarding the language flame war which I initiated. ;) Of course, it's a matter of choice and personal preference and so forth. I think VB.NET code is a bit "noisy" and harder to read than C#. It gets too verbose and "English-like" in my mind. It's probably a bit of what you are used to, though. Use whichever language you prefer.

Best regards,
Per
Reply all
Reply to author
Forward
0 new messages