WebBrowser control error

  • Thread starter Thread starter Shane Story
  • Start date Start date
S

Shane Story

I am trying to add the Microsoft Web Browseractive X control to a vb.net
form.

I always get an error on the EndInit line.

Parts of the errors says:

"Unknown error"

"First Chance exception"

I tried putting it in a user control but this failed also.

Anyone have a solution?

Or is there another control that is free that could be used in place of it?

I need a solution now and not a VS 2005 solution.

Thanks,

Shane
 
Shane,

Did you do it like this. Don't ask yourself why I show it like this, because
I have seen people with great expirience failing in this because of the
documentation which is not always very clear in this part.

\\\
In the toolbox rightclick and select add/Remove items

In the customize toolbox select Com and in that Microsoft Webbrowser

When that is in the toolbox drag it to your form
///


The point is that it creates doing this code in the RESX.


I hope this helps,

Cor
 
Hi Shane

I fear you will have to live with this if you use the WebBrowser control. If
you don't catch first chance exceptions the code will proceed and the
control should work correctly. Watch out for MarshalDirectiveException:
"Marshaler restriction: Excessively long string" exceptions as well. These
will pop up all over the place, but can usually be ignored.

Unfortunately the WebBrowser control is pretty flaky when used in .NET. That
is not to say that it doesn't work (or can't be made to work), but you will
have to ignore these particular exceptions, and if you want to do anything
sophisticated you will have to scour the newsgroups for information, or ask
here, of course.

The way I tackled it was to wrap the WebBrowser control in a user control,
and then I could protect the rest of my program from these wild exceptions.
You are effectively creating your own, well-behaved browser control.

You may like to look here as well

microsoft.public.inetsdk.programming.webbrowser_ctl
microsoft.public.inetsdk.programming.mshtml_hosting

although there is less VB.NET specific knowledge there.

HTH

Charles
 
Charles,

The one I was talking about was not you, (that you understand of course),
however somebody who was helping you. He was busy with using it as IE.

:-)

Cor
 
What alternative is there? Is there another control that would do a simple
web page rendering?

My problem is in the InitalizeComponent where it does the EndInit for
webbrowser. I can't seem to trap that error. It happen even if a try catch
is around that line of code.

Any ideas? Links? Controls? Code?

Thanks,

Shane
 
Doing a quick Google brought up

http://www.itwriting.com/htmleditor/index.php
http://www.thinktechnologies.com/think_html.asp

I'm not sure why you cannot get past the first chance exception. If you
don't try to trap it, and don't have exceptions break into the debugger (in
the IDE) then the exception should just be ignored. I certainly wouldn't put
a Try ... Catch around the code, because it is in the InitializeComponent
sub, and that will get overwritten by the designer. Go to Debug |
Exceptions, and check that Common Language Runtime Exceptions are set to
Continue "When the exception is thrown". In these conditions, my Windows
form loads without reporting an exception.

HTH

Charles
 
Hey,

You are right! Ignoring two com exceptions made it run.
I hope this will cause me no problems at run time.

Thanks for the information!

Shane
 

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