Could not load file or assembly 'CefSharp.Wpf for x64 and x86; only one works

When I run in, I get: Could not load file or assembly 'CefSharp.Wpf, Version=41.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138' or one of its dependencies. An attempt was made to load a program with an incorrect format.


This means that the problem is because the dlls are not the correct bitness.

In version 41.0.0, the nuget package adds dll references to the x86 version that point to the correct path (x86 folder). There is also another copy of the dll pointing to an empty path in the property pane. The problem is the x64 version is crashing with a bad image error as it is referencing the x86 dll versions.

I went back to 39.0.2 and CefSharp works for me. I have both sets of DLLs and where the x86 and x64 versions of my application compile and run as expected.

When I upgrade to 41.0.0 again the same problem as before. The x64 version will compile, although the application uses the x86 version of the DLL that crashes when trying to display the first browser. I tried to rebuild everything and also remove the DLLs that are copied automatically and at compile time the x86 versions are copied again. (At least I believe this is the case:

Two Sets of Dlls

Then I removed all the DLLs in the links and manually added the x64 versions. Compilation and execution worked correctly as with CefSharp.WPF version 39.02.

How can I get both versions to work without having to manually change the dll paths?

One more note, I can use nuget when it is set to x64 and it does the opposite of the stated problem. Now x64 is working, but x86 is not. DLL paths are now x64 folders.

+3


source to share


1 answer


It turns out that after a lot of sorrow and anguish, I discovered that the links were not properly configured in mine .csproj

. They were identified as x64 somehow.

<Reference Include="CefSharp, Version=41.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=AMD64">
  <SpecificVersion>False</SpecificVersion>
  <!--<HintPath>..\packages\CefSharp.Common.41.0.0\CefSharp\x64\CefSharp.dll</HintPath>-->
</Reference>
<Reference Include="CefSharp.Core, Version=41.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=AMD64">
  <SpecificVersion>False</SpecificVersion>
  <!--<HintPath>..\packages\CefSharp.Common.41.0.0\CefSharp\x64\CefSharp.Core.dll</HintPath>-->
</Reference>
<Reference Include="CefSharp.Wpf, Version=41.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=x86">
  <SpecificVersion>False</SpecificVersion>
  <!--<HintPath>..\packages\CefSharp.Wpf.41.0.0\CefSharp\x64\CefSharp.Wpf.dll</HintPath>-->
</Reference>

      

As soon as I commented HintPath

it started working correctly. Please note that the actual links are defined Import

at the top of the project.



<Import Project="..\packages\CefSharp.Wpf.41.0.0\build\CefSharp.Wpf.props" Condition="Exists('..\packages\CefSharp.Wpf.41.0.0\build\CefSharp.Wpf.props')" />
<Import Project="..\packages\CefSharp.Common.41.0.0\build\CefSharp.Common.props" Condition="Exists('..\packages\CefSharp.Common.41.0.0\build\CefSharp.Common.props')" />

      

These files .props

install the actual HintPath

one that is needed to copy the correct one .dlls

into the build folder. I'm not sure how my project ended up wrong.

+1


source







All Articles