IE Control in Winform (FW1.1)

R

R. K. Wijayaratne

Hi everyone,

I am trying to develop a Winforms app using .NET FW 1.1 (don't want to
use 2.0 for this particular project) and am trying to use the IE
control.


It compiles and builds without any problems. However everytime I run
it in DEBUG and it comes to this line:

this.WebBrowser.Navigate("about:blank", ref flags, ref
targetFrame, ref postData, ref headers);


It throws this error:

System.OutOfMemoryException: Error creating window handle.


I am following this article here for instructions:

http://www.codeproject.com/csharp/advhost.asp?target=idochostuihandler


Can anyone please advice how to get around this error; or if there is
an easier way to do this on .NET 1.1 (I need an embedded browser
control)?


Here is the stack-trace:

System.OutOfMemoryException: Error creating window handle. --->
System.NullReferenceException: Object reference not set to an instance
of an object.
at Program.Form1.Form1_Load(Object sender, EventArgs e) in c:
\program\form1.cs:line 92
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean
fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.IntCreateWindowEx(Int32
dwExStyle, String lpszClassName, String lpszWindowName, Int32 style,
Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent,
HandleRef hMenu, HandleRef hInst, Object pvParam)
at System.Windows.Forms.UnsafeNativeMethods.CreateWindowEx(Int32
dwExStyle, String lpszClassName, String lpszWindowName, Int32 style,
Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent,
HandleRef hMenu, HandleRef hInst, Object pvParam)
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
--- End of inner exception stack trace ---
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Control.Show()
at Program.frmMain.mnuFileNew_Click(Object sender, EventArgs e) in
c:\program\frmmain.cs:line 312
 
N

Nicholas Paldino [.NET/C# MVP]

I'm just guessing here, but I think it has something to do with calling
Navigate before the window is shown (the Load event is fired before the
window is just shown. I seem to remember something similar when using the
object in VB6). Try setting a timer to fire right after the load event, and
then call navigate from there.
 
G

Guest

Hi Nicholas,

Thanks for your reply. I was missing some key lines of code from the article
:)


Nicholas Paldino said:
I'm just guessing here, but I think it has something to do with calling
Navigate before the window is shown (the Load event is fired before the
window is just shown. I seem to remember something similar when using the
object in VB6). Try setting a timer to fire right after the load event, and
then call navigate from there.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

R. K. Wijayaratne said:
Hi everyone,

I am trying to develop a Winforms app using .NET FW 1.1 (don't want to
use 2.0 for this particular project) and am trying to use the IE
control.


It compiles and builds without any problems. However everytime I run
it in DEBUG and it comes to this line:

this.WebBrowser.Navigate("about:blank", ref flags, ref
targetFrame, ref postData, ref headers);


It throws this error:

System.OutOfMemoryException: Error creating window handle.


I am following this article here for instructions:

http://www.codeproject.com/csharp/advhost.asp?target=idochostuihandler


Can anyone please advice how to get around this error; or if there is
an easier way to do this on .NET 1.1 (I need an embedded browser
control)?


Here is the stack-trace:

System.OutOfMemoryException: Error creating window handle. --->
System.NullReferenceException: Object reference not set to an instance
of an object.
at Program.Form1.Form1_Load(Object sender, EventArgs e) in c:
\program\form1.cs:line 92
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean
fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.IntCreateWindowEx(Int32
dwExStyle, String lpszClassName, String lpszWindowName, Int32 style,
Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent,
HandleRef hMenu, HandleRef hInst, Object pvParam)
at System.Windows.Forms.UnsafeNativeMethods.CreateWindowEx(Int32
dwExStyle, String lpszClassName, String lpszWindowName, Int32 style,
Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent,
HandleRef hMenu, HandleRef hInst, Object pvParam)
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
--- End of inner exception stack trace ---
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Control.Show()
at Program.frmMain.mnuFileNew_Click(Object sender, EventArgs e) in
c:\program\frmmain.cs:line 312
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top