I am using GeckoFx v45
and I am trying to set different proxy.
I tried the following which should normally work.
private void Form1_Load(object sender, EventArgs e)
{
try
{
Xpcom.Initialize("Firefox"); //just in case its not already loaded
GeckoPreferences.User["general.useragent.override"] = UA;
GeckoPreferences.User["network.proxy.type"] = 1;
//replaced by normal valid proxy and port
GeckoPreferences.User["network.proxy.http"] = "1.1.1.1";
GeckoPreferences.User["network.proxy.http_port"] = "1234";
GeckoPreferences.User["network.proxy.ssl"] = "1.1.1.1";
GeckoPreferences.User["network.proxy.ssl_port"] = "1234";
geckoWebBrowser1.Navigate(textBox1.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.InnerException.Message);
}
}
The GeckoBrowser
will never load and it will remain black.
In the output i see a 'System.InvalidCastException' in Geckofx-Core.dll
.
In the metadata I see this from the DLL
,
public static GeckoPreferences Default { get; }
public static GeckoPreferences User { get; }
and I am wondering how can we set that Property
while it is get-only.
I think this is the issue that is not letting my browser load.
When I remove the GeckoPreferences
and simply Navigate
the browser, it works, but without Proxy
obviously.
If this is the issue then how can I properly set the proxy on a Gecko Webbrowser
?
This seems to be a simple issue. When I added your code to my sample I got a runtime error:
Additional information: A String value may not be assigned to 'network.proxy.http_port' because it is already defined as Int32.
So, 'network.proxy.http_port/ssl_port' needs to be an integer:
GeckoPreferences.User["network.proxy.http_port"] = 1234;
GeckoPreferences.User["network.proxy.http_port"] = 6789;
You may also want to look at: