Configuring libcef.dll for CefGlue/Demo.WinForms build?

3,609 views
Skip to first unread message

R Bailey

unread,
Mar 6, 2013, 6:57:19 PM3/6/13
to cef...@googlegroups.com
I'm new to CEF, and was trying out Xilium, CefSharp, and even webkitdotnet (https://github.com/webkitdotnet/webkitdotnet), the last of which was pretty easy to get up and running.

Using Xilium, I ran into some issues figuring out how to configure the libcef.dll.

In CefRuntime.cs's Load() method, BuildRevision from the below snippet is doing one of two things.

var rev = BuildRevision;
if (rev != libcef.CEF_REVISION) throw ExceptionBuilder.RuntimeVersionMismatch(rev, libcef.CEF_REVISION);

Straight out of the box, it was throwing the following error:

System.DllNotFoundException was unhandled
  Message=Unable to load DLL 'libcef': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
  Source=Xilium.CefGlue
  TypeName=""
  StackTrace:
       at Xilium.CefGlue.Interop.libcef.build_revision()
       at Xilium.CefGlue.CefRuntime.get_BuildRevision() in D:\Projects\chromeige\xilium.cefglue\CefGlue\CefRuntime.cs:line 247
       at Xilium.CefGlue.CefRuntime.Load() in D:\Projects\chromeige\xilium.cefglue\CefGlue\CefRuntime.cs:line 81
       at Xilium.CefGlue.Demo.DemoApp.Run(String[] args) in D:\Projects\chromeige\xilium.cefglue\CefGlue.Demo\DemoApp.cs:line 46
       at Xilium.CefGlue.Demo.Program.Main(String[] args) in D:\Projects\chromeige\xilium.cefglue\CefGlue.Demo.WinForms\Program.cs:line 14
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

That makes enough sense; libcef isn't in there.

So I copied a version of libcef I had laying around (File version 1.1084.728.0) into...
\xilium.cefglue\CefGlue.Demo.WinForms\bin\Debug

... which seemed to be the best place for it.  I think it's found, but now I'm getting the second error...

System.BadImageFormatException was unhandled
  Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
  Source=Xilium.CefGlue
  StackTrace:
       at Xilium.CefGlue.Interop.libcef.build_revision()
       at Xilium.CefGlue.CefRuntime.get_BuildRevision() in D:\Projects\chromeige\xilium.cefglue\CefGlue\CefRuntime.cs:line 247
       at Xilium.CefGlue.CefRuntime.Load() in D:\Projects\chromeige\xilium.cefglue\CefGlue\CefRuntime.cs:line 81
       at Xilium.CefGlue.Demo.DemoApp.Run(String[] args) in D:\Projects\chromeige\xilium.cefglue\CefGlue.Demo\DemoApp.cs:line 46
       at Xilium.CefGlue.Demo.Program.Main(String[] args) in D:\Projects\chromeige\xilium.cefglue\CefGlue.Demo.WinForms\Program.cs:line 14
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:


I think, based on some Googling and stumbling over this post:
https://groups.google.com/forum/#!searchin/cefglue/xilium/cefglue/D5XL0uBY3MY/nx2RsfSZB9gJ

... that I've got the wrong version of libcef.dll.  So I'm pretending that I'm looking for 1102, since that's what libcef.CEF_REVISION evals to right now.

So I grab what looks like the right thing from cef_binary_3.1384.1102_windows_xilium.7z\Debug\ -- it's file version 3.1384.1102.0.

Same BadImageFormatException.  That makes some sense, since it's not like I was receiving the wrong version for the other libcef file; CefRuntime.BuildRevision didn't work.

Is the dll supposed to go somewhere else?  Seems that since it's found (and wasn't found before), that I'm okay there, even if placement is suboptimal.  Am I missing a reference?

Sorry for the dll n00bness; I'm usually a web or clean Windows.Forms .NET guy.  I haven't waded into C or dlls (past a little play with Noesis.Javascript.dll) since the VB6 and Dan Appleman days.

Thanks,

Ruffin Bailey

Dmitry Azaraev

unread,
Mar 6, 2013, 7:18:40 PM3/6/13
to cef...@googlegroups.com
Hi.

libcef.dll - it is x86 image. And looks like your's application targeted to any cpu, so it loaded in x64 arch.
Set in project properties x86 arch, like it done in sample applications.




--
You received this message because you are subscribed to the Google Groups "CefGlue" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cefglue+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Best regards,
   Dmitry

R Bailey

unread,
Mar 7, 2013, 9:12:57 AM3/7/13
to cef...@googlegroups.com, dmitry....@gmail.com
On Wednesday, March 6, 2013 7:18:40 PM UTC-5, Dmitry Azaraev wrote:

    libcef.dll - it is x86 image. And looks like your's application targeted to any cpu, so it loaded in  x64 arch.
    Set in project properties x86 arch, like it done in sample applications.

On Wednesday, March 6, 2013 7:18:40 PM UTC-5, Dmitry Azaraev wrote:

    libcef.dll - it is x86 image. And looks like your's application targeted to any cpu, so it loaded in x64 arch.
    Set in project properties x86 arch, like it done in sample applications.


Dmitry --

Thanks for the reply.

I did try setting to x86 earlier in the Configuration Manager, and after changing the "Active solution platform" to x86, I received the DllNotFoundException again.  

My Configuration Manager values (after changing to x86) read:

Active solution configuration:       Active solution platform:
Debug                                x86

Project                    Configuration  Platform
CefGlue                    Debug          Any CPU
CefGlue.Client             Debug          x86
CefGlue.Demo               Debug          Any CPU
CefGlue.Demo.WinForms      Debug          x86
CefGlue.Samples.WpfOsr     Debug          x86
CefGlue.WindowsForms       Debug          Any CPU


and the error's the same as no dll earlier:
System.DllNotFoundException was unhandled
  Message=Unable to load DLL 'libcef': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
  Source=Xilium.CefGlue
  TypeName=""
  StackTrace:
       at Xilium.CefGlue.Interop.libcef.build_revision()
       at Xilium.CefGlue.CefRuntime.get_BuildRevision() in D:\Projects\chromeige\xilium.cefglue\CefGlue\CefRuntime.cs:line 247
       at Xilium.CefGlue.CefRuntime.Load() in D:\Projects\chromeige\xilium.cefglue\CefGlue\CefRuntime.cs:line 81
       at Xilium.CefGlue.Demo.DemoApp.Run(String[] args) in D:\Projects\chromeige\xilium.cefglue\CefGlue.Demo\DemoApp.cs:line 46
       at Xilium.CefGlue.Demo.Program.Main(String[] args) in D:\Projects\chromeige\xilium.cefglue\CefGlue.Demo.WinForms\Program.cs:line 14
  InnerException:

Changing back to Any CPU does recreate the "System.BadImageFormatException was unhandled" error.

My first guess was that that means that I've got an x64 dll?  But this is the one I extracted from ~\cef_binary_3.1384.1102_windows_xilium.7z\Debug\  Tried running CorFlags, but no luck.  Perhaps CorFlags is for .NET dlls only.

D:\Projects\chromeige\xilium.cefglue\CefGlue.Demo.WinForms\bin\Debug>CorFlags libcef.dll
Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  3.5.30729.1
Copyright (c) Microsoft Corporation.  All rights reserved.

corflags : error CF008 : The specified file does not have a valid managed header


Anyhow, still stuck.  Thanks again for the help.

Ruffin Bailey

Wladimr Coka

unread,
Mar 7, 2013, 9:22:34 AM3/7/13
to cef...@googlegroups.com, cef...@googlegroups.com, dmitry....@gmail.com
The change to x86 was ok, but now the new debug folder might be different path so you need to copy the dlls to there now.

Sent from my iPhone
--

R Bailey

unread,
Mar 7, 2013, 10:21:23 AM3/7/13
to cef...@googlegroups.com, dmitry....@gmail.com, wla...@gmail.com

On Thursday, March 7, 2013 9:22:34 AM UTC-5, Wladimir Coka wrote:
The change to x86 was ok, but now the new debug folder might be different path so you need to copy the dlls to there now.

That was exactly the issue, thank you.  (Sorry Dmitry -- you're also right; I had neglected to mention that I'd installed libcef.dll into ~\xilium.cefglue\CefGlue\bin\Debug folder as well, so that was working fine.)

I did end up needing to add a fair number of dlls from the binary, which makes sense.  Just to get up quickly, I pulled pretty much everything from the binaries' Debug folder (to be clear, by "binaries", I mean the 7z file from the builds page: http://xilium.bitbucket.org/cefglue/ ) and dropped them all into ~\xilium.cefglue\CefGlue.Demo.WinForms\bin\x86\Debug (a folder from a Mercurial pull from here: https://bitbucket.org/xilium/xilium.cefglue )

Here's what I copied over in addition to libcef.dll:

avcodec-54.dll
avformat-54.dll
avutil-51.dll
cef.pak
d3dcompiler_43.dll
d3dx9_43.dll
debug.log
devtools_resources.pak
ffmpegsumo.dll
icudt.dll
libEGL.dll
libGLESv2.dll
locales (<<< folder)

It's coming up fine now, and seems to handle certs out of the box, something webkitdotnet wasn't doing for me automagically.

Thanks a lot for the help; I appreciate it.

Ruffin Bailey
Reply all
Reply to author
Forward
0 new messages