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
@BgR8 Extension support is extremely limited. Details are at cefsharp/CefSharp#2497
Make sure the extension api you require are supported first
Alex Maitland
@amaitland

@pwilkowski Also did you set <EnableDynamicLoading>true</EnableDynamicLoading> in your csproj file so the dependencies are copied to your plugin output?
https://docs.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support#plugin-with-library-dependencies

They would be copied by default if you did a dotnet publish

pwilkowski
@pwilkowski
@amaitland thanks i used McMaster.NETCore.Plugins wrapped CEF inside DLL, loaded that DLL with this plugins and it worked.
hicks86
@hicks86

The assembly with display name 'CefSharp.Core.Runtime' failed to load in the 'Load' binding context of the AppDomain with ID 3

@hicks86 First step is to confirm if your plugin is going to be run in the default AppDomain. Because CefSharp is built with Visual C++ which only runs in the default AppDomain (won't work from a different one).

If you are then it should just be a matter of loading the libraries.

If not then you can use

  • Try using NetOffice which I believe others have successfully integrated CefSharp into office applications with, not tried myself so you'd probayl need to confirm with the NetOffice devs first.
  • another CEF based wrapper like CefGlue or look for a different browser altogether

Hi I have checked and the addin-express and VSTO taskpanes load into a separate domain. So unfortunately it looks like CefSharp is out - our project is too big and tied into the AddIn for now but I'll note down that library for future. I will also take a look at CefGlue as you recommended. Cheers

larouchefrancois
@larouchefrancois

@amaitland So things are going well on my handling with resourcehandler except once I'm at OnResourceLoadComplete I don't get the WebBrowser object with the newly followed Url info. For instance, on the first load of the page I get about:blank instead of the url requested. Why I'm mentioning that event is because on the normal flow it's where it gets updated. And in my case it's where I'm updating my form to get the new data. For example, I'm only updating the info if the request url = to the one in the browser (that's how I know if it's the main request or any subsequent calls for other resources like css, pictures, js, etc) in the raised event , something in the like of

    private void chromiumBrowser_OnResourceLoadCompleteEvent(object sender, OnResourceLoadCompleteEventArgs args)
    {
                // If main url
                if (args.ChromiumWebBrowser.Address == args.Request.Url)
                {
                    this.InvokeOnUiThreadIfRequired(() =>
                    {
                        // Update UI controls

I tried to register the resourcehandler in ProcessRequestAsync with ChromiumWebBrowser.RegisterResourceHandler(request.Url, stream); but it doesn't make any difference. Obviously I can figure out a workaround but it would be dirty and I would rather prefer to get the clean supported way. I was wondering if I was missing something.

jsoldi
@jsoldi

Interesting, thanks. Please create a new issue https://github.com/cefsharp/CefSharp/issues/new/choose

@amaitland OK I created a bug report cefsharp/CefSharp#3850. Let me know if it needs any additional info.

larouchefrancois
@larouchefrancois
@amaitland To give more info to help. I saw that only on the initial request of the url the ChromiumWebBrowser contains the former loaded page URL. All subsequent requests it for resources contained in the main url (initial request) such as css, images, etc will have the proper Address in the ChromiumWebBrowser. And the Browser and its Frame as well (which I guess is really important as well)
What I wonder is when the ChromiumWebBrowser gets its Address set, and the Browser object set as well. I tried to first search in the CefSharp code and I didn't find it and then in Cef project and not quite find it. Problem with hooking and event type of solution it's really hard to debug or analyze. If I can find perhaps I can do it. Obviously in the normal flow it is set somewhere before OnResourceLoadComplete. I would be very curious when it happens and if I can change it.
pwilkowski
@pwilkowski
It appears to be I cannot call Cef.Initialize second time but there is something strange going on. I have created DLL plugin with cef that is suppose to shutdown properly when unloaded. Loading it second time crashes process. Is there any way to completely uninitialize CEF or at least grab the previous "initialization" ?
pwilkowski
@pwilkowski
do i need to dispose settings also?
pwilkowski
@pwilkowski
alternatively is there a way to "cache" existing cef handles?
larouchefrancois
@larouchefrancois
@amaitland Last observation that could be of interest. I noticed that the initial page I'm calling is not part of the Network requests in the devtool associated to my project. I tried to force the Url on the ChromiumWebBrowser and if it helps for the displaying of my data it does not work in there and it should be taken care of. I'm going to continue to investigating. I was hoping that you would say hey! It's an easy one just check this or set that since you know so much the solution :)
Angshuman Agarwal
@angshuman-agarwal
@amaitland : How do we enable permission api for clipboard access : https://googlechrome.github.io/samples/async-clipboard/. Is there a way please ? I tried in CefSharp (WPF) v92, it does not seem to work due to permission denied.
chacham2
@chacham2
How do you change the font size of the browser? I'm looking to start it as a browser preference, not page by page.
chacham2
@chacham2
So far, i have tried BrowserSettings.DefaultFontSize, BrowserSettings.DefaultFixedFontSize, CefSettings.CefCommandLineArgs.Add("minimum_font_size", "18"), CefSettings.CefCommandLineArgs.Add("minimum_logical_font_size", "18"),
chacham2
@chacham2
Wait a sec, i set BrowserSettings.DefaultFontSize, BrowserSettings.DefaultFixedFontSize but never told cef to use those settings. That is, when using CefSettings, the object must be passed via Cef.Initialize(Settings). Is there something similar for BrowserSettings?
To answer my own question, it's passed when starting the browser: New ChromiumWebBrowser("<url>") Though. it still seems not to b doing anything.
chacham2
@chacham2
Okay, it works if BrowserSettings is used to set MinimumFontSize. I think i will set all 4 just in case. Not sure the difference between them, necesarily.
Krishna Chaitanya M
@chaitanyajun12

@amaitland Is there an API in WinForms CefSharp for passing JSON string from JS to C# layer ?

I see that there is one in WPF CefSharp JavascriptMessageReceived. I see there is no equivalent in Winforms CefSharp. Is there one?

Krishna Chaitanya M
@chaitanyajun12
@chacham2 I see this event is present only in WPF CefSharp library and not in Winforms CefSharp. Is there any alternative for Winforms CefSharp?
chacham2
@chacham2
I'm using it in winforms
Actually I don't see the JavascriptMessageReceived in Winforms library..
chacham2
@chacham2
The link i sent is the ChromiumWebBrowser which is used in WinForms
I mean, i am using that right now in the current project i am working on.
Krishna Chaitanya M
@chaitanyajun12
image.png@chacham2 But the link which you sent is Wpf library only
Please correct me if I'm not understanding correctly.
So, basically in my project I'm using CefSharp.Winforms library only and not CefSharp.Wpf library.
chacham2
@chacham2
Okay, now i see, the link shows wpf. Sorry, i missed that. But, i am using it in WinForms
In VB: AddHandler Chromium.JavascriptMessageReceived, Sub(Sender As Object, Arguments As JavascriptMessageReceivedEventArgs) ...
jsoldi
@jsoldi
Anyone knows if it's possible to identify which iframe elements in the main frame correspond to which CEF frame? These are sites which I have no control over, so I cannot set a name on the iframe HTML, and calling setAttribute('name', 'something') on the iframe seems to have no effect on CEF's frame name. So basically I have a list of iframes on the main frame's javascript site I get like document.querySelectorAll('iframe'), and another list on the C# site I get by calling browser.GetFrameIdentifiers().Select(id => browser.GetFrame(id)), and they both have the same number of frames, but I have no idea which one correspond to which one on the other side.
Alex Maitland
@amaitland

that's how I know if it's the main request

@larouchefrancois You can use IRequest.ResoruceType to determine if the resource request is for the MainFrame.

It appears to be I cannot call Cef.Initialize second time

@pwilkowski That is correct, it's a limitation of Chromium. See https://github.com/cefsharp/CefSharp/wiki/General-Usage#initialize-and-shutdown

I have created DLL plugin with cef that is suppose to shutdown properly when unloaded. Loading it second time crashes process

Once Cef.Shutdown is called you cannot use the browser again. If you absolutely must support this then you would need to run the browser in a separate process.

or at least grab the previous "initialization"

What do you mean by this exactly?

do i need to dispose settings also?

What settings are you referring to?

alternatively is there a way to "cache" existing cef handles?

What is happening in your scenario? Are the dlls being unloaded? I need a clearer understanding of what's going on.

How do we enable permission api for clipboard access : https://googlechrome.github.io/samples/async-clipboard/.

@angshuman-agarwal CEF doesn't provide an API for handling those permissions requests. https://bitbucket.org/chromiumembedded/cef/issues/2921/add-support-for-asynchronous-clipboard-api

It's possible you might be able to use DevTools to set the permissions.

Alex Maitland
@amaitland

Okay, it works if BrowserSettings is used to set MinimumFontSize. I think i will set all 4 just in case. Not sure the difference between them, necesarily.

@chacham2 For reference there are also some preferences that can be used to change the min font size at runtime.

https://github.com/cefsharp/CefSharp/blob/4608924d5a0c676857720917550674b88bd7b701/CefSharp.Example/Handlers/RequestContextHandler.cs#L29

I see that there is one in WPF CefSharp JavascriptMessageReceived. I see there is no equivalent in Winforms CefSharp. Is there one?

@chaitanyajun12 The exact same event exists in WinForms.

https://cefsharp.github.io/api/51.0.0/html/T_CefSharp_WinForms_ChromiumWebBrowser.htm#!
http://cefsharp.github.io/api/75.1.x/html/E_CefSharp_Wpf_ChromiumWebBrowser_JavascriptMessageReceived.htm

Actually I don't see the JavascriptMessageReceived in Winforms library..

The API Doc is version specific. Here you are comparing version 51 to version 75. Both very very old outdated version

chacham2
@chacham2
@amaitland Thank you for the note!
Krishna Chaitanya M
@chaitanyajun12
Oh missed that @amaitland. Thank you for pointing it out. @chacham2 Thanks to you too. :)
jsoldi
@jsoldi

Anyone knows if it's possible to identify which iframe elements in the main frame correspond to which CEF frame? These are sites which I have no control over, so I cannot set a name on the iframe HTML, and calling setAttribute('name', 'something') on the iframe seems to have no effect on CEF's frame name. So basically I have a list of iframes on the main frame's javascript site I get like document.querySelectorAll('iframe'), and another list on the C# site I get by calling browser.GetFrameIdentifiers().Select(id => browser.GetFrame(id)), and they both have the same number of frames, but I have no idea which one correspond to which one on the other side.

In case anyone else has this question, here is what I'm doing now. If someone has a better solution that'd be awesome since this feels a little hacky:

public static async Task<IFrame> GetFrame(this IFrame parent, string getFrameScript)
{
    string prevName = "___e2XuTklANdkaRTav";
    await parent.EvaluateScriptAsync($"window.{prevName} = document.activeElement; ({getFrameScript})?.focus();");
    await Task.Delay(1); // This is needed to wait for the frame to actually gain focus
    var frame = parent.Browser?.FocusedFrame ?? parent;
    await parent.EvaluateScriptAsync($"document.activeElement instanceof HTMLElement && document.activeElement.blur(); window.{prevName} instanceof HTMLElement && window.{prevName}.focus(); delete window.{prevName}");
    return frame;
}
kcwms
@kcwms
...using CefSharp.Winforms v92.0.260. Does CefSharp expose the amount of memory used by any specific instance ?
ukandrewc
@ukandrewc
@jsoldi I set the frameId in a variable then you can find it either side from that
Frame.EvaluateScriptAsync($"var __FrameID = {e.Frame.FrameId}") Frames.Add(e.Frame)
jsoldi
@jsoldi
@ukandrewc I do something similar to get the frame ID from inside the frame document, but what I also need is to identify the frame from outside the iframe, so I have an iframe HTML element (which may be in another domain) and then I need to get the frame ID of that iframe.
Alex Maitland
@amaitland

Does CefSharp expose the amount of memory used by any specific instance ?

@kcwms Short answer is no. There is no API for that. We are limited by the API exposed by the Chromium Embedded Framework(CEF).

What are you trying to do exactly?

bobodeveloper-anonymous
@bobodeveloper-anonymous
I use CefSharp 94.4.2 I found problem about black screen appear before webpage show on first-time initialize. Anyone encountered this problem?
1 reply
ukandrewc
@ukandrewc
@jsoldi Not sure if I've missed your point but you would then just search for the FrameId using "iframe.contentWindow.__FrameID"
Krishna Chaitanya M
@chaitanyajun12
@amaitland In the latest version of cef.redist.x64.94.4.5, we see there are two dlls which are not getting picked vk_swiftshader.dll and vulkan-1.dll when we are referencing CefSharp dlls in csproj file. We see these dlls in the downloaded nuget package. Are these two dlls required?