Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 10 2016 09:45
    User @amaitland unbanned @aolko
  • Oct 10 2016 09:36
    @amaitland banned @aolko
  • Feb 11 2016 05:56
    User @amaitland unbanned @miyakedev from this room
  • Feb 10 2016 19:59
    @amaitland banned @miyakedev
Alex Maitland
@amaitland

is there a way to change the region / location to South Africa only in CefSharp

@JaredDrakeZA You can change the following:

How does the website determine region? IP Address? Accept-Language header? timezone?

Secondly, how to disable Cloudflare Security Check (CAPTCHA) when browsing the website.

If CloudFlare has a server side component to it's captcha then it's unlikely you can disable it.
I'd search for something like headless chrome cloudflare.

1 reply
buhtig0815
@buhtig0815
RequestHandler.OnSelectClientCertificate () is not being called after CefSharp.Wpf.NETCore 89.0.170. Create a NET5 WPF project. Add a reference to CefSharp.Wpf.NETCore version 89.0.170 or lower. Add a ChromiumWebBrowser to the MainWindow.xaml. In the code behind set the address of a site that uses client certificates, a custom RequestHandler and the LoadError eventhandler. Build and run. Up until 89.0.170 the OnSelectClientCertificate() will be called. Change the PackageReference to version 90.5.70-pre or higher. Clean, Build and Run. Now the error eventhandler will hit with: ERR_SSL_CLIENT_AUTH_CERT_NEEDED. But only if the visiting website ask for a certificate after a redirect. Testsites like https://certauth.idrix.fr/ always work. I looked at all the changes in CEFSharp/CEF/Chromium starting in version 90/4430/90.0.4430.30. I can't find any clues on why it behaves differently. Any suggestions on where to look?
Alex Maitland
@amaitland
@buhtig0815 How does Chrome behave at the same version? I don't recall any reports of similar issues. You can try asking on https://magpcss.org/ceforum/viewforum.php?f=6 to see if anyone in the wider CEF community has experienced a similar problem.
buhtig0815
@buhtig0815
@amaitland Mmmh, apparently I didn't search in the right places. On the link you provided it is sitting there on the top of the page. So yes, it seems to be a CEF issue https://magpcss.org/ceforum/viewtopic.php?f=6&t=18693&sid=3ddb0b974945aac491af6dd825b47419 handled here https://bitbucket.org/chromiumembedded/cef/issues/3200/sso-throwing-onloaderrors-with. A trial fix seems to be available today (2021-11-10). We will just wait for the next version and hope for the best. Thanks!
Alex Maitland
@amaitland

https://bitbucket.org/chromiumembedded/cef/issues/3200/sso-throwing-onloaderrors-with. A trial fix seems to be available today (2021-11-10).

@buhtig0815 I've updated master with the latest beta CEF build and you can test out the fix using a CI nuget package available from https://www.myget.org/gallery/cefsharp
Changes are included in 96.0.120-CI4308

If the problem still reproduces then if you have an example url that reproduces the problem then it's probably worth posting on the bitbucket issue for testing purposes.

joe-williams-cccu
@joe-williams-cccu

Hello, firstly, it has been awhile but I am grateful to see this project still being maintained @amaitland - thank you.

I noticed it is now possible to take screenshots via DevTools, which is awesome. However, I am trying to capture a full page screenshot (that is, capture everything beyond the current viewport) but my results always return a screenshot of the current viewport (that is, what the user is currently looking it).

My code is based on the example in the docs: https://github.com/cefsharp/CefSharp/wiki/General-Usage#screenshots but I note an optional (and experimental) boolean parameter is available captureBeyondViewport. Regardless, I end up with a screenshot of just the current view. Is it possible to take a fullpage screenshot via this method?

 using (var devToolsClient = uiTabbedBrowserControl.CurrentTab.Browser.GetDevToolsClient())
 {
                var result = await devToolsClient.Page.CaptureScreenshotAsync(null, null, null, null, true);
                File.WriteAllBytes(@"C:\Users\joe\Desktop\test1.png", result.Data);
 }

I am rusty around the edges, so am happy to concede I am missing something blindingly obvious. Thank you for any help, as always.
Version: WinForms, 95.7.14

Alex Maitland
@amaitland

Hello, firstly

Hi @joe-williams-cccu, it has been a while :smile:

it has been awhile but I am grateful to see this project still being maintained

yep, still going :smile:

I am rusty around the edges, so am happy to concede I am missing something blindingly obvious.

The DevTools protocol in CefSharp is generated, provides raw access to the underlying protocol. I am working on a cutdown version of PuppeteerSharp specifically for CefSharp that will provide a nicer API for using the DevTools protocol. See https://github.com/cefsharp/PuppeteerSharp.Embedded#puppeteersharp-embedded-cefsharp (There's no official nuget package as yet).

Anyway back to the question. the upstream documentation is actually fairly lacking. Little bit of research and it looks like you need to provide the clip param also. See https://bugs.chromium.org/p/chromium/issues/detail?id=1198576#c17

Tested with WinForms version 95.7.141 and the following appears to work:

using (var devToolsClient = browser.GetDevToolsClient())
{
    //Get the content size
    var layoutMetricsResponse = await devToolsClient.Page.GetLayoutMetricsAsync();
    var contentSize = layoutMetricsResponse.ContentSize;

    var viewPort = new Viewport()
    {
        Height= contentSize.Height,
        Width = contentSize.Width,
        X = 0,
        Y = 0,
        Scale = 1 
    };

    // https://bugs.chromium.org/p/chromium/issues/detail?id=1198576#c17
    var result = await devToolsClient.Page.CaptureScreenshotAsync(clip: viewPort, fromSurface:true, captureBeyondViewport: true);

    return result.Data;
}
joe-williams-cccu
@joe-williams-cccu
@amaitland As always, you are tremendously helpful! Thank you. (I've sent a small donation as a thank you - it will never be enough for your efforts in this project, though 😋)
Łukasz Szafirski
@FLAMESpl

Hi, I have following code

        private async Task ExecuteAsync(Func<ChromiumWebBrowser, Task> action)
        {
            using var browser = new ChromiumWebBrowser(new HtmlString(htmlContent));
            var loadResponse = await browser.WaitForInitialLoadAsync();

            if (loadResponse.Success)
            {
                await action(browser);
            }
            else
            {
                logger.LogError(
                    "Chromium browser failed to load with error code: {ErrorCode}",
                    loadResponse.ErrorCode);
            }

            browser.Dispose();
        }

When called, application hangs on var loadResponse = await browser.WaitForInitialLoadAsync(); indefinitely.
If I remove this line exception is thrown instead that says:

System.Exception: 'The ChromiumWebBrowser instance creates the underlying Chromium Embedded Framework (CEF) browser instance in an async fashion. 
The undelying CefBrowser instance is not yet initialized. Use the IsBrowserInitializedChanged event and check the IsBrowserInitialized property to 
determine when the browser has been initialized.'

I have also tried subscribing to lifecycle events but they were never raised.

What should I do in this scenario?

2 replies
Krishna Chaitanya M
@chaitanyajun12
image.png

@amaitland In our application, we use CefSharp Winforms library and we open multiple instances CefSharp browsers in different tabs. There is an option to close the tab and the expectation is the CefSharp browser instance should get killed and it happens that way.

But, in some cases what we observe is even after all the tabs are closed in the application, still some of the CefSharp browser instances show up in the task manager. Is possible to happen from the runtime point of view?

Alex Maitland
@amaitland

Thank you.

@joe-williams-cccu You are most welcome :smile:

I've sent a small donation as a thank you

An unexpected birthday surprise, thank you very much! :smile:

Alex Maitland
@amaitland

still some of the CefSharp browser instances show up in the task manager.

@chaitanyajun12 The Network/Storage/Audio services, GPU Process,CrashPad Handlerprocesses are independent of the browser instances and will continue to run untilCef.Shutdown` is called.

Krishna Chaitanya M
@chaitanyajun12
@amaitland Yes there can be some processes present. But, I was of the assumption that the renderer process should not be present once the browser instance is closed. Am I correct on this?
Alex Maitland
@amaitland
@chaitanyajun12 Depends on the version. What version are you using?
Krishna Chaitanya M
@chaitanyajun12
@amaitland I'm using CefSharp 94.4.50.
dadloo
@dadloo

I have a problem with cors after updating cefsharp.winforms from 79.1.360 to 95.7.141.

Uncaught DOMException: Blocked a frame with origin "akela://" from accessing a cross-origin frame.
    at Player._onLoadWorskpace (webpack:///./pages/player/controller.js?:462:38)
    at HTMLIFrameElement.dispatch (akela://common/assets/js/jquery-latest.min.js:2:41772)
    at HTMLIFrameElement.y.handle (akela://common/assets/js/jquery-latest.min.js:2:39791)
  • i have custom scheme for akela but do not have custom scheme for webpack (never needed to)
  • i have set header for Headers.Add("Access-Control-Allow-Origin", "*");

After update i had to remove (because of the changes):

            this.browser.BrowserSettings.FileAccessFromFileUrls = CefState.Enabled;
            this.browser.BrowserSettings.UniversalAccessFromFileUrls = CefState.Enabled;
            this.browser.BrowserSettings.WebSecurity = CefState.Enabled;

instead i included:

            cefSettings.CefCommandLineArgs.Add("allow-universal-access-from-files");
            cefSettings.CefCommandLineArgs.Add("allow-file-access-from-files");
           //i thought this will help solve the issue (as a last resort, not really comfortable with this solution), but for some reason cors problem is still there (it feels like it is ignored?)
           // cefSettings.CefCommandLineArgs.Add("disable-web-security");
           //cefSettings.CefCommandLineArgs.Add("disable-features", "OutOfBlinkCors");

I am lost at what I can do to make it work again. I have a feeling that my command line arguments are being ignored maybe (at least disable-web-security)? Is there a way to check that those arguments are applied properly?

Francois Larouche
@larouchefrancois

Hello all, hopefully it's an easy one.
I was wondering why some ajax requests are not detected in OnBeforeBrowse when I click in the browser link?
The specific case is as followed in client side code:

<a href="#" onclick="new Ajax.Updater('sidebar', '/account/signup_form', {asynchronous:true, evalScripts:true}); return false;">&lt;&lt; Register</a>

I can detect many types of XHR but not that one.

Alex Maitland
@amaitland

I'm using CefSharp 94.4.50.

@chaitanyajun12 Calling ChromiumWebBrowser.Dispose should close the associated CefSharp.BrowserSubProcess.exe render process instance. Starting in version 95 there is a spare render process that will be closed when Cef.Shutdown is called.

Make sure you are correctly disposing of the browser.

I have a feeling that my command line arguments are being ignored maybe

@dadloo If you load chrome://version/ in the ChromiumWebBrowser instance you should see the command line args

2 replies
Alex Maitland
@amaitland

I was wondering why some ajax requests are not detected in OnBeforeBrowse when I click in the browser link?

@larouchefrancois Do you mean OnBeforeResourceLoad?

3 replies
Alex Maitland
@amaitland

I have a problem with cors after updating cefsharp.winforms from 79.1.360 to 95.7.141.

@dadloo Are you using the file:/// scheme?

2 replies
Alex Maitland
@amaitland

cefSettings.CefCommandLineArgs.Add("disable-features", "OutOfBlinkCors");

@dadloo From memory it's no longer possible to disable OutOfBlinkCors, and a quick check confirms it.
https://magpcss.org/ceforum/viewtopic.php?f=6&t=18157

1 reply
Krishna Chaitanya M
@chaitanyajun12
Thank you @amaitland. Will check.
Serhiy Mashkovskyi
@serhiy1994
Migrating from 90.6.5 to the new release. Is there any analogues to these old parameters?
config.FileAccessFromFileUrls = (!CrossDomainSecurity).ToCefState(); config.UniversalAccessFromFileUrls = (!CrossDomainSecurity).ToCefState(); config.ApplicationCache = ApplicationCache.ToCefState();
Alex Maitland
@amaitland

Migrating from 90.6.5 to the new release. Is there any analogues to these old parameters?

@serhiy1994 Breaking changes are listed in the Releases for each version on GitHub, you'll find details there.

Shishir Halaharvi
@ShishirH

Hello, I am using CefSharp (WPF) for a VSIX project. When I try to run the program, I get a

System.Windows.Markup.XamlParseException
  HResult=0x80131501
  Message='The invocation of the constructor on type 'CefSharp.Wpf.ChromiumWebBrowser' that matches the specified binding constraints threw an exception.' Line number '19' and line position '10'.
  Source=PresentationFramework
  StackTrace:
   at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
   at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
   at P_Inti.MyWindowControl.InitializeComponent() in C:\Dev\P-Inti\P-Inti\MyWindowControl.xaml:line 1

Inner Exception 1:
FileNotFoundException: Could not load file or assembly 'CefSharp.Core.Runtime, Version=95.7.141.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138' or one of its dependencies. The system cannot find the file specified.

I have manually added the following files and set them to copy always:

  1. CefSharp.BrowserSubprocess.exe
  2. CefSharp.BrowserSubprocess.Core.dll
  3. Ijwhost.dll
  4. CefSharp.Core.Runtime.dll
  5. CefSharp.Core.dll
  6. CefSharp.dll
  7. CefSharp.Wpf.dll
  8. libcef.dll
  9. chrome_elf.dll
  10. icudtl.dat
  11. snapshot_blob.bin
  12. v8_context_snapshot.bin

I can find the above files in bin after I build, but I cannot figure out why CefSharp,Core.Runtime is still reported missing.
This is on VS 2022 on Windows 11, with CefSharp version 95.7.141.

Any help would be very appreciated. Thanks in advance!

Alex Maitland
@amaitland

I am using CefSharp (WPF) for a VSIX project

@ShishirH Try using build 96.0.130-CI4313 from https://www.myget.org/feed/cefsharp/package/nuget/CefSharp.Wpf
See if commit cefsharp/CefSharp@5447c8d makes a different.

Ahmed Talaat
@bahnay7:matrix.org
[m]

i have code to get data from html table to datagridview using webbrowser thats my code:
Dim mytable As HtmlElement = WebBrowser1.Document.GetElementById("DataGridemplis")
Dim dtData As DataTable = New DataTable
dtData.Columns.Add("id")
dtData.Columns.Add("name")
dtData.Columns.Add("code")
dtData.Columns.Add("school")
dtData.AcceptChanges()
Dim dr As DataRow = Nothing
For Each row As HtmlElement In mytable.GetElementsByTagName("tr")
dr = dtData.NewRow
Dim cells As HtmlElementCollection = row.GetElementsByTagName("td")
Dim i As Integer = 0
Do While (i < cells.Count)
dr(i) = cells(i).InnerText
i = (i + 1)
Loop
dtData.Rows.Add(dr)
Next
dtData.AcceptChanges()
DataGridView2.DataSource = dtData

and it work very well
but now i use cefsharp chromium and i cant get data from html table to datagridview
I want get data from html table to datagridview using cefsharp

Krishna Chaitanya M
@chaitanyajun12

@amaitland, while running our application with CefSharp support, in few of the VMs we are getting the below crash.

As part of our code, we are stringifying the CefSettings object via JavascriptSerializer. But, we see the below crash happening in few of the machines. Could you let me know if you have faced this anytime before?

17/11/2021 15:16:21 .NET Runtime Error Application: Sample.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.AccessViolationException at System.String.wcslen(Char) at System.String.CtorCharPtr(Char) at CefSharp.Core.CefSettingsBase.get_BrowserSubprocessPath() Exception Info: System.Reflection.TargetInvocationException at System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object, System.Object[], System.Object[]) at System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo) at System.Web.SecurityUtils.MethodInfoInvoke(System.Reflection.MethodInfo, System.Object, System.Object[]) at System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(System.Object, System.Text.StringBuilder, Int32, System.Collections.Hashtable, SerializationFormat) at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(System.Object, System.Text.StringBuilder, Int32, System.Collections.Hashtable, SerializationFormat, System.Reflection.MemberInfo)

edhalsim
@edhalsim
Hi. I need to detect when a server request, such as the result of clicking a link, generates a non-200 response and pass that info back to my CefSharp.Offscreen program. I'm using an overridden OnResourceResponse to detect the bad status, but I don't know how to get my main program to respond to it. I tried throwing an exception and catch it in my main program to no avail.
Alex Maitland
@amaitland

i have code to get data from html table to datagridview using webbrowser thats my code:

@bahnay7:matrix.org You can acess the DOM using javascript see https://github.com/cefsharp/CefSharp/wiki/General-Usage#2-how-do-you-call-a-javascript-method-that-returns-a-result

A simple example getting the cells from a table might look like:

var response = await webBrowser.EvaluateScriptAsync(@"(function (){
    let srcTable = document.getElementsByTagName('table')[0];
    return Array.from(srcTable.rows, row => Array.from(row.cells, cell => cell.innerText));
    })();
");

dynamic arr = response.Result;

foreach(dynamic row in arr)
{
    foreach(var cell in row)
    {
        var data = (string)cell;
    }
}
Alex Maitland
@amaitland
@chaitanyajun12 I've never seen anyone trying to turn CefSettings into JSON before. Access violation would suggest the unmanaged memory was freed. Are you attempting to access CefSettings after you've called Cef.Initialize? The instance will be automatically Disposed.
3 replies
Alex Maitland
@amaitland
@edhalsim Perhaps http://cefsharp.github.io/api/95.7.x/html/E_CefSharp_OffScreen_ChromiumWebBrowser_FrameLoadEnd.htm suites your purpose. You can get the http status code for the frames main resource load.
5 replies
Serhiy Mashkovskyi
@serhiy1994
By the way, is it possible to open the GitHub CefSharp project in VS2015?
Holger Prause
@holger-prause
hello - i got a question about javsscript errors in the devtool windows
they dont show up if using EvaluateScriptAsync - but they do show up if explicitly calling from devtools console - can i do something there?
Alex Maitland
@amaitland

By the way, is it possible to open the GitHub CefSharp project in VS2015?

@serhiy1994 VS2019 or higher is required.

they dont show up if using EvaluateScriptAsync - but they do show up if explicitly calling from devtools console - can i do something there?

@holger-prause Already asked at https://github.com/cefsharp/CefSharp/discussions/3900

Please just ask your question once and wait for a reply, thanks.

Ramakrishna kolli
@ramkolli:matrix.org
[m]
Hi Team, I have WPF application using Cefsharp, I want to enter text in input field of browser using WPF onscreen keyboard . Guide me right approach
Ramakrishna kolli
@ramkolli:matrix.org
[m]
:point_up: Edit: Hi Team, I have WPF application using Cefsharp, I want to enter text in input field of browser using WPF custom onscreen keyboard . Guide me right approach
Alex Maitland
@amaitland
@ramkolli:matrix.org The http://cefsharp.github.io/api/96.0.x/html/E_CefSharp_Wpf_ChromiumWebBrowser_VirtualKeyboardRequested.htm is called when the browser wants show/hide the keyboard. It's up to you to actually show an onscreen keyboard. The project source has an example OS using the win 10 oak
2 replies
*osk
Nick
@vwmberry95
@amaitland 96.0.170 packages are not in Nuget
Alex Maitland
@amaitland

96.0.170 packages are not in Nuget

@vwmberry95 Thanks, I haven't forgotten. Had a lot of rain here of late including a very heavy downpour which had water in my garage (my computer is in the garage). Had to deal with that as a priority.

Packages should appear shortly.

Nick
@vwmberry95
Great, thanks!
chylex
@chylex
hi, there used to be devtools_resources.pak in packages\cef.redist.x86.<version>\CEF but since about version 90 it's not there anymore, are dev tools always included now?
3 replies
Ramakrishna kolli
@ramkolli:matrix.org
[m]
@amaitland: Google earth (https://earth.google.com/web/) search not working in cefsharp, is their any settings specifically i need to add?