Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include VC++ Redistributable Files Needed by CEFSharp

Building an application using the CEFSharp browser, works fine on my machine, but crashes on the server with the following error:

System.IO.FileLoadException: A procedure imported by 'CefSharp.Core.dll' could not be loaded.

I’ve seen this problem all over the internet, and the most common solution seems to be installing the VC++ Redistributable. However, I don’t have that access on our production server. In the development server, I tried installing the redistrituable (x86, x64, 2017, and 2013) and nothing made a difference. The computers are 64 bit, but the application is 32bit so I tried everything.

Can someone tell me what files specifically I need to add to the application directory to make CEFSharp work. Section 6 of this document: https://github.com/cefsharp/CefSharp/wiki/Frequently-asked-questions#6-how-do-i-include-the-visual-studio-c-2012-redistributables-on-the-target-app lists directories of files necessary, but I’m using Visual Studio 2017 and don’t have any of these directories on my machine.

Additional Info:

  • Development machine Windows 10, server 2016 Standard

  • Build set to x86, have not made any config changes for Any CPU mode

  • Windows Forms application

  • CefSharp version 71.0.0 from NuGet (& individually through Package Management Console Simple CefSharp application is missing files at runtime)

  • Not using any type of package or ClickOnce Deployment, manually uploading all files from my computer to server

Update:

Although I'm still unable to get CEFSharp to work in my project, I accepted Peter Liapin's answer because it did answer the question I asked. Now I know what files in the VC++ Redistributable to copy to my application folder on the server, I just don't have the specific dlls he mentioned on my computer or on the server.

Additionally, I created a new test Windows forms project with CEFSharp and it worked on the server without the VC++ Redistributable dlls. However, I need the CEFSharp browser to work in a user control referenced by existing application.

like image 757
Jayden67 Avatar asked Feb 18 '19 21:02

Jayden67


People also ask

Where are the Visual C++ redistributable files located?

In the latest version of Visual Studio 2019, you'll find the redistributable files in the %VCINSTALLDIR%Redist\MSVC\v142 folder. In both Visual Studio 2017 and Visual Studio 2019, they're also found in %VCToolsRedistDir% .

How do I install Microsoft Visual C++ redistributable packages?

The Redistributable is available in the my.visualstudio.com Downloads section as Visual C++ Redistributable for Visual Studio 2019 - Version 16.7. Use the Search box to find this version. To download the files, select the platform and language you need, and then choose the Download button.

Do I need to keep all Microsoft Visual C++ redistributable?

We don't recommend that you delete any Visual C++ redistributable, because doing so could make multiple applications on your computer stop working. Given how little space they take up and how broadly they are used, it doesn't seem worth the hassle to mess with your current ecosystem of standard library files.


2 Answers

The Visual C++ dlls you need to ship with your CefSharp based project:

If you use CefSharp v63.0.3 or below:

  • msvcp120.dll
  • msvcr120.dll

If you use CefSharp v65.0.0 or above:

#Example of files for VC++ 2017(141), there will be a few less files for VC++2015(140) and a few more for VC++ 2019(142), copy everything from the `Microsoft.VC14x.CRT` folder where `x` matches the VC++ Version
concrt140.dll
msvcp140.dll
msvcp140_1.dll
msvcp140_2.dll
vccorlib140.dll
vcruntime140.dll

Files can be found on your Dev PC in the:

  • C:\Windows\System32
  • C:\Program Files (x86)\Microsoft Visual Studio\[Version]\[Edition]\VC\Redist\MSVC\[Version]\[x64|x86]\Microsoft.VC14x.CRT folder.
  • See section at bottom if you are having problems finding the files on your machine, they are in slightly different folder structure for VS2015 compared to VS2017/2019

Note, you must have an appropriate version of Visual C++ or Visual Studio installed on your PC, otherwise you would not be able to find them:

Universal CRT is required by Visual C++, on Windows 10 it is installed by default. Local deployment of the Universal CRT is supported see https://docs.microsoft.com/en-us/cpp/windows/universal-crt-deployment?view=vs-2019#local-deployment

For Windows 7/8/8.1 you will either need the Universal CRT pre installed or deploy the files as per the link above.

To deploy redistributable Visual C++ files, you can use the Visual C++ Redistributable Packages (VCRedist_x86.exe, VCRedist_x64.exe, or VCRedist_arm.exe) that are included in Visual Studio. In Visual Studio 2017, these files can be found in the Program Files[ (x86)]\Microsoft Visual Studio\2017\edition\VC\Redist\MSVC\lib-version folder, where edition is the Visual Studio edition installed, and lib-version is the version of the libraries to redistribute. In Visual Studio 2015, these files can be found under your Visual Studio installation directory in Program Files [(x86)]\Microsoft Visual Studio version\VC\redist\locale. Another option is to use redistributable merge modules (.msm files), which in Visual Studio 2017 can be found in the Program Files [(x86)]\Microsoft Visual Studio\2017\edition\VC\Redist\MSVC\lib-version\MergeModules\ folder. In Visual Studio 2015 these can be found in Program Files [(x86)]\Common Files\Merge Modules. It's also possible to directly install redistributable Visual C++ DLLs in the application local folder, which is the folder that contains your executable application file. For servicing reasons, we do not recommend that you use this installation location.

As per https://docs.microsoft.com/en-us/cpp/windows/redistributing-visual-cpp-files?view=vs-2019 the locations for VS2015 are slightly different to VS2017/2019.

like image 50
Peter Liapin Avatar answered Oct 06 '22 06:10

Peter Liapin


I had what appears to be the exact same issue, and I was able to get things working by copying msvcp140.dll and vcruntime140.dll into the bin folder of my application. I'm using CEFSharp 75.1.143 with cef.redist.x86 75.1.14.

like image 20
Matt Burnell Avatar answered Oct 06 '22 06:10

Matt Burnell