Having used the standard WinForms WebBrowser
control in the past, I was able to get OLECMDID_SHOWSCRIPTERROR
notifications whenever a script error occurs inside the currently loaded page of the hosted web browser control.
Now I'm switching to use Chromium Embedded (through the CefSharp .NET wrapper) and look for something similar.
I could think of injecting some JavaScript code, but really would love to have a solution that does not require to alter the HTML at all.
My question:
Is it somehow possible that Chromium Embedded notifies my application when a JavaScript error occurs in the current loaded page?
(I'm also asking this in the CefSharp group ant think that this might be independent so asking it here on Stack Overflow, too)
Update 1:
I see that there seems to be an OnUncaughtException
function that currently seems to not be implemented by CefSharp. Not sure whether this is about JavaScript errors or CEF errors, though.
To reset the Chromium Edge to its default settings to fix problems, use these steps: Open Microsoft Edge. Click the Settings and more (three-dotted) button from the top-right. Click the Settings option. Click on Reset settings. Click the Restore settings to their default values option.
Getting Chromium to show up inside a .NET WinForms application is relatively easy using CefSharp. CefSharp is an open source project which provides Embedded Chromium for .NET (WPF & WinForms).
But no h2 element exists, so the script fails. Other errors that the Console reports are network errors. To display it in action, navigate to the Network error reported in Console.
Is there a way to suppress the certificate error in Edge chromium. Please suggest Your antivirus can interfere with Microsoft Edge and cause the mentioned error to appear. So you might want to change its configuration and disable certain settings, or you might want to consider disabling or removing your antivirus completely.
Although it does not give you the specificity of explicitly knowing when something is an error, you can bind to the ConsoleMessage
event. I use this in conjunction with Log4Net
to keep track of all console messages from Chromium, which includes most javascript errors:
var webView = new WebView(startUrl, browserSettings);
webView.ConsoleMessage += (sender, args) =>
{
log.Debug(string.Format("Webview {0}({1}): {2}",
args.Source,
args.Line,
args.Message))
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With