cefsharp / CefSharp

.NET (WPF and Windows Forms) bindings for the Chromium Embedded Framework
http://cefsharp.github.io/
Other
9.89k stars 2.92k forks source link

Use CefSharp in .NET WebApi #2266

Closed lexon0011 closed 6 years ago

lexon0011 commented 6 years ago

I need CefSharp in my WebApi for converting HTML Code to PDF files. If I use the library in the WebApi project, I get the following error: Could not load file or assembly 'CefSharp.BrowserSubprocess.Core.DLL' or one of its dependencies.

I attach a simple .NET WebApi Project, which has the CefSharp library included. On running the project, the error occurred.

Please tell me how I can use the library in a .NET WebApi project.

Thanks!

merceyz commented 6 years ago

No binary files

Please use the Bug Report template provided at https://github.com/cefsharp/CefSharp/blob/master/ISSUE_TEMPLATE.md#bug-report

Fork the https://github.com/cefsharp/CefSharp.MinimalExample project and provide an example that reproduces your problem.

lexon0011 commented 6 years ago

I create a repository for the sample.

  1. clone the repository: https://github.com/lexon0011/CefSample
  2. restore Nuget packages
  3. change build configuration to x86
  4. run the application
perlun commented 6 years ago

Is your WebApi project using .NET Core or .NET Framework 4.x?

lexon0011 commented 6 years ago

.NET Framework 4.6.1

amaitland commented 6 years ago

Duplicate of #1127

lexon0011 commented 6 years ago

But no working answer ...

amaitland commented 6 years ago

There are quite a few suggestions, the most practical in my opinion is to switch to using a different CEF wrapper, CefGlue or ChromiumFx are two other options.

daniel-scatigno commented 6 years ago

@lexon0011 have you managed to do it? I´m trying to work with CefSharp.Offscreen in a Web Application. If not, have you moved to CefGlue or ChromiumFX?

lexon0011 commented 6 years ago

I use the library in an console application and call this application from the WebApi

utkarshagrawal90 commented 3 years ago

I use the library in an console application and call this application from the WebApi

Hi @lexon0011, Please can you elaborate your solution as in how you use console application and call it from web api?

amaitland commented 3 years ago

If you need to perform simple automation tasks like generate pdfs or take screenshots then headless chrome with Puppeteer Sharp is probably better option nowadays

https://levelup.gitconnected.com/using-puppeteer-sharp-as-a-headless-static-html-component-generator-fd17fbef0352

Shashankkt commented 1 year ago

Puppeteer sharp doesn't work in windows container and by doing setcomp=unconfined in linux container (which is not safe) it works. Locally on your laptop it will work but not on productions hosts.