Could not load file or assembly CefSharp - c#

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 error is like picture below.
Anyone can help me this problem? I spent 2 days to research but can't solve it. 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
https://i.stack.imgur.com/8JnS0.png
Update: I installed Orca and see that CefSharp assembly is already included in .msi file as picture below
https://i.stack.imgur.com/g7Ngj.png

Related

to run this program you must install .net (for a net5.0 windows forms app windows 11)

I built a small C# windows forms project on Windows 11 using net5. It runs fine in debug mode under Vstudio 2019 latest (v16.11.8). If it helps any, the "dotnet --list-sdks" commands report that both .NET v5.0.404 and v6.0.101 are installed."dotnet --list-runtimes" reports that runtimes NETCore.App 3.1.22, 5.0.13, and 6.0.1 are installed, along with WindowsDesktop.App versions 3.1.22, 5.0.13, and 6.0.1.
When I build the app I use the post-build event to copy files to a different folder where I double click the .exe file to run the forms app. But the double click always tells me that to run the app I need to install ".NET" (exactly, no other info). Would you like to download it now? I click Yes, the popup dialog disappears, and nothing happens.
I copied the .exe first to the destination folder, and when that failed I copied the json config file, the DLL, and the .pdb file too. But still, no happiness.
I must be missing something simple since the app runs fine under vstudio.
I compared the contents of the Debug/net5.0-windows folder with my destination folder. The Debug folder had 44 other DLLs and a dozen language packs. I suspect that my .exe app cannot find all those DLLs for some reason. It should find them because of all the SDKs and runtimes that are installed. But I don't know enough about how to tell the .exe file to find and use all the installed SDKs and runtimes.
Can someone please tell me what I'm doing wrong and how I can get the exported file to run using the installed runtimes? Thank you.
You can publish it with a single executable option -
https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file#publish-a-single-file-app---visual-studio
You can do this via VS gui or with the .net cli like:
dotnet publish -r win-x64 -p:PublishSingleFile=true --self-contained false
IMO it's one of those cases where the error message is simply misleading.
Got this message even after having installed the latest .NET 5.0 runtime files.
And even after the suggested dotnet publish the application still wouldn't start on the target machine.
Turns out that, in addition to the .NET runtime files, there is also a "Windows Desktop Runtime". Only after installing the latter the app would start normally.

Windows Form C# Application throws Could not load File or Assembly 'Mimekit' when run on different machine

My mail-provider has made an update, which generated some problems using Dot.Net Mail in an older Windows Form C# solution. I found, that it is recommended to use MailKit/Mimekit instead of Dot.Net mail. So I decided also to upgrade to newer Visual Studio 2019, where I can use NuGet packages.
I installed Visual Studio 2019, installed MailKit using Manage NuGet Packages (Browse, Right Click, Install) and made a simple test-program in C# (Windows Form Solution) where I send an Email with some attachments.
The solution works 100 % - as long as I execute the solution (both debug and Release builds on the PC where the program is build.
When I copy the Release version (exe-file) to a similar PC (Win 10, DotNet 4.8) I get the following error: Could not load File or Assembly 'Mimekit, Version 2.10.0.0, Culture=neutral, PublicKey Token=bede1c8a46c66814' or one of its dependencies.
The same happens if I transfer the exe-file to a Win 7 - PC.
I have
Checked that both MailKit an MimeKit is listed in the Solutions References
Tried to uninstall and reinstall both MailKit and MimeKit (version 2.10.0)
Tried to upgrade MimeKit to version 2.10.1
It is my first solution in Visual Studio 2019 - as well as my first use of a NuGet Package.
I expected that the built Release Version could be transferred to another PC as a file copy, but something seems to be missing.
I have no clue what to do !?
#Jada_DK, copying executable alone doesn't make the dependencies available on other PC. You'll need to distribute the application through publish wizard or create an installer. Kindly refer the documentation here. Alternatively, if it's a quick sample application you don't intend to distribute, you can copy the entire bin/debug or bin/release folder to another machine and run the application.

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.

Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=11.0.0.0

I recently upgraded my n-tier solution from .NET 3.5 vs 2008 to 4.5 visual studio 2012. Every thing went fine apart from crystal reports and I had to install new runtime crystal reports for visual studio 2012 from the following link http://downloads.businessobjects.com/akdlm/cr4vs2010/CRforVS_13_0_5.exe.
After installing the above package I had to resolve some deprecated function and properties of
CrystalViewer and after that reports rendering properly in development environment (Windows 7 64 bit, SQL Server 2005, Visual Studio 2012). When I deployed the package in test environment windows server 2008 R2
the Application failed to load by throwing error
Could not load file or assembly Microsoft.ReportViewer.WebForms, Version=11
I managed to resolve ReportViewer.WebForms error by copying the DLL
from C:\Program Files (x86)\Microsoft Visual Studio 11.0\ReportViewer to bin folder of solution and set property copylocal = true and deployed the package. After that I received the error Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=11.0.0.0 . I tried to search that DLL on my machine but couldn't. when project is running in visual studio, In Debug-> Windows->Module the file is not listed however in global assembly cache that file is installed but I don't know how its installed to global cache and from where . I found one solution that I had to install ReportViewer.msi from microsoft package but if i install this package it asks me to install SQL Server 2012 which I dont wan't. Could any one help me to resolve this issue. Thanks
Dont know if this is good to anyone, but search all these dlls:
Microsoft.ReportViewer.Common.dll
Microsoft.ReportViewer.ProcessingObjectModel.dll
Microsoft.ReportViewer.WebForms.dll
Microsoft.ReportViewer.WinForms.dll
Microsoft.ReportViewer.DataVisualization.dll
You find them in C:\Windows\assembly\GAC_MSIL\..., and then put them in the references of your project.
For each of them say: local copy, and check for 32 or 64 bit solution.
You can install the Microsoft Report Viewer 2012 Runtime and change your references so they point to the ones installed by the runtime.
http://www.microsoft.com/en-gb/download/details.aspx?id=35747
I have installed the runtime without it asking for SQL Server 2012. Before installing try uninstalling any previous versions of report viewer.
As Microsoft.ReportViewer.2012.Runtime has Microsoft.ReportViewer.WebForms, Microsoft.ReportViewer.Common and Microsoft.ReportViewer.ProcessingObjectModel libraries, just run this command on PM Console:
Install-Package Microsoft.ReportViewer.2012.Runtime
Note : If you want to completely remove the old Microsoft.ReportViewer.xxx references, you can remove them from Manage NuGet Packages>Installed Packages menu and then remove the related lines from packages.config file in your project. After that it will not comeback again during building of the project.
Could not load file or assembly 'Microsoft.ReportViewer.Webforms'
or
Could not load file or assembly 'Microsoft.ReportViewer.Common'
This issue occured for me in Visual studio 2015.
Reason:
the reference for Microsoft.ReportViewer.Webforms dll is missing.
Possible Fix
Step1:
To add "Microsoft.ReportViewer.Webforms.dll" to the solution.
Navigate to Nuget Package Manager Console as
"Tools-->NugetPackageManager-->Package Manager Console".
Then enter the following command in console as below
PM>Install-Package Microsoft.ReportViewer.Runtime.WebForms
Then it will install the Reportviewer.webforms dll in "..\packages\Microsoft.ReportViewer.Runtime.WebForms.12.0.2402.15\lib" (Your project folder path)
and ReportViewer.Runtime.Common dll in "..\packages\Microsoft.ReportViewer.Runtime.Common.12.0.2402.15\lib". (Your project folder path)
Step2:-
Remove the existing reference of "Microsoft.ReportViewer.WebForms".
we need to refer these dll files in our Solution as "Right click Solution >References-->Add reference-->browse ".
Add both the dll files from the above paths.
Step3:
Change the web.Config File to point out to Visual Studio 2015.
comment out both the Microsoft.ReportViewer.WebForms and Microsoft.ReportViewer.Common version 11.0.0.0 and Uncomment both the Microsoft.ReportViewer.WebForms and Microsoft.ReportViewer.Common Version=12.0.0.0. as attached in screenshot.
Microsoft.ReportViewer.Webforms/Microsoft.ReportViewer.Common
Also refer the link below.
Could not load file or assembly 'Microsoft.ReportViewer.WebForms'
You can download the nuget package too.
I had the same problem for Winforms.
The solution for me is:
Install-Package Microsoft.ReportViewer.Runtime.Winforms
Simply install Microsot.ReportViewer.2012.Runtime nuget package as shown in this answer https://stackoverflow.com/a/33014040/2198830
Add Microsot.ReportViewer 2010 or 2012 in prerequisite of setup project then it first install Report Viewer if it's not present in "C:\Windows\assembly\GAC_MSIL..." and after installing, it installs set up project
In my case, the 'Microsoft.ReportViewer.Common.dll' assembly is not required for my project, so I simply removed all references (Project -> Add Reference... -> ...) (all requirements from Publish tab the VS2013 removed automatically) and all works properly.
I Had the same problem.
The solution for me is:
You must have the same version of: Microsoft.ReportViewer.ProcessingObjectModel registred in C:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.ProcessingObjectModel,
like you have registraded in web.config in developer server:
In my case i was only registred the 13. version in my prodution server and i have the 12. version in developer server.
the solution is install the version 12. in the prodution server too
the version 12. :
https://download.microsoft.com/download/A/1/2/A129F694-233C-4C7C-860F-F73139CF2E01/ENU/x86/ReportViewer.msi
Then now i have the version 12. in the prodution and the report work fine.
*** Remember to reset your IIS after instalation
I resolved this problem, searching the dll's file in C:\Windows\assembly\GAC_MSIL\ and copied to bin directory of the proyect deployed. That work for me.
Although rather late, but you can manually download the required DLLs from nuget at the following link:
https://www.nuget.org/packages/Microsoft.ReportViewer.Runtime.Common/12.0.2402.15
Open the file .Rar Archive, extract the dlls and copy them manually to the bin folder of your publish.
This solution worked for me. Hope that helps !!
I solve it by download the reportviewer.exe and install it.
After the installation, all related assemblies will be available in C:\Windows\assembly\GAC_MSIL, then you can refer it in web config

Mono for Android won't build - Can't find Novell.MonoDroid.CSharp.targets

I followed all of the instructions, and install completed successfully. In MonoDevelop, I go to:
New Solution -> C# -> Mono for Android -> Mono for Android Application, just as it says. When I go to build it, MonoDevelop throws an error, saying:
C:\Users\[NAME]\Documents\Android\HelloAndroid1\HelloAndroid1\HelloAndroid1.csproj: Error: C:\Program Files (x86)\Mono-2.10.8\lib\mono\xbuild\Novell\Novell.MonoDroid.CSharp.targets: Project file could not be imported, it was being imported by C:\Users\[NAME]\Documents\Android\HelloAndroid1\HelloAndroid1\HelloAndroid1.csproj: Imported project: "C:\Program Files (x86)\Mono-2.10.8\lib\mono\xbuild\Novell\Novell.MonoDroid.CSharp.targets" does not exist. (HelloAndroid1)
In addition, under References, "Mono.Android" has an error, and says,
Assembly not available for Android 2.2 (Froyo) (in Mono 2.10.8 (C:\Program Files (x86)\Mono-2.10.8)).
How do I fix this? Uninstalling and reinstalling doesn't help.
Make sure your Active Runtime is set to Microsoft.Net. There should be a combobox on the toolbar for it, or an option in the Project menu.

Categories

Resources