How to include VC++ Redistributable Files Needed by CEFSharp
Asked Answered
W

3

8

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.

Wheelock answered 18/2, 2019 at 21:13 Comment(1)
See blogs.msdn.microsoft.com/vcblog/2015/03/03/…Vulgarity
K
10

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://learn.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://learn.microsoft.com/en-us/cpp/windows/redistributing-visual-cpp-files?view=vs-2019 the locations for VS2015 are slightly different to VS2017/2019.

Kersey answered 19/2, 2019 at 23:0 Comment(13)
You will need to include the dlls for 140 or 141. 120 is version 2013. Microsoft have somewhat simplified and complicated things with version 2015 and above, I recommend everyone reads blogs.msdn.microsoft.com/vcblog/2015/03/03/…Vulgarity
github.com/cefsharp/CefSharp#release-branches lists .net version and vc++ version requirements for CefSharp based on branchVulgarity
Thank you for the clarification. We still use ChefSharp version 49.0.0 as we were not able to migrate to the newer version yet due to some breaking changes and incompatibility with some requirements from our client. I did not know the Visual C++ version has change. Useful note! I have updated my answer.Kersey
Unfortunately, in my computer, were CEFSharp works, I don’t have msvcp141.dll or msvcr141.dll. I do have msvcp120.dll and msvcr120.dll, those files are also on the server. I’ll try downgrading the version of CEFSharp used in the application. Hopefully version 63 will still have all the necessary features: communication between JavaScript & C# code and silent file downloads.Wheelock
Are you sure you have Visual Studio C++ Redistributable 2015 installed on your dev PC: microsoft.com/en-us/download/details.aspx?id=48145 ?Kersey
You can use either VC++ 2015 or VC++ 2017. Downgrading to and older version will leave you using an unsupported version.Vulgarity
I don’t know if VC++ is installed on my computer, but whatever I have (or don’t have), CEFSharp v71 works. Which version of VC++ should I install, my PC & the server are both 64bit, but the application I'm codding is x86? BTW, I did try downgrading, and instead of loading the website, CEFBrowser just shows a blank/white screen. So going to version 63 wasn't the solution.Wheelock
To understand which version of VC++ you already have you can go to Control Panel -> Programs -> Programs and Features and search for "Redistributable". I have also added the link to all the versions to my original answer above. You can select the version you need then on the download page you can choose whether you x86 or x64 version (you need x86).Kersey
I have also added one more path where you can search the DLLs in my original question above.Kersey
In Programs and Features > Installed Updates, I have x64 & x86 Redistributable 2010. Also, in System32, I have msvcP140.dll, but not msvcR140.dll. I ran the installer for Redistributables 2015 and 2017, but neither installed msvcr140.dll or msvcr141.dll. I copied msvcp140.dll to the server in the same directory with the app, and in System32, but CEFSharp still threw the error.Wheelock
There were some mistakes which hopefully I've corrected, there dll names are awalys 140 regardless of version, e.g. there is no msvcr141.dll file, for v141 the files are still 140 in the name. Also added links to Universal CRT deployment which is required on Win7/8, it comes preinstalled as part of Win 10. You can also use VC++ 2019 as it's backwards compatible (v142).Vulgarity
What do you mean by ship? Do we just set these dlls to be installed into the same folder as the application?Credulous
Thanks it worked perfectly. I needed to add the dll named vcruntime140_1.dll as well (works with cef.sharp 97.1.60)Dictum
L
4

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.

Lebkuchen answered 26/11, 2019 at 1:18 Comment(1)
Thank you, you've saved my day, I wasn't able to find the file msvcr140.dll, but used vcruntime140.dll instead, and worked for me.Shala
M
0

Seems that Microsoft offers a unified installer for all C++ runtimes versions, from the 2015 to 2022.The installer is available on both 32 or 64bit, depending your architecture.

For details, check the Microsoft Visual C++ Redistributable latest supported downloads article.

Maragretmarala answered 11/5, 2022 at 8:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.