Click here to Skip to main content
15,920,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a WPF net core project and it's using CEF ChromiumWebBrowser, in the debug mode it run ok. Then I create Setup Project to make file msi file for client but it has error "File 'CefSharp.Core.Runtime.dll' of project output 'Publish Items from CommunicateWithWeb (Active)' targeting 'x64' is not compatible with the project's target platform 'x86'" while building. After I change TargetPlatform of Setup Project to x64, build is successfully. 

Then I run msi file to install app in my PC but I can't open this app by clicking exe file. I open event viewer and see that this error "System.IO.FileNotFoundException: Could not load file or assembly 'CefSharp, Version=108.4.130.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138'. The system cannot find the file specified." is displayed.

So anyone can help me this problem? Any comment is also important for me. Thank you.

Note: I use VS2022, CefSharp.WPF.NETCore ver 108.4.130. I also install MS Visual C++ 2015-2022 Redistributable (x64 and x86) ver 14.34.31931


What I have tried:

I installed Orca and see that CefSharp assembly is already included in .msi file.
Posted
Updated 28-Dec-22 4:03am
Comments
Sandeep Mewara 28-Dec-22 3:02am    
Are you referencing x86 or x64 versions of cefsharp - did you check that?
huynhminh97 28-Dec-22 3:05am    
@Sandeep Mewara Thank you so much. My project is reference x64 version of cefsharp. Also, I'm using VS2022 64 bit, win10 64bit and build properties Platform ="Any CPU"
Sandeep Mewara 28-Dec-22 9:55am    
On the system where you are trying to use the app, does that have 64bit cefsharp? (check at the location expected/reference).
huynhminh97 29-Dec-22 2:36am    
@Sandeep Mewara I'm so grateful for your help, I've already fixed it.

1 solution

DON'T use Any CPU. That will run your code as a 32-bit app on 32-bit Windows and 64-bit on 64-bit Windows. The problem you're going to run into is when running on 32-bit Windows and you only included the 64-bit .DLL's for cefsharp, you're going to get the error you're getting. You can NOT mix 32 and 64-bit code in the same process.

I highly suggest making two versions of your app, one for 32-bit and the other for 64-bit. Then make two installers, for each architecture, making sure you include the correct .DLL's for each.
 
Share this answer
 
Comments
huynhminh97 29-Dec-22 2:29am    
@Dave Kreskowiak Thanks to your right comment, I've already understood this issue and solved it. The following steps are the way that I fixed:
1. Open Configuration Manager and change Platform to x64
2. Right click to WPF project => choose Properties and change PlatformTarget to x64
3. Click to SetupProject => Press F4 => change TargetPlatform to x64
4. Open file csproj and add the following code:
    <PropertyGroup Condition="'$(PlatformTarget)' == 'x64'">
      <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    </PropertyGroup>

    <PropertyGroup Condition="'$(PlatformTarget)' == 'x86'">
      <RuntimeIdentifier>win-x86</RuntimeIdentifier>
    </PropertyGroup>

Because my project is WPF so need add more code:
    <ItemGroup>
		<Reference Update="CefSharp">
			<Private>true</Private>
		</Reference>
		<Reference Update="CefSharp.Core">
			<Private>true</Private>
		</Reference>
		<Reference Update="CefSharp.Wpf">
			<Private>true</Private>
		</Reference>
	</ItemGroup>


You can visit this link to more information: https://github.com/cefsharp/CefSharp/issues/3284

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900