I am building a web scraping app using Cefsharp.Offscreen. I use Visual Studio 22 and net framework 6 or 7. I have installed Cefsharp.Offscreen, Cefsharp.WinForms, Cefsharp.Common, cef.redist.x64 and cef.redist.x86 as dependencies.
I have this code:
using CefSharp;using CefSharp.WinForms;namespace cefsharp{ public partial class Form1 : Form { public Form1() { InitializeComponent(); InitializeChromium(); } public ChromiumWebBrowser browser; private void Form1_Load(object sender, EventArgs e) { } private void InitializeChromium() {browser = new ChromiumWebBrowser(); browser.LoadUrl("https://google.com"); this.Controls.Add(browser); browser.Dock = DockStyle.Fill; } }}
When I run the application in x64 debug mode. It gives error in InitializeChromium()
method. Full description of the error is "System.IO.FileNotFoundException: 'Could not load file or assembly 'CefSharp, Version=112.2.70.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138'. The system cannot find the file specified'
I checked /bin folder and coudn't see the "cefsharp.dll" file and some other dlls. I guess, it is because of it. But I don't know how to add them.
Note: I have NU1701 warning in error list.
Also, when I try to change the browser = new ChromiumWebBrowser();
line with browser = new ChromiumWebBrowser("https://google.com");
It gives CS0012 error descripted as "Htmlstring defined in an assembly that is not refferenced" I tried to edit app.config file but, coudnt fix.
How can I fix these issues?