Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Could not load file or assembly 'CefSharp.Core.dll' or ..." when running CefSharp.Wpf.Example from another project #466

Closed
KennyKay opened this issue Sep 8, 2014 · 13 comments
Labels

Comments

@KennyKay
Copy link

KennyKay commented Sep 8, 2014

When I run the CefSharp.Wpf.Example project from another WinForms project , it crashes on the CefExample.Init() call even though all the necessary references are added.
I added the CefExample.Init() call in the constructor of the MainWindow.xaml.cs.

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in CefSharp.Wpf.Example.exe
Additional information: Could not load file or assembly 'CefSharp.Core.dll' or one of its dependencies. The specified module could not be found.

My main goal is to be able to show the Wpf CefSharp browser from a WinForms application using the WPF integration in WinForms (http://weblogs.asp.net/jdanforth/open-a-wpf-window-from-winforms):
var wpfwindow = new MainWindow();
ElementHost.EnableModelessKeyboardInterop(wpfwindow);
wpfwindow.Show();

It works fine when I start the CefSharp.Wpf.Example project although it doesn't work when running it from another project. The configuration of all project are set to x86 .Net 4.

Am I doing anything wrong or is it an issue?
Thanks.

@amaitland
Copy link
Member

Could not load file or assembly 'CefSharp.Core.dll' or one of its dependencies. The specified module could not be found

@KennyKay Can you confirm the bin folder for your project has all the supporting Cef libraries present? The error above is often misleading, typically seen when libcef or one of it's dependencies is missing.

@AaronLS
Copy link

AaronLS commented Sep 9, 2014

My suggestions for troubleshooting:
Clean out bin folder.
Go to nuget package manager and if there is a Restore option click it to force a package Restore.
Build project twice. Because the Core nuget package is referenced from the other packages, I find the first time I build I have to build twice.

As amaitland mentioned, make sure all the DLLs are present in the BIN of whichever project is actually the executing application as in your case the WinForms app you've made will need all the DLLs present in its bin folder. If it doesn't reference the nuget packages directly and is relying on the Wpf.Example references then the native DLLs might be getting copied to the Wpf.Example instead of your Winforms bin folder. You can have issues loading CefSharp.Core.dll if some of the native dlls are missing.

@KennyKay
Copy link
Author

KennyKay commented Sep 9, 2014

Thanks for your help guys.

Although, after adding the DLLs for the WinForms project, another bug appeared:
cefexecutecrash
An unhandled exception of type 'System.NullReferenceException' occurred in CefSharp.Wpf.dll
Additional information: Object reference not set to an instance of an object.

I made it work by commenting out the lines in the RaiseCanExecuteChanged method.

@peters
Copy link
Contributor

peters commented Sep 9, 2014

@KennyKay See #464

@amaitland
Copy link
Member

@KennyKay Can you give PR #465 a go and see if that resolves your problem?

I wouldn't necessarily comment out RaiseCanExecuteChanged, just the Application.Current checks

@KennyKay
Copy link
Author

@amaitland I tried the PR #465 and it does not crash on startup.

I did some tests with the browser and I found out that when running it in ElementHost.EnableModelessKeyboardInterop(wpf), the browser doesn't receive any keyboard input but the mouse works. ( Same issue with the master branch)

Also, it happens sometimes that the browser crash on window closing:
keyboardcrashwhenclosing

@amaitland
Copy link
Member

I've merged #465 into master.

did some tests with the browser and I found out that when running it in ElementHost.EnableModelessKeyboardInterop(wpf), the browser doesn't receive any keyboard input but the mouse works. ( Same issue with the master branch)

Issue #362 has some info on the problem, the only fix I know of at this stage is to open the Wpf Window as model.
Code sample https://github.com/amaitland/CefSharp/blob/bug/wpf-hosted-in-winforms/WPFHostedInWinForm/WinFormsExampleHost.cs

Is there are a specific reason your using the WPF version and not the native WinForms version? Would resolve the issue.

Also, it happens sometimes that the browser crash on window closing:
keyboardcrashwhenclosing
Should be relatively easy to fix, just need to unhook the even handlers on dispose

protected virtual void Dispose(bool isdisposing)
{
  GotKeyboardFocus -= OnGotKeyboardFocus;
  LostKeyboardFocus -= OnLostKeyboardFocus;

@amaitland
Copy link
Member

I do have a PR that's waiting for review that has the relevant dispose changes applied to it already if your interested, it's #412

I've just merged the latest master changes into it. Hopefully this fixes the null pointers your seeing.

@amaitland
Copy link
Member

It appears this is the same problem as #460 so I've created and merged PR #469

Hopefully that fixes your problem. Ideally we'll expand the Dispose to unhook all relevant events (which we really should be doing regardless)

@amaitland amaitland added the cef3 label Sep 11, 2014
@KennyKay
Copy link
Author

@amaitland I tested PR #469 and it fixes the dispose bug.

For now, I will be using the Wpf browser without a WinForm (Call from the program.cs) to have the keyboard inputs and all the RenderTransform functions on the browser control.

Thanks

@Pkotian80
Copy link

ey I am not able to use the cefSharp in my Xaml file. I get a error as

{"Could not load file or assembly 'CefSharp.Core, Version=63.0.3.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138' or one of its dependencies. The system cannot find the file specified.":"CefSharp.Core, Version=63.0.3.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138"}
and I am using the latest vesion 63.0.3.
Could any one please suggest on this

@Apurv1516
Copy link

@Pkotian80 I am also facing the same problem . Please share if you have found the solution.

@4eyecoder
Copy link

I installed the applicable Visual C++ Runtime and it started working for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants