CefSharp icon indicating copy to clipboard operation
CefSharp copied to clipboard

CefSharp Dependency Changes 1.25.0 to 1.25.3

Open jasonds opened this issue 13 years ago • 10 comments

Hello,

I recently moved from 1.25.0 to 1.25.3. 1.25.3 works fine for me, but now I am getting this issue on other user's machines:

System.BadImageFormatException: Could not load file or assembly 'CefSharp.dll' or one of its dependencies. is not a valid Win32 application. (Exception from HRESULT: 0x800700C1) File name: 'CefSharp.dll'

I used Dependency Walker and noticed that now CefSharp.dll is using MSVCP110.dll and MSVCR110.dll whereas 1.25.0 was using *90.DLL. I copied these locally and it still did not work.

The setup I had which worked for 1.25.0 was copying libcef.dll and icudt.dll with CefSharp and CefSharp.Wpf locally. Then I set PackLoadingDisabled to true in my code.

Any ideas what might have changed / any additionally dependencies I need to include in my build? I greatly appreciate your time here,

Jason

jasonds avatar Sep 07 '13 18:09 jasonds

Experienced the same issue a couple of days ago, solved it by embedding the crt runtime per application install. These are the files i'm using (cefsharp 1.25.4): msvcp110.dll, msvcr110.dll, vccorlib110.dll.

peters avatar Sep 07 '13 20:09 peters

Thank you peters for your response - at first I did not include vccorlib110.dll. However, after adding it, this still did not fix the issue.

Here is a brief update below. I have a temporary fix for now:

1.25.0 was working fine with our current process architecture setup pointed to x86 for myself and all other users (some non-developers). We are on x64 builds / Windows 7.

I tried installing the VC2010 and 2012 redistributable packages on the users' machines but this didn't work. I tried taking the *110 dlls and copying locally as well discussed initially. I spent time with DependencyWalker and FusionLogViewer but nothing came from the research.

I ended up taking the 1.25.0 source code and making the change I needed (the null reference exception for the AddSourceHook method). I rebuilt the solution and used the CefSharp and CefSharp.Wpf dlls. This fixed the issue for now. I wonder if you have any other ideas for why this would happen. Thank you for your time,

Jason

jasonds avatar Sep 11 '13 03:09 jasonds

Hi Jason,

The BadimageFormatException you are seeing usually gets thrown because of either one of the following two errors:

  • Trying to load an x86 assembly in an x64 process, or vice versa (the latter would not be the case in this fault, since both CEF and CefSharp is x86 for the time being) OR
  • Trying to refer to .NET assemblies from another version of the framework (e.g. loading 4.0 assemblies in a 2.0 app). This could very well be the case, since CefSharp is .NET 4.0 (1.25.3 and upwards, whereas 1.25.0 was .NET 2.0).

If a DLL file (either the .NET assembly trying to be loaded or one of its unmanaged dependencies) cannot be located, you usually get a FileNotFoundException instead.

Now, some questions:

  • Is your app compiled with .NET 2.0/3.5 or .NET 4.0/4.5? What version of Visual Studio are you using?
  • When you say that you compiled CefSharp 1.25.0+local patch yourself, what version of Visual Studio did you use for that? (I presume 2008, since that's the only one that worked with 1.25.0. :wink:)

perlun avatar Sep 11 '13 04:09 perlun

Did you manage to find the underlying problem here?

perlun avatar Sep 16 '13 18:09 perlun

Hi perlun,

I've had some time to revisit this. I started fresh and extracted the 1.25.4 binary release found here.

Before touching the solution, I ran the WPF sample from the release directory locally: CefSharp.Wpf.Example.exe. This worked fine. I then copied the release directory to a clean machine without VC++ 2010/12 installed. I attempted to run and it failed. I checked dependency walker - noticed I correctly needed msvcp110 and msvcr110 dlls. I copied these to the same directory as the executable and it failed. As @peters mentioned, I copied vccorlib110.dll locally as well, but this still failed. I checked Fusion log viewer and noticed there was no entry for "CefSharp.Wpf." I think it is failing with dependencies for the CefSharp.dll. I checked fusion log viewer on my local machine (has an entry for the Wpf dll here) and compared CefSharp.dll but did not see any differences. I think I am missing an additional dependency for VC++ 2012 on this machine.

I am using visual studio 2010. I then took the 1.25.4 source code found here. I rebuilt the solution in release mode. I ran the WPF sample from the release directory fine. I copied the release directory to the same machine. I attempted to run and it failed. I checked dependency walker and noticed correctly we needed msvcp100 and msvcr100 dlls. I copied only these to the same directory as the executable and it worked perfect. I then took these built dlls and dependencies and put them in my application and everything is working fine. I am using the same source code now, so I am up to date. Do you see anything obvious, some dependency or otherwise, on why the binary release example would fail even though I copied the VC++ dependencies locally? Thank you for your time here,

Jason

jasonds avatar Oct 07 '13 18:10 jasonds

Interesting indeed... The major thing changed between 1.25.0 and 1.25.3+ is the fact that @ataranto used to use VS2010 when building (and he made the 1.25.0 release). I use VS2012, which is also the version used when building 1.25.3 (but as you've noticed, it can also be successfully built using VS2010).

The "funny", or should we say perhaps more rightfully, "weird" thing here is that I can run a 1.25.3+ binary on a machine without VS2012, as long as I provide the msvcp110 and msvc110 DLLs along with the app. This is on Windows 7, x86 (i.e. 32-bit), running inside a .NET-based Click Once application.

What is the configuration (OS and platform, x86 or x64) of the failing machine in your case?

perlun avatar Oct 21 '13 18:10 perlun

Closing because of lack of feedback.

perlun avatar Nov 13 '13 15:11 perlun

I had the exact same issue and finally fixed it by installing the VS 2012 redistributables for C++. Apparently there is a difference between the ones for 2010 and 2012...

reikjarloekl avatar Nov 15 '13 10:11 reikjarloekl

Yes, absolutely. :) Perhaps this hasn't been clearly noted before: Recent versions of CefSharp are compiled with VS2012, which means that they need the VC++2012 redist. Sorry for not pointing this out earlier (but I do think it's listed on the FAQ actually).

On Fri, Nov 15, 2013 at 12:41 PM, reikjarloekl [email protected]:

I had the exact same issue and finally fixed it by installing the VS 2012 redistributables for C++. Apparently there is a difference between the ones for 2010 and 2012...

— Reply to this email directly or view it on GitHubhttps://github.com/cefsharp/CefSharp/issues/163#issuecomment-28560585 .

mvh, Per Lundberg

perlun avatar Nov 15 '13 11:11 perlun

HI perlun , please help me i want used cefsharp 1.25.0 on system have 2.0 .net freamwork i download cefsharp 1.25.0 and try to build in target freamwork 2.0 i got error cefshap.dll can't load assembly what should i do please help

Rajesh...

HirulkarRajesh avatar Dec 17 '14 14:12 HirulkarRajesh