Search code examples
c#visual-studiochromiumcefsharpchromium-embedded

Error adding ChromiumWebBrowser to project - C# Visual Studio


I am trying to add the Cef.WinForms library to my project and I'm following the steps found here https://tutorialslink.com/Articles/DEVELOPING-CHROMIUM-BASED-BROWSER-IN-Csharp/1468. I was able to add the library find using Nuget, however I did get a warning that it expected .NET 4.6.1 and I have .NET 5.0. I tried to manually install 4.6.1 but it will not allow it as it says a newer version is already installed. This may not even be the cause of my error but I wanted to mention it just in case.

When I try to drag the component ChromiumWebBrowser over to my main form, I get the error seen below. I've searched for this error to try and resolve it but I am so far not finding anything helpful. Does anyone know what I'm missing here?

enter image description here


Solution

  • As noted in the comments, when targeting .Net 5.0 you'll need to use the packages with the NETCore suffix.

    For .Net Core 3.1/.Net 5.0+

    NOTE A minimum of .Net Core 3.1 is required.

    For the .Net 4.5.2 to .Net 4.8


    All packages require Microsoft Visual C++ 2019 or greater.

    Ijwhost.dll

    To support C++/CLI libraries in .NET Core/.Net 5+, ijwhost was created by Microsoft as a shim for finding and loading the runtime. All C++/CLI libraries are linked to this shim, such that ijwhost.dll is found/loaded when the C++/CLI library is loaded. It's important this dll is distributed with your application.