cefsharp- Commandline aurgument not working.

2,853 views
Skip to first unread message

Amit Arya

unread,
Apr 16, 2015, 2:44:33 AM4/16/15
to cefs...@googlegroups.com
 // var setting = new CefSettings();
            var setting = new CefSettings
            {
                BrowserSubprocessPath = "CefSharp.BrowserSubprocess.exe"
            };
            //setting.UserAgent = "UFX.WidgetFX";
           // setting.CefCommandLineArgs.Add("user-agent", "CefSharp");
           // setting.CefCommandLineArgs.Add("enable-media-stream", "0");

i tried many commandline args but not working any 1.
What's wrong with it?

Alex Maitland

unread,
Apr 16, 2015, 4:03:38 AM4/16/15
to cefs...@googlegroups.com
For example see
https://github.com/cefsharp/CefSharp/blob/master/CefSharp.Example/CefExample.cs#L33

Make sure your passing the `CefSettings` object to `Cef.Initialize()`

https://github.com/cefsharp/CefSharp/blob/master/CefSharp.Example/CefExample.cs#L86

If your still having problems then please include a `GIST` containing the full code example.

Alex Maitland

unread,
Apr 16, 2015, 4:08:14 AM4/16/15
to cefs...@googlegroups.com
If you navigate to `chrome://version` you can see some debug info including command line arguments.

Amit Arya

unread,
Apr 16, 2015, 5:27:06 AM4/16/15
to cefs...@googlegroups.com
Thanks for quick reply, I have tried as per above sample. Still not working    
 public MainWindow()
        {
            InitializeComponent();
           
            //var setting = new CefSettings();
            var setting = new CefSettings
            {
                BrowserSubprocessPath = "CefSharp.BrowserSubprocess.exe"
            };
            var architecture = Environment.Is64BitProcess ? "x64" : "x86";
            setting.BrowserSubprocessPath = "..\\..\\..\\output\\CefSharp.BrowserSubprocess.exe";
            //setting.UserAgent = "SefSharp";
           // setting.CefCommandLineArgs.Add("user-agent", "CefSharp");
            setting.CefCommandLineArgs.Add("disable-gpu-vsync", "1");
            setting.CefCommandLineArgs.Add("disable-image-loading", "disable-image-loading");
            setting.CefCommandLineArgs.Add("disable-gpu", "1");
            setting.CefCommandLineArgs.Add("window-size", "800,400");
            Cef.Initialize(setting);
         
        }

Can not find Any command line aurgument in Chrome:/version page.

Alex Maitland

unread,
Apr 16, 2015, 5:29:28 AM4/16/15
to cefs...@googlegroups.com
More your code to before `InitializeComponent()`. By the time your call `Cef.Initialize()` the browser is already initialized with default settings.

Alex Maitland

unread,
Apr 16, 2015, 5:31:04 AM4/16/15
to cefs...@googlegroups.com
I'd usually recommend calling `Cef.Initialize() in your Application class.

Example
https://github.com/cefsharp/CefSharp/blob/master/CefSharp.Wpf.Example/App.xaml.cs#L14

Amit Arya

unread,
Apr 16, 2015, 5:32:59 AM4/16/15
to cefs...@googlegroups.com
Actually i want resize the window size by command line

Alex Maitland

unread,
Apr 16, 2015, 5:40:28 AM4/16/15
to cefs...@googlegroups.com
Which command are you trying to set specifically?

You must call `Cef.Initialize()` before the browser control is initialized otherwise `Cef.Initialize()` will be implicitly called for you (otherwise the browser would fail to load).

Amit Arya

unread,
Apr 16, 2015, 5:46:03 AM4/16/15
to cefs...@googlegroups.com
Thanks, it may work now. 

is it right way to passing arg for re-sizing window?

Amit Arya

unread,
Apr 16, 2015, 5:50:07 AM4/16/15
to cefs...@googlegroups.com
window resizing, window maxmizing and browser url commands .. i will send by command line

Alex Maitland

unread,
Apr 16, 2015, 5:52:03 AM4/16/15
to cefs...@googlegroups.com
You just specify the Width and Height properties like any control.

There are no command line options with width/height.

Alex Maitland

unread,
Apr 16, 2015, 5:55:12 AM4/16/15
to cefs...@googlegroups.com

Alex Maitland

unread,
Apr 16, 2015, 6:02:02 AM4/16/15
to cefs...@googlegroups.com
You interact with the control like you would any `WPF` control.

https://github.com/cefsharp/CefSharp.MinimalExample/blob/master/CefSharp.MinimalExample.Wpf/Views/MainView.xaml#L15

command line args are for tweaking specific browser behaviors, like disabling GPU acceleration, enabling WebRTC, etc.

Amit Arya

unread,
Apr 16, 2015, 6:39:46 AM4/16/15
to cefs...@googlegroups.com
Thanks for All,

I am figuring out the features of cefsharp before implementing in app.

Can we set default url of browser by command-line aurgument, i can't find any aurgument there..

Alex Maitland

unread,
Apr 16, 2015, 6:47:45 AM4/16/15
to cefs...@googlegroups.com
Try toying around with the MinimalExample, create a basic prototype for you application.

`CefSharp` is more like a browser framework than a standalone web browser. you interact with it like a control. You set the `Address` property, or you call `Loadl(url)` method.

https://github.com/cefsharp/CefSharp/blob/master/CefSharp/IWebBrowser.cs#L54


If you have a specific question then ask away, otherwise I'd ask that you actually try the code before asking any further questions.

Nitin Kandpal

unread,
May 3, 2016, 4:47:03 AM5/3/16
to CefSharp
Hi Alex,

I am working with CEFSharp to display panorama on x86 build of my project, but sometimes on frequent loading of same image or different images the screen goes black and the following errors are recorded on the debug file.

[0503/125112:ERROR:gles2_cmd_decoder.cc(14033)] [.Compositor-00614AA0]GL ERROR :GL_INVALID_OPERATION : glCreateAndConsumeTextureCHROMIUM: invalid mailbox name
[0503/125112:ERROR:gles2_cmd_decoder.cc(7430)] [.Compositor-00614AA0]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering.
[0503/140519:WARNING:dns_config_service_win.cc(673)] Failed to read DnsConfig.
[0503/140832:ERROR:ipc_channel_win.cc(465)] pipe error: 995

I am using Cefsharp winform and WPF component and the error is shown in both.

Thank you,
Nitin Kandpal
Reply all
Reply to author
Forward
0 new messages