AxWebbrowser control problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to use the AxWebbrowser control in my VB.Net application. The
control is placed on one of the tab pages in the form. This is the error I am
getting when I
have the 'exceptions' set to break into the debugger:
A first chance exception of type
'System.Runtime.InteropServices.COMException' occurred in
system.windows.forms.dll

Additional information: Unknown error

If I set the 'exceptions' to Continue, then the control is not visible in
the form during run-time.

Any help is greatly appreciated.
Thanks.
 
Udhay,

The axwebbrowser is integrated in the resources.

I never succeeded to set it as viewable webbrowser (not as link to internet
explorer) without dragging it from the toolbox.

What did you do?

Cor
 
Cor,
I guess I did not clearly explain the problem in my last post.

I am creating an user control (myUControl.dll) in VB .Net 2003 and in that
I have a TabControl with four tab pages. In the third tab page, I placed an
AxWebBrowser control (from the tool box where I added the COM Microsoft Web
Browser shdocvw.dll, initially) and couple of buttons to navigate. The
problem is when I try to use the myUControl.dll in my main application
(myUApp.exe), it always break at this line:
CType(Me.AxWebBrowser1,
System.ComponentModel.ISupportInitialize).EndInit()

Please help.
Thanks.
 
Udhay,

That is exactly the problem that I have when I did not drag it, did you drag
it on your tabpage?

Cor
 
Cor,

I am not sure what you mean by dragging it on the tab page! This is
what I did:

Within the user control, I was on that tabpage (tabpage3) and from the
tool box I selected the web browser control and placed it on the
tabpage (and expanded the size of the web control).

If there is way that I can send you my stripped down code for you to
look at?

Thanks.
Udhay
 
Shobauy,

I think that it is not needed to send code.

I have created a new project
Draged on the form a tabcontrol with 4 tabpages
Draged on page for the Axwebbrowser (I assume you are talking about
2002/2003)
I have docked the Axwebbrowswer to fill

than I have put this code in the load event of the page
\\\
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
TabControl1.SelectedTab = TabPage4
Me.AxWebBrowser1.Navigate2("www.google.com")
End Sub
///

Now I have a specialized webbrowser in Tab 4 for Google.

Can you try that as well.

I hope this helps,

Cor
 
Hi Udhay

The WebBrowser control does this when used in VB.NET. It is safe to ignore
this exception. Set Exceptions to Continue rather than Break into the
Debugger and it should work.

The WebBrowser control is an ActiveX, and when you drop it into your
application an AxHost wrapper is created to marshal calls between managed
and unmanaged code (that's why it appears as AxWebBrowser). EndInit throws
an "Unknown Error" because there are many bugs (sorry, coding anomalies) in
the wrapped WebBrowser control, but you can ignore this one.

HTH

Charles
 
Charles,

I am not sure if it is this one, however I have in the program where I use
this as well that empty catch, I find it terrible to look at. This one is in
my idea that one that Fergus and you have strugled so long with.

(In my idea is the one you mention in the document complete, however maybe
is that the remedie with this one as well.)

:-)

Cor
 
Charles,

When I set the CLR Exceptions to 'Continue' and run the application, I
do not even see the browser control on the tab. Once again, this is
happenning only when I have the browser control on a tab within an User
Control; if I do the same thing in a regular windows application
everything works fine! (ofcouse, with the exceptions set to continue).

Thanks.
Udhay
 
Hi Udhay

I followed Cor's suggestion to the letter and the browser control appears as
expected. Are you doing this in a simple Windows form, or are you creating
an MDI application?

Charles
 
Charles,

The problem is that it is in a usercontrol. That axWebbrowser needs
something from the resx. However copying that seems for me not simple.

I have written that already in this message thread.

Cor
 
Hi Udhay

Cor has pointed out that you are doing this in a user control, so the trick
here is to use a second user control.

Create a control called WebViewer, say, and put the WebBrowser on that.
Then, reference the WebViewer in your main control, and put an instance of
it on your tab page. Now, when you run and subsequently select your tab
page, the browser should appear.

The reason you have to do this is that the WebBrowser control misbehaves if
it is loaded and displayed piece-meal. That's what happens when it is on a
tab page like you have. When it is in its own control it gets created and
displayed (even though you can't see it) when that control is created.

HTH

Charles
 
Hi Cor

I have re-read the thread and hadn't spotted the thing about user control.
In that case another user control is required.

I have put a fuller answer in the OP's thread.

Charles
 
Charles:

Thanks for explaining the reason for the axWebbrowser's behavior when used
within an user control. I will try your suggested solution.

Thanks.

Udhay
 

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

Back
Top