Could not load file or assembly 'CefSharp.dll' or one of its dependencies

Kien Dang Ngoc picture Kien Dang Ngoc · Aug 13, 2013 · Viewed 52k times · Source

I'm trying to use CefSharp to load my web app into winfoms. I've added 2 dll files: CefSharp.dll and CefSharp.WinForms into references and add 2 dll files icudt.dll and libcef.dll into my project through add existing items.
enter image description here

and this is the code from the form

public WebView web_view;

public Form1()
{
     InitializeComponent();
     web_view = new WebView("http://localhost:8084/wsmill",new CefSharp.BrowserSettings());
     web_view.Dock = DockStyle.Fill;
     toolStripContainer1.ContentPanel.Controls.Add(web_view);
     CefSharp.CEF.Initialize(new Settings());
}

When run the app, I got this error

An unhandled exception of type 'System.IO.FileLoadException' occurred in WindowsFormsApplication1.exe Additional information: Could not load file or assembly 'CefSharp.dll' or one of its dependencies. A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)

So anyone who know about this please help me, thanks

Answer

Toan Nguyen picture Toan Nguyen · Oct 29, 2013

You need to put these files

libcef.dll
icudtl.dat
CefSharp.dll
CefSharp.WinForms.dll

into your bin\Debug (or bin\Release, based on your configuration).

And please do not forget to install Visual C++ 2012 Redistribution (Visual C++ 2013 Redistributable since version 43). If you don't, Visual Studio will always display an exception saying CefSharp.dll is not found even though you already have it.