ChromiumWebBrowser BrowserSettings

Having problems with building or using the CefSharp .NET binding? Ask your CEF-related questions here. Please ask general usage questions on StackOverflow.

Moderator: amaitland

ChromiumWebBrowser BrowserSettings

Postby sidg » Mon May 16, 2022 4:14 pm

Hello All,

I feel silly for having to ask this in the forum but I am kind of stuck. I need to allow use of local files, and thus need to set the appropriate BrowserSettings but I can't find a way to instantiate a BrowserSettings object to do that. The IBrowserSettings exists in the CefSharp namespace and there is a settable BrowserSettings property of that type but how do I create a concrete instance from code behind?

I am using version 94.

Thanks for any help!
sidg
Newbie
 
Posts: 2
Joined: Mon May 16, 2022 4:06 pm

Re: ChromiumWebBrowser BrowserSettings

Postby amaitland » Tue May 17, 2022 1:59 am

new CefSharp.BrowserSettings() should work
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: ChromiumWebBrowser BrowserSettings

Postby sidg » Tue May 17, 2022 6:06 am

Yes, it was silly. I was not including CefSharp.Core.dll. Although setting them seems to have no effect. If I try to do it after the browser has been created, I get an exception telling me I can't do that. If I try to do it at the instantiation of the ChromiumWebBrowser, it seems to work, temporarily, and then at some point during the initialization BrowserSettings get reset to null.

Not sure what the appropriate way to set them is.

I ended up achieving my goal by using a self-hosted web api, but I am curious what I am doing wrong on the BrowserSettings.
sidg
Newbie
 
Posts: 2
Joined: Mon May 16, 2022 4:06 pm

Re: ChromiumWebBrowser BrowserSettings

Postby amaitland » Tue May 17, 2022 2:30 pm

The property is null after the underlying CEF browser instance has been created. This is nothing to worry about. Sounds like it was working.

Using local files is not recommend as the file scheme has very different behaviour/restrictions.

You don't need to use a local webserver, you can use a scheme handler for loading of local resources. https://github.com/cefsharp/CefSharp/wi ... me-handler
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am


Return to CefSharp Forum

Who is online

Users browsing this forum: No registered users and 24 guests