How to include VC++ Redistributable Files Needed by CEFSharp - 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.

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:
Version 120 is installed with C++ Redistributable for Visual Studio
2013
Version 140 is installed with Visual C++ Redistributable for Visual
Studio
2015
Version 141 is installed with Microsoft Visual C++ Redistributable
for Visual Studio
2017
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.

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.

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.

Related

Correct location of MSBuild.exe to build .net 4.5 application using command line

I have asp.net web api application targeting 4.5 framework.
I am trying to create a docker image for my application. In order to build the application, I can use MSBuild.exe available in C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe or C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe locations.
When I build using C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe location, I get error saying "
C:\MyApp-Api\MyApp-Api.csproj(985,3)
: error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft
\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" was not f
ound. Confirm that the path in the declaration is correct, and that th
e file exists on disk."
I am able to build my application using C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe location.
Questions:
What is the difference between the MsBuild.Exe available in these two folders?
Ideally I think using C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe location is the right approach as it comes with default location and I think MSBuild in program files comes due to installation of Visual Studio. and on my Build server I will not have visual studio installed.
In order to build the application on container, I need to specify SDK which will allow me to build the application. Which version of SDK, I need to build .net 4.5 application.
I was browsing web with a similar query today and stumbled upon this random link to a Veracode extension which lists nicely the difference.
Visual Studio 2017
The first two paths below that contain Professional differ based on the edition of Visual Studio you have installed. Replace Professional with Enterprise or Community, when appropriate.
Note: the Visual Studio Preview install also changes the path based on Enterprise, Professional, or Community.
Standard Visual Studio Paths
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\amd64\
Visual Studio Preview Paths
C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\MSBuild\15.0\Bin
MSBuild Tools Paths
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\amd64\
Visual Studio 2015
C:\Program Files (x86)\MSBuild\14.0\Bin\
C:\Program Files (x86)\MSBuild\14.0\Bin\amd64\
Visual Studio 2013
C:\Program Files (x86)\MSBuild\12.0\Bin\
C:\Program Files (x86)\MSBuild\12.0\Bin\amd64\
Visual Studio 2012
C:\Windows\Microsoft.NET\Framework\v4.0.30319\
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\
It seems like you have both VS2012 and VS2015 installed.
I dont know much about ASP.NET and docker but will try to answer your questions:
I think the difference is explained above.
The problem you are experiencing there is explained better in here:
The imported project Microsoft.WebApplications.targets was not found Maybe give it a go?
Relying on https://dotnet.microsoft.com/download/visual-studio-sdks and
https://learn.microsoft.com/en-us/dotnet/framework/install/guide-for-developers it seems like there is no SDK for .net 4.5 as it is included in VS2012. But any higher version should build your project to 4.5 anyway.
Reading (3) I would use VS2015 msbuild if VS2012 gives you a headache.
If you dont mind me asking - Why not switching to ASP.NET Core ?

How to launch VStudio 2015 RC for ASP.NET vNext

I installed VSStudio 2015 from here: http://www.asp.net/vnext
Installation says success but I have no icon on desktop to run why?
VS2015RC installation did not put an icon on my desktop either, it is in the application menu though.
The exe should be located here.
C:\Program Files (x86)\Microsoft Visual Studio
14.0\Common7\IDE\devenv.exe
You can create a shortcut and put it on the desktop yourself.
If you cannot find the folder maybe you need to reinstall or repair the installation.
The official download site is here. The community edition should have all you need to get started with ASP.NET 5 and all the vNext stuff.

Build ASP.NET 4.5 without Visual Studio on Build Server

Its been a while since I setup a Build Server so maybe I've forgotten something or maybe .NET 4.5 is different from whatever version I did this with last time, but here is my problem.
I'm trying to setup a build server to monitor a source control repository. Whenever something changes, I want the server to pull the changes and build the project. If there are no errors, I want to deploy the site to a web site running on the build server.
In the past when I did this, I thought that I was able to do this having only .NET installed, but when I try to build this project I get an error that "C:\Program Files\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" is missing, and if I go and look I can see that it is missing. In fact there are no Visual Studio 11 targets files.
After a lot of thought and head scratching, I went out and got the "Windows 8/.NET 4.5 SDK" thinking that the .NET 4.5 SDK might install the targets files that I needed, but it did not unless I installed it wrong somehow.
So, what do I need to put on the Build Server in order to get the project to build. I would prefer not to have to install the full Visual Studio 2012.
To run on on your CI server without Visual Studio, you only need to copy a few folders from a development machine to the same location on the CI server. There is no need to install the SDK.
VS 2015:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications
VS 2013:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\WebApplications
VS 2012:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications
VS 2010:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications
.NET 4.6:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6
.NET 4.5.2:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2
.NET 4.5.1:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1
.NET 4.5:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5
.NET 4.0.1:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0.1
.NET 4.0:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0
Or, as Matt suggested, you could copy them into a subdirectory of your project and alter the <MSBuildExtensionsPath32> location in your MSBuild (typically .csproj or .vbproj) file.
Once you have done this, your project will compile.
You should also set the VisualStudioVersion environment variable explicitly to the Visual Studio version (10.0 for VS2010, 11.0 for VS2012, 12.0 for VS2013, 14.0 for VS2015) you are using just to be sure it is set right in your configuration.
My problem was related to installing the Windows Software Development Kit (SDK) for Windows 8 on a Windows 2008 Box. If you read further on the page, you will get to a heading labeled ".NET Framework 4.5 SDK Tools on Windows Vista and Windows Server 2008." This tells you to:
Run the Windows SDK for Windows 8 installer on a supported operating system (for example, Windows 7, or Windows 8).
Choose the following option on the Specify Location screen: Download the Windows SDK for installation on a separate computer.
Press the Next button.
Answer the questions on the Join the Customer Experience Improvement Program (CEIP) screen.
On the next screen, choose the .NET Framework 4.5 Software Development Kit feature. Unselect all other features that can be unselected.
Choose the Download button.
Go to the download location (specified in step 2) and find the following .NET Framework 4.5 SDK tool installer files:
sdk_tools4.msi,
sdk_tools4.cab
You can copy these files to a Windows Vista or Windows 2008 Server computer within your organization. These files need to be copied to same directory on the Windows Vista or Windows 2008 Server computer.
Note: Do not redistribute these files outside your organization or as part of any other installer.
On the Windows Vista or Windows 2008 Server computer, review the license terms here .
Check whether .NET Framework 4.5 is already installed on the computer. Otherwise, download and install .NET Framework 4.5 from www.microsoft.com .
Open a command prompt with administrator privileges.
Go to the directory where .NET Framework 4.5 SDK Tools installer files were copied.
Install .NET Framework 4.5 SDK tools by using the command line:
Msiexec /i sdk_tools4.msi VSEXTUI=1
From msdn:
The Windows SDK no longer ships with a complete command-line build environment. You must install a compiler and build environment separately. If you require a complete development environment that includes compilers and a build environment, you can download Visual Studio 2012 Express, which includes the appropriate components of the Windows SDK.
In order to fix this, I had to copy the folder C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5 from my development machine (which has Visual Studio 2012 by the way) onto the build agents. After this operation, Team City did not report any more errors and mscorlib.dll was not output to the bin folder.
Microsoft Build Tools 2013 will help in this case, as its download page describes:
If you don't have Visual Studio installed on your computer, you can
use Build Tools 2013 to build managed applications. The Visual Basic
and C# compilers are also included in this download. (In earlier
versions, these tools were included in the stand-alone .NET
Framework.)
My dept. likes taking a minimalistic approach to what's installed on our Win 7 build machines. However, we don't like just copying and pasting files/folders because of potential registry key issues. Instead of installing VS 2013, I installed the following much smaller and free components. Now the dev team can build VS 2013 web apps successfully.
.Net Framework v4.5.1, required to install the tools - http://www.microsoft.com/en-us/download/details.aspx?id=40779
MS Build Tools 2013, we needed the C# compiler - http://blogs.msdn.com/b/visualstudio/archive/2013/07/24/msbuild-is-now-part-of-visual-studio.aspx
MS VS 2013 Isolated Shell, we needed the web app targets - http://www.microsoft.com/en-us/download/details.aspx?id=40764.
I solve this problem with Visual Studio Agents.
You can try install Visual Studio Agents 2012.
http://www.microsoft.com/en-us/download/details.aspx?id=38186

How to Include Anti-XSS in ASP.Net 2.0 Without Visual Studio

Can I include Microsoft's Anti-XSS library in my ASP.Net 2.0 application without Visual Studio? If so, how?
I've already downloaded and installed the library. From Microsoft's download page: "Reference the library in your application and use it." Researching this turns up instructions for doing so with Visual Studio, but not without.
This S.O. answer links to a few promising articles, but those also assume Visual Studio to start.
(As for why I can't use Visual Studio: my manager says "No.")
Its very simple, just copy the file \program Files\Microsoft Corporation\Anti-Cross Site Scripting Library V1.5\Library\Net 2.0\AntiXssLibrary.dll, into your /bin/ directory of your asp.net and you ready to use it by just include the reference of antixss in every code that you won to use it.
The library is this file: AntiXssLibrary.dll
If not found on the directory I write for, just search your disk, where you have install it.
Ver 4.2.1
For the version 4.2.1 that you have a link on it the files are on
c:\Program Files\Microsoft Information Security\AntiXSS Library v4.2\NET20\
and you copy both, AntiXssLibrary.dll and AntiXssLibrary.xml to your /Bin/ directory of your asp.net
Download
If you can not find the library installed on your computer from the visual studio or from the SDK, you can always download it from Microsoft. The latest version is here:
https://www.microsoft.com/en-us/download/details.aspx?id=43126

Could not load assembly System.Data.SQLite.dll

I have a perfectly working windows forms C# .NET 4 application that uses a SQLite3 database file to store data and display forms.
When I deploy my app on any machine other then the dev machine, I get an exception thrown and it's message is "Could not load assembly System.Data.SQLite.dll or one of its dependencies. The specified module could not be found."
The System.Data.SQLite.dll reference in the project is set to Copy Local = True. Also, I tried manually loading the assembly with Assembly.LoadFile. The dll is placed in the output directory. I also tried setting the platform target to Any CPU as well as x86, no difference. All machines I am working with are 32-bit. What is the issue here? Why is my application trying to load the assembly and can't find it?
Thanks!
I had the same problem after publishing my program to a separate computer. Installing Microsoft Visual C++ 2010 Redistributable Package (x86) on the separate computer fixed the problem.
Note: the separate computer already had Microsoft Visual C++ 2010 Redistributable Package (x64) installed, the x86 version was needed.
'System.Data.SQLite.dll" requires "msvcr100.dll" which is one of it's Dependencies. This will be available only if you installed latest "Microsoft Visual C++ Redistributable" or any other product which internally provides this.
For example, VS2010 will install C++ Redistributable by default. Thats the reason your application doesnot works in some machine but works in others.
You could try pasting the "msvcr100.dll" in your application bin folder and distribute if you dont want to install VC++ 2010 Redist in all the PC's.
Some of the System.Data.Sqlite.dll modules depend on the "Microsoft Visual C++ 2012 Redistributable Package" .
You can find required dependencies on the official download page : http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
The answers already given didn't solve my problem. I tried to deploy to a VMware server. The solution that did help where given here: http://sqlite.1065341.n5.nabble.com/System-Data-SQLite-Deployment-Mystery-td71752.html Two methods are described there.
When i install this sqlite-netFx45-setup-bundle-x86-2012-1.0.88.0.exe, my app is able to find the right dll.
The second method is to add the dll to de app.exe.config in the debug or release dir. If you edit this file directly, there is a change VC will overwrite the file.
My main problem was that i installed the sqlite package manually. I didn't use NuGet, because i'm behind a proxy. If you do use Nuget, the information in the app.exe.config will be provided automatically.
Using NuGet behind a proxy is described here: NuGet Behind Proxy

Resources