How to include Visual C++ Redistribution with application - c#

I've written a large C# 4.0 App in Visual Studio 2010. Some time ago I added the CEF framework (version 43.0.0.0) in order to utilize a web-browser inside my WinForms application.
If I run my app from Visual Studio, the browser runs correctly. However, upon using ClickOnce to deploy my app, it threw the following error: "Could not load file or assembly 'CefSharp.Core.dll' or one of its dependencies. The specified module could not be found." Although all the CEF files are present in the bin\Debug folder. In fact I found a page on GitHub listing which files are required, and a careful check verifies that all are present in the executable folder.
A list of required files can be found here:
One of the points made in the above article, are that the Visual C++ Redist files are required and asks in question 6. How do I include the Visual Studio C++ 2012/2013 redistributables on the target app?
It specifically states that CefSharp version 43.0.0 and below needs VC++ Version 2012. Therefore, I downloaded vcredist_x86.exe (the 2012 version)
I created a package.xml and product.xml Bootstrapper files in the Microsoft SDKs folder. I included these as a prerequisite in Visual Studio 2010's Publish screen.
However, upon a ClickOnce deployment and an attempt to launch the CEF Web Browser, it immediately throws the exception "Could not load file or assembly 'CefSharp.Core.dll' or one of its dependencies. The specified module could not be found."
I am at a loss as to what to do, in order to get the browser to work outside of my development environment, i.e., for the End-User to successfully use.
I've followed all the steps that I've found on line, both on Stackoverflow and Github for CefSharp. What else is required to get this working?
Please help!

I'm adding this addendum in case anyone working with CefSharp has run into the same issue, namely "Could not load file or assembly 'CefSharp.Core.dll' or one of its dependencies. The specified module could not be found.". It turned out to be a ClickOnce issue. ClickOnce included all the "managed" resources, but did not include the unmanaged ones, i.e., cef.pak, cef_100_percent.pak, d3dcompiler, libcef.dll, icudtl.dat, etc.
If I right-clicked on References and attempted to browse to these resources to add them, Visual Studio complained about them being unmanaged and would not allow them to be added.
After working with the Microsoft ClickOnce and Deployment forum, it was suggested that I right-click on the project, Add > Existing Item and add them. Then set their Build Action to "Content" and Copy to Output Directory to "Copy Always."
This allowed the resources to show up in Application Files... on the Publish tab. After another ClickOnce deployment, launching the Web browser was successful. No more complaints about missing files.

Related

c# Winforms application with CefSharp Could not load file or assembly CefSharp.Core

Got an issue with the build for a Winform application. Keep getting the could not load file or assembly CefSharp.Core error message during runtime of a build. I don't get the same issue in debug mode.
CefSharp version is 79.1.360.
The project structure at a basic level is:
Startup project
Component project (where the Custom Chromium Browser user control resides)
UI project
The platform target is AnyCPU.
I've installed Cefsharp as per this site's instructions:
For the project setup I've got the CefSharpAnyCpuSupport tag set to true in both the Startup project and the Component project.
Prefer 32-bit is ticked in the Startup project. For the other projects it is read only.
The App.config for both Component & Startup projects have been modified as per the instructions.
The nuget packages I've noted as appearing in UI project packages folder.
The references in the Components project for all have "copy to output" set to "copy always." There's 3 references (CefSharp, CefSharp.Core, CefSharp.Winforms)
And tried to resolve this issue by doing the following:
Uninstall and reinstall CefSharp
Tried to resolve using the cefsharp github faq.
Tested having the UI project having all the same app settings and references, same goes for the other projects.
The required dll's all appear in the bin folder for both debug and release. Each machine, where the build is created and where the actual program is tested have the correct Visual Studio c++ redistributables installed 2013/2015 for x64 and x86.
Has anyone else encountered a similar issue and resolved this? I've already searched every previous Stackoverflow query regarding this and none of those have solutions that work for this application. Not sure if there's an issue because we use InstallShield for the builds/publishing which I haven't noticed anyone else using.
Please let me know if there's any further information you require to assist. Thanks,
Update: Bin folder contents post build
Contents
I replaced all the CefSharp required files and folders from Debug folder into the Release folder and kept the rest of the release build as they are, and my issue resolved.

Getting error while loading Sqlite dll in Window 10 mahcine [duplicate]

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

SSRS 2016 Custom Assembly Deployment Not Working

I have a very simple custom assembly written in C# using VS2017 that is being deployed to Microsoft SQL Server Reporting Services Version 13.0.4435.0 running with SQL Server 2016 (SP1-CU3) (KB4019916) on a Windows 10 box.
Below is the C# code for this "Hello World" custom assembly:
Namespace MyCustomAssembly
{
public class HellowWorldClass
{
public static string HellowWorld()
{
return "Hello World!";
}
}
}
Microsoft describes a step-by-step process for deploying a Custom Assembly:
https://learn.microsoft.com/en-us/sql/reporting-services/custom-assemblies/deploying-a-custom-assembly
Following the steps in the process, the first thing that I discovered is that the Report Designer default directory was different. After trying various folders, the destination that worked was the following:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\SSRS
After depositing the custom assembly DLL in this directory, the report preview worked as expected. This provided verification that the expression in the report textbox was defined correctly.
In accordance with the process, to deploy the custom assembly on the server the DLL should be placed in the following destination, adjusted for the specific SSRS version:
C:\Program Files\Microsoft SQL Server\MSRS13.MSSQLSERVER\Reporting Services\ReportServer\bin
The process then describes steps that extend the permissions of the custom assembly but this simple example should not require that. Execution permission should be sufficient. Therefore modification of rssrvpolicy.config should be unnecessary.
When I attempt to deploy the report to the serer by right clicking on the report in the Solution Explorer of VS2017 and selecting "Deploy", I get the following message (and only this text):
The definition of the report '/HelloWorldReport' is invalid.
If I remove the textbox containing the reference to the HelloWorld function in the custom assembly, the report deploys successfully to the server. So while there is no further information available in the message about why the report is invalid, it appears to be associated with the custom assembly on the server.
Here is what I have tried:
In spite of it not being required according to the process, I went ahead and edited rssrvpolicy.config to grant "FullTrust" to the assembly. Restarted the server.
I read that SSRS is based on .NET 3.5 (I built the assembly with 4.5.1) and that libraries needed to be built on .NET 3.5 to work. The custom assembly build was changed to use .NET 3.5.
Ensured that .NET 3.5 (and dependencies .NET 3.0 and 2.0) were installed on the server box. This was a long shot.
Reviewed various other tutorials and videos about the creation and deployment of custom assemblies. All seem to indicate that all that is necessary in this case is the placement of the DLL in the proper directory on the server.
Copied the custom assembly DLL in various other directories on the server. The thought was that if the VS2017 was in error maybe the server directory was also in error.
I looked into assembly security. Went through the signing process for the DLL. Used gacutil to install the custom assembly into the GAC.
In another desperate effort, I installed VS2017 community on the server and created a simple report and custom assembly on the server. Just as before, the VS2017 report preview presented itself correctly and the server deployment failed.
None of the above efforts worked.
I can share the RDL file or other material that might help identify the problem but I don't believe that the issue is with the report definition because the report will deploy if the references to the functions within the custom assembly are removed. And I don't believe that the issue is with the custom assembly because the preview works within the VS2017 environment. Is has to be something with the server but the error message is very opaque.
This is the first time that I have reached out to the SO community. I'm generally reserved and somewhat hesitant. Yet the experience of others has proven valuable to get by past development challenges and I am grateful. But I am really stumped this time. No one seems to have had this exact experience that I can find and I have searched exhaustively. I have little concern if the solution turns out to be a simple oversight or some basic ignorance that is worthy of ridicule. I just need a solution with what seems to be a non-problem for others.
Refer the following URL for solution:
https://developercommunity.visualstudio.com/content/problem/574712/rdl-deploy-error-vs-2017-ssrs-2017.html
Copy custom DLL to this folder C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\PrivateAssemblies on the developer machine.
One solution that worked is to use Report Manager to add the report rather than deploy from Visual Studio.
Just had the same problem as is described here.
For me the problem is that the DLL must be in two folders on the machine from where the report is being deployed:
For the DLL to work during development:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7
\IDE\CommonExtensions\Microsoft\SSRS
And to be able to deploy the report:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7
\IDE\PrivateAssemblies
Of course on the server the DLL must also be in the ReportServer\Bin folder
Also, I have seen posts about assembly having to be .NET 4.0, but this is not the case for me..... mine is 3.5

Cannot reference dll file in project

This is my first time trying to use a dll file in visual studio (2012) so I am not sure what I am doing wrong. I am trying to get sqlite into my project following this tutorial
I right click on the project in the Solution Explorer and click Add References
I then click on the browse tab and find where I have the dll file,click ok then ok in visual studio and I get an error saying Reference to *dll path* could not be added. Please make sure the file is accessible and that is it a valid assembly or COM component.
did I miss a step here or something?
The file is located in my dropbox folder (where my whole project is) and the project is a windows store application is that matters
Not a direct answer but instead of referencing the dll directly, you should install the Visual Studio extension for SQLite. The extension includes the dlls for all platforms (x86, x64, ARM). It also makes sure that the right dll is used for the platform that you are building for.
After you install the extension, it will appear in the references dialog under Windows -> Extensions. Also, when you use the extension, you must change all your project build configurations to be x86 or x64 (on the desktop) or Arm (for Arm devices). It will fail to build if you use AnyCPU.

"Application requires that assembly *** be installed" error while trying to install my ClickOnce app

Here's an error I get when I try to install my application from the publish location:
I have my application (and a DLL used by it) linked to version 1.61.4111... of QWhale.Common which is a 3rd party DLL. I have been used this version since about 4 updates ago and never had this problem. I have no idea which part of my application or DLL could be trying to link to the older version. The only thing I did different on this version is that I moved my application's project folders to a new location in my computer.
Where should I start trying to find where this problem is coming from? Did you ever have this problem before?
As Yahia commented, this can be a licensing issue but if you've been using this assembly for a while and if you've been compiling it with your application, there is a chance that a setting associated with the file could have changed with your projects settings.
Assuming you are using Visual Studio, I recommend opening your Projects properties window and navigating to the Publish tab and opening the Application Files Dialog.
From there, find the referenced, 3rd party assemblies make try setting the Publish Status to Include and the DownloadGroup to (Required).
Save your changes and republish your application.

Categories

Resources