Comments (8)
You should set the parent of the GeckoWebBrowser object to another control
which
"contains" it. E.g.
GeckoWebBrowser wb = new GeckoWebBrowser();
wb.Parent = panel1;
Call Navigate() after this and it will work.
Original comment by [email protected]
on 13 Mar 2009 at 12:07
from geckofx.
This solution does not work if the GeckoWebBrowser is not actually drawn on
screen.
Original comment by alen.siljak
on 26 Jun 2009 at 7:26
from geckofx.
Is there anywhere a sample that shows how to get a browser running and
displaying a
page without this error? I'm putting it in a panel in a single-threaded
application,
I would *think* that GeckoWebBrowser is being "drawn on the screen", but I'm
getting
this error anyway.
I don't know what I'm doing wrong, that's why a sample from A-Z on how to put
it on a
form and display a web page would be handy.
Original comment by [email protected]
on 2 Feb 2010 at 8:01
from geckofx.
Hi,
I am facing the same problem.
I noticed that it happens only when the browser not drawn on screen.
In my application, I have a windows forms tab control and the browser is in one
of the tab pages.
So my solution (which is not user friendly) is to switch to that tab before
navigating with the browser control.
I think the problem is that the actual handle to the control is not created
until the browser control is shown.
If you solved it using another better technique, please share.
Original comment by [email protected]
on 13 Jun 2010 at 6:18
from geckofx.
This is my workaround:
if (this.tabControl1.SelectedTab != this.tpFFBrowser)
{
this.tabControl1.SelectedTab = this.tpFFBrowser;
Application.DoEvents();
}
this.firefoxBrowser.Navigate(this.txtURL.Text);
Original comment by [email protected]
on 13 Jun 2010 at 6:24
from geckofx.
I had a very similar problem which I got around by adding these lines:
//Constructor for the form
public form1()
{
InitializeComponent();
geckoBrowser1.HandleCreated += new EventHandler(geckoBrowser1_HandleCreated);
}
//Handle Created EventHandler
private void geckoBrowser1_HandleCreated(object sender, EventArgs e)
{
geckoBrowser1.Navigate("www.google.com");
}
In this way the system waits until the handle is created for the navigate. I
dont know how much help this will be but this is what I used to cause my system
to start on a specific page and it seems to work.
Original comment by [email protected]
on 17 Jun 2010 at 8:06
from geckofx.
I fixed this error by adding the following code in the Navigate Method of the
GeckoWebBrowser Class in GeckoWebBrowser.cs
public bool Navigate(string url, GeckoLoadFlags loadFlags, string referrer,
byte [] postData, string additionalHeaders)
{
star:
if (string.IsNullOrEmpty(url))
return false;
if (IsHandleCreated)
{
if (IsBusy)
this.Stop();
// WebNav.LoadURI throws an exception if we try to open a file that doesn't exist...
Uri created;
if (Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out created) && created.IsAbsoluteUri && created.IsFile)
{
if (!File.Exists(created.LocalPath) && !Directory.Exists(created.LocalPath))
return false;
}
nsIInputStream postDataStream = null, headersStream = null;
if (postData != null)
{
// post data must start with CRLF. actually, you can put additional headers before this, but there's no
// point because this method has an "additionalHeaders" argument. so we might as well insert it automatically
Array.Resize(ref postData, postData.Length + 2);
Array.Copy(postData, 0, postData, 2, postData.Length - 2);
postData[0] = (byte)'\r';
postData[1] = (byte)'\n';
postDataStream = ByteArrayInputStream.Create(postData);
}
if (!string.IsNullOrEmpty(additionalHeaders))
{
// each header must end with a CRLF (including the last one)
// here we simply ensure that the last header has a CRLF. if the header has other syntax problems,
// they're the caller's responsibility
if (!additionalHeaders.EndsWith("\r\n"))
additionalHeaders += "\r\n";
headersStream = ByteArrayInputStream.Create(Encoding.UTF8.GetBytes(additionalHeaders));
}
nsIURI referrerUri = null;
if (!string.IsNullOrEmpty(referrer))
{
referrerUri = Xpcom.GetService<nsIIOService>("@mozilla.org/network/io-service;1").NewURI(new nsACString(referrer), null, null);
}
return (WebNav.LoadURI(url, (uint)loadFlags, referrerUri, postDataStream, headersStream) != 0);
}
else
{
CreateHandle();
goto star;
//throw new InvalidOperationException("Cannot call Navigate() before the window handle is created.");
}
}
Hope it helps.
Even Though I know Using Labels are not recommended but this is a quick fix.
Original comment by [email protected]
on 10 Apr 2011 at 2:47
from geckofx.
This behavior has not changed in geckofx 1.9.1.0. I modified Navigate to call
CreateHandle() if IsHandleCreated is null. Works perfect.
There are a few tricks to building geckofx.
Start here: http://www.webprogrammingblog.com/compile-geckofx/
GeckoWebWrowser.cs: Line 420:
public bool Navigate(string url, GeckoLoadFlags loadFlags, string referrer,
byte [] postData, string additionalHeaders)
{
if (string.IsNullOrEmpty(url)) return false;
if (!IsHandleCreated) CreateHandle(); // Add this and removed if and else for check
if (IsBusy) this.Stop();
Uri created;
if (Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out created) && created.IsAbsoluteUri && created.IsFile)
{
if (!File.Exists(created.LocalPath) && !Directory.Exists(created.LocalPath))
return false;
}
nsIInputStream postDataStream = null, headersStream = null;
if (postData != null)
{
Array.Resize(ref postData, postData.Length + 2);
Array.Copy(postData, 0, postData, 2, postData.Length - 2);
postData[0] = (byte)'\r';
postData[1] = (byte)'\n';
postDataStream = ByteArrayInputStream.Create(postData);
}
if (!string.IsNullOrEmpty(additionalHeaders))
{
if (!additionalHeaders.EndsWith("\r\n")) additionalHeaders += "\r\n";
headersStream = ByteArrayInputStream.Create(Encoding.UTF8.GetBytes(additionalHeaders));
}
nsIURI referrerUri = null;
if (!string.IsNullOrEmpty(referrer))
{
referrerUri = Xpcom.GetService<nsIIOService>("@mozilla.org/network/io-service;1").NewURI(new nsACString(referrer), null, null);
}
return (WebNav.LoadURI(url, (uint)loadFlags, referrerUri, postDataStream, headersStream) != 0);
}
Original comment by [email protected]
on 7 Jul 2012 at 6:44
from geckofx.
Related Issues (20)
- Dll not compatable
- P/invoke Exception
- Facebook, HTML effects, etc.. dont work at all HOT 1
- Forum Admin And Mods Are Stupid HOT 1
- cant get xulrunner 7.0.1 to work with geckofx 1.9.1 ?
- Proxy
- Can't calll any javascript methods
- Does it support to drag drop event?
- how to manipulate document text
- document_completed eventhandle run 2 times HOT 1
- is inaccessible due to its protection level
- how to use geckofx in xaml ??
- Multiple Instances not working independently
- Popup window not working and Append new Addon Extentions.
- cannot naviaget to a intranet web page
- An unhandled exception of type 'System.InvalidCastException' occurred in Skybound.Gecko.dll
- Click even???
- Error: xulrunnerCall Xpcom.Initialize() in your application startup code and specify the directory where XULRunner is installed.
- Cannot navigate to urls. Timed out error
- Auto Download File from mozilla using geckofx HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geckofx.