HTML Renderer

M

Michael C

Anyone know of a good HTML Rendering control? I need a control that will
render and display HTML in a Windows form. It doesn't need to pull down
HTML pages from the Web - I'll feed it all the HTML it needs to display.
I've already spent way too much time trying to get the Microsoft WebBrowser
control to work, and I have too many other things to work on to waste any
more time on it. If you know of any third-party HTML Renderers out there,
please let me know.

Thanks,
Michael C., MCDBA
 
N

Nicholas Paldino [.NET/C# MVP]

Michael,

I don't understand why you wouldn't use the webbrowser? How are you
trying to feed the HTML to it? It's pretty simple, you can do it through
memory, or through a file, or through a number of other mechanisms.
 
M

Michael C

There's nothing to understand. It generates an application error every time
I shut down the application. No one can explain why, no one has a solution,
several people have had similar (if not the exact same) issue. The
unstoppable error messagebox at shutdown is a deal-breaker. Plain and
simple.

So I ask again, does anyone know of a decent HTML Renderer?

Thanks,
Michael C., MCDBA

Nicholas Paldino said:
Michael,

I don't understand why you wouldn't use the webbrowser? How are you
trying to feed the HTML to it? It's pretty simple, you can do it through
memory, or through a file, or through a number of other mechanisms.


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

Michael C said:
Anyone know of a good HTML Rendering control? I need a control that will
render and display HTML in a Windows form. It doesn't need to pull down
HTML pages from the Web - I'll feed it all the HTML it needs to display.
I've already spent way too much time trying to get the Microsoft
WebBrowser
control to work, and I have too many other things to work on to waste any
more time on it. If you know of any third-party HTML Renderers out there,
please let me know.

Thanks,
Michael C., MCDBA
 
N

Nicholas Paldino [.NET/C# MVP]

Michael,

Actually, I would disagree. Because I have not seen this behavior
myself, I can't really say that there is a reason to go with something else.
If you can post an example of where it gives this, then it's possible that
an error could be pointed out, or in the case that there is no error on the
part of the code, a workaround.

Can you post an example?

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

Michael C said:
There's nothing to understand. It generates an application error every
time
I shut down the application. No one can explain why, no one has a
solution,
several people have had similar (if not the exact same) issue. The
unstoppable error messagebox at shutdown is a deal-breaker. Plain and
simple.

So I ask again, does anyone know of a decent HTML Renderer?

Thanks,
Michael C., MCDBA

in
message news:%[email protected]...
Michael,

I don't understand why you wouldn't use the webbrowser? How are you
trying to feed the HTML to it? It's pretty simple, you can do it through
memory, or through a file, or through a number of other mechanisms.


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

Michael C said:
Anyone know of a good HTML Rendering control? I need a control that will
render and display HTML in a Windows form. It doesn't need to pull
down
HTML pages from the Web - I'll feed it all the HTML it needs to
display.
I've already spent way too much time trying to get the Microsoft
WebBrowser
control to work, and I have too many other things to work on to waste any
more time on it. If you know of any third-party HTML Renderers out there,
please let me know.

Thanks,
Michael C., MCDBA
 
M

Michael C

Sure. My code works perfectly well, until I drop in the WebBrowser control.
I won't include all the Windows Generated WebBrowser code, because I don't
change any of it (I can copy and paste the Windows Generated code later if
you really feel it's necessary). Here's the code I add myself:

object novalue = System.Reflection.Missing.Value;
object url = "http://www.microsoft.com";
axWebBrowser1.Navigate2(ref url, ref novalue, ref novalue, ref novalue, ref
novalue);

Here's the error I get after shutting down (but *only after adding this
code*):

..NET-BroadcastEventWindow.1.0.5000.0.3: myApplication.exe - Application
Error
The exception unknown software exception (0xc0020001) occurred in the
application at location 0x77e73887.
Click on OK to terminate the program

I've reproduced this error on 8 different machines now (have added one more
since the last time, this one with .NET 1.1 SP 1 installed). It gives this
error a few seconds *AFTER* the Windows Form shuts down. How do you work
around that?

Thanks,
Michael C., MCDBA

Nicholas Paldino said:
Michael,

Actually, I would disagree. Because I have not seen this behavior
myself, I can't really say that there is a reason to go with something else.
If you can post an example of where it gives this, then it's possible that
an error could be pointed out, or in the case that there is no error on the
part of the code, a workaround.

Can you post an example?

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

Michael C said:
There's nothing to understand. It generates an application error every
time
I shut down the application. No one can explain why, no one has a
solution,
several people have had similar (if not the exact same) issue. The
unstoppable error messagebox at shutdown is a deal-breaker. Plain and
simple.

So I ask again, does anyone know of a decent HTML Renderer?

Thanks,
Michael C., MCDBA

in
message news:%[email protected]...
Michael,

I don't understand why you wouldn't use the webbrowser? How are you
trying to feed the HTML to it? It's pretty simple, you can do it through
memory, or through a file, or through a number of other mechanisms.


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

Anyone know of a good HTML Rendering control? I need a control that will
render and display HTML in a Windows form. It doesn't need to pull
down
HTML pages from the Web - I'll feed it all the HTML it needs to
display.
I've already spent way too much time trying to get the Microsoft
WebBrowser
control to work, and I have too many other things to work on to waste any
more time on it. If you know of any third-party HTML Renderers out there,
please let me know.

Thanks,
Michael C., MCDBA
 
J

Joep

Just a thought, is there a left over that should have been trashed? The left
over still running and missing the app or similar? Some compo thingy
perhaps?
 
N

Nicholas Paldino [.NET/C# MVP]

Michael,

I did the exactly as you said in the email, and I did not get any errors
upon shutdown. Do you get this same error when you use the web browser
control in say, a VB6 application? If so, then it would suggest that it is
not .NET, but the web browser control itself.

Also, the eight machines, are they the same configuration (relatively)?
I only ask because if there is a plugin, a browser helper object, or
something of that nature in Internet Explorer which is causing the problem
(it definitely seems like an unmanaged code exception), then I wonder if it
is present in all of the machines where you have tried this on.

Also, the version of Internet Explorer that I am running is the latest,
with XP SP2 installed.

My guess is that this is in an enterprise, where the distributions are
very similar, and that there is a plug in, or a setting for IE that is
causing the error.

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

Michael C said:
Sure. My code works perfectly well, until I drop in the WebBrowser
control.
I won't include all the Windows Generated WebBrowser code, because I don't
change any of it (I can copy and paste the Windows Generated code later if
you really feel it's necessary). Here's the code I add myself:

object novalue = System.Reflection.Missing.Value;
object url = "http://www.microsoft.com";
axWebBrowser1.Navigate2(ref url, ref novalue, ref novalue, ref novalue,
ref
novalue);

Here's the error I get after shutting down (but *only after adding this
code*):

.NET-BroadcastEventWindow.1.0.5000.0.3: myApplication.exe - Application
Error
The exception unknown software exception (0xc0020001) occurred in the
application at location 0x77e73887.
Click on OK to terminate the program

I've reproduced this error on 8 different machines now (have added one
more
since the last time, this one with .NET 1.1 SP 1 installed). It gives
this
error a few seconds *AFTER* the Windows Form shuts down. How do you work
around that?

Thanks,
Michael C., MCDBA

in
message news:%[email protected]...
Michael,

Actually, I would disagree. Because I have not seen this behavior
myself, I can't really say that there is a reason to go with something else.
If you can post an example of where it gives this, then it's possible
that
an error could be pointed out, or in the case that there is no error on the
part of the code, a workaround.

Can you post an example?

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

Michael C said:
There's nothing to understand. It generates an application error every
time
I shut down the application. No one can explain why, no one has a
solution,
several people have had similar (if not the exact same) issue. The
unstoppable error messagebox at shutdown is a deal-breaker. Plain and
simple.

So I ask again, does anyone know of a decent HTML Renderer?

Thanks,
Michael C., MCDBA

"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote
in
message Michael,

I don't understand why you wouldn't use the webbrowser? How are you
trying to feed the HTML to it? It's pretty simple, you can do it through
memory, or through a file, or through a number of other mechanisms.


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

Anyone know of a good HTML Rendering control? I need a control that
will
render and display HTML in a Windows form. It doesn't need to pull
down
HTML pages from the Web - I'll feed it all the HTML it needs to
display.
I've already spent way too much time trying to get the Microsoft
WebBrowser
control to work, and I have too many other things to work on to
waste
any
more time on it. If you know of any third-party HTML Renderers out
there,
please let me know.

Thanks,
Michael C., MCDBA
 
M

Michael C

Try it in a multithreaded app. and see if you get the same results.

I've investigated the heck out of this over the past 2 days, and I've found
some good leads. There are quite a few people who have posted similar
items, and I've e-mailed a guy at microsoft who blogs and claims he's aware
of 6 or 7 causes of this problem, although he seems to hold most of his info
pretty close to the vest.

I'm pretty certain I know why this is happening, and it has nothing to do
with configuration, settings, third-party tools, etc. I'm 99% sure I know
the cause of this problem; I'm 100% sure I don't know how to work around it.
So rather than wasting more time playing with code hoping I accidentally
stumble across a solution, I'd much rather just use a control that won't
error out when I shut down my app.

Thanks,
Michael C., MCDBA

Nicholas Paldino said:
Michael,

I did the exactly as you said in the email, and I did not get any errors
upon shutdown. Do you get this same error when you use the web browser
control in say, a VB6 application? If so, then it would suggest that it is
not .NET, but the web browser control itself.

Also, the eight machines, are they the same configuration (relatively)?
I only ask because if there is a plugin, a browser helper object, or
something of that nature in Internet Explorer which is causing the problem
(it definitely seems like an unmanaged code exception), then I wonder if it
is present in all of the machines where you have tried this on.

Also, the version of Internet Explorer that I am running is the latest,
with XP SP2 installed.

My guess is that this is in an enterprise, where the distributions are
very similar, and that there is a plug in, or a setting for IE that is
causing the error.

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

Michael C said:
Sure. My code works perfectly well, until I drop in the WebBrowser
control.
I won't include all the Windows Generated WebBrowser code, because I don't
change any of it (I can copy and paste the Windows Generated code later if
you really feel it's necessary). Here's the code I add myself:

object novalue = System.Reflection.Missing.Value;
object url = "http://www.microsoft.com";
axWebBrowser1.Navigate2(ref url, ref novalue, ref novalue, ref novalue,
ref
novalue);

Here's the error I get after shutting down (but *only after adding this
code*):

.NET-BroadcastEventWindow.1.0.5000.0.3: myApplication.exe - Application
Error
The exception unknown software exception (0xc0020001) occurred in the
application at location 0x77e73887.
Click on OK to terminate the program

I've reproduced this error on 8 different machines now (have added one
more
since the last time, this one with .NET 1.1 SP 1 installed). It gives
this
error a few seconds *AFTER* the Windows Form shuts down. How do you work
around that?

Thanks,
Michael C., MCDBA

in
message news:%[email protected]...
Michael,

Actually, I would disagree. Because I have not seen this behavior
myself, I can't really say that there is a reason to go with something else.
If you can post an example of where it gives this, then it's possible
that
an error could be pointed out, or in the case that there is no error on the
part of the code, a workaround.

Can you post an example?

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

There's nothing to understand. It generates an application error every
time
I shut down the application. No one can explain why, no one has a
solution,
several people have had similar (if not the exact same) issue. The
unstoppable error messagebox at shutdown is a deal-breaker. Plain and
simple.

So I ask again, does anyone know of a decent HTML Renderer?

Thanks,
Michael C., MCDBA

"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote
in
message Michael,

I don't understand why you wouldn't use the webbrowser? How are you
trying to feed the HTML to it? It's pretty simple, you can do it through
memory, or through a file, or through a number of other mechanisms.


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

Anyone know of a good HTML Rendering control? I need a control that
will
render and display HTML in a Windows form. It doesn't need to pull
down
HTML pages from the Web - I'll feed it all the HTML it needs to
display.
I've already spent way too much time trying to get the Microsoft
WebBrowser
control to work, and I have too many other things to work on to
waste
any
more time on it. If you know of any third-party HTML Renderers out
there,
please let me know.

Thanks,
Michael C., MCDBA
 
M

Michael C

Now we're cooking! I'm trying this out now, will get back to you ASAP!

Thanks!
Michael C., MCDBA
 
M

Michael C

That didn't work, but I definitely think we're on the right track with this.

Thanks,
Michael C., MCDBA
 
J

Joep

But does the WindowClose fire? Sometimes a reference is not released,
sometimes a reference has to be set to null to release resources. A proper
and complete tear down of the instances created is needed anyhow in one way
or another.

I think it is not the axWebBrowser control itself that causes the problem
you are experiencing but as I mentioned something that gets created that
does not get destroyed and remains. So my suggestion is to make sure all
that is created is properly destroyed.

HTH
 
M

Michael C

It didn't seem to fire this time, but I'm running some more tests to be
sure. I think the unmanaged code for the axWebBrowser is hanging around in
memory after the managed form is closed. I've read that this particular
error can be caused by unmanaged code trying to send a message to managed
code, if the managed code no longer exists... I think the problem is
exactly what you state - the unmanaged code of the axWebBrowser is hanging
around after the managed code is long gone. Only problem is I can't seem to
get rid of the axWebBrowser control first when closing down the window...
I've tried setting it to null, running Dispose() on it followed immediately
by GC.Collect() and everything else I can think of... but it's just not
going away before the form closes.

Thanks,
Michael C., MCDBA
 
M

Michael C

Thank you Joep!!! With a little tweaking, the solution you pointed me to
worked perfectly! I found some more info - it appears the WebBrowser
component doesn't necessarily completely unload itself. This fix did the
job. Thanks again!

Michael C., MCDBA
 
J

John Lee

Hi, Nick,

Could you please show me the code how you can feed html or xml to the web
browser in memory? I can only do it by creating a temp file and supply the
url. ..

Thanks!
John
Nicholas Paldino said:
Michael,

I don't understand why you wouldn't use the webbrowser? How are you
trying to feed the HTML to it? It's pretty simple, you can do it through
memory, or through a file, or through a number of other mechanisms.


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

Michael C said:
Anyone know of a good HTML Rendering control? I need a control that will
render and display HTML in a Windows form. It doesn't need to pull down
HTML pages from the Web - I'll feed it all the HTML it needs to display.
I've already spent way too much time trying to get the Microsoft
WebBrowser
control to work, and I have too many other things to work on to waste any
more time on it. If you know of any third-party HTML Renderers out
there,
please let me know.

Thanks,
Michael C., MCDBA
 
M

Michael C

I posted some code to do this already. The post is called "Re:
AxSHDocVw.AxWebBrowser Component Question", the date was 10/9.

Thanks,
Michael C., MCDBA

John Lee said:
Hi, Nick,

Could you please show me the code how you can feed html or xml to the web
browser in memory? I can only do it by creating a temp file and supply the
url. ..

Thanks!
John
message news:%[email protected]...
Michael,

I don't understand why you wouldn't use the webbrowser? How are you
trying to feed the HTML to it? It's pretty simple, you can do it through
memory, or through a file, or through a number of other mechanisms.


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

Michael C said:
Anyone know of a good HTML Rendering control? I need a control that will
render and display HTML in a Windows form. It doesn't need to pull down
HTML pages from the Web - I'll feed it all the HTML it needs to display.
I've already spent way too much time trying to get the Microsoft
WebBrowser
control to work, and I have too many other things to work on to waste any
more time on it. If you know of any third-party HTML Renderers out
there,
please let me know.

Thanks,
Michael C., MCDBA
 
M

Michael C

Hi John,

Here's a sample called BrowseHTML:

private void BrowseHTML (AxSHDocVw.AxWebBrowser wb, string html)
{
IHTMLDocument2 doc = wb.Document as IHTMLDocument2;
doc.writeln(html);
doc.clear();
doc.close();
}

Just pass BrowseHTML the AxWebBrowser control and the HTML you want
displayed. One note: Somewhere in your initialization code, before you try
to use BrowseHTML, you need to Navigate to "about:blank" (I put it in
Form_Load). If you try to BrowseHTML () before you do this, it will error
out with a null exception:

object nil = "";
object zero = 0;
axWebBrowser1.Navigate("about:blank", ref zero, ref nil, ref nil, ref nil);

This blanks out the WebBrowser control and initializes it to display HTML
pages. And here's how you use the BrowseHTML function (pardon the ugly
HTML, but it is just a sample):

BrowseHTML (axWebBrowser1, "<CENTER><FONT SIZE = +5
COLOR=GREEN>HELLO!</FONT></CENTER>");

This code is based on code from Stephan Popov at The Code Project and some
code samples on the MS Website.

Thanks,
Michael C., MCDBA


Michael C said:
I posted some code to do this already. The post is called "Re:
AxSHDocVw.AxWebBrowser Component Question", the date was 10/9.

Thanks,
Michael C., MCDBA

John Lee said:
Hi, Nick,

Could you please show me the code how you can feed html or xml to the web
browser in memory? I can only do it by creating a temp file and supply the
url. ..

Thanks!
John
message news:%[email protected]...
Michael,

I don't understand why you wouldn't use the webbrowser? How are you
trying to feed the HTML to it? It's pretty simple, you can do it through
memory, or through a file, or through a number of other mechanisms.


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

Anyone know of a good HTML Rendering control? I need a control that will
render and display HTML in a Windows form. It doesn't need to pull down
HTML pages from the Web - I'll feed it all the HTML it needs to display.
I've already spent way too much time trying to get the Microsoft
WebBrowser
control to work, and I have too many other things to work on to waste any
more time on it. If you know of any third-party HTML Renderers out
there,
please let me know.

Thanks,
Michael C., MCDBA
 
N

Nicholas Paldino [.NET/C# MVP]

Personally, I wouldn't use that method, as I don't believe it was
intended for this.

Rather, what I would do is define the COM interface IPersistMemory in
your assembly. You can find the definition in Ocidl.idl. Once you have
that, you can cast the value returned from the document property (after you
navigate to about:blank to get an instance loaded) to this interface and
then call Load in order to load the document from memory.

The thing here is that it expects a pointer, in which case, you will
have to copy the content to unmanaged code, or you will have to use unsafe
code to fix the location of the data in memory and then make the call.

Hope this helps.



Michael C said:
I posted some code to do this already. The post is called "Re:
AxSHDocVw.AxWebBrowser Component Question", the date was 10/9.

Thanks,
Michael C., MCDBA

John Lee said:
Hi, Nick,

Could you please show me the code how you can feed html or xml to the web
browser in memory? I can only do it by creating a temp file and supply
the
url. ..

Thanks!
John
message news:%[email protected]...
Michael,

I don't understand why you wouldn't use the webbrowser? How are you
trying to feed the HTML to it? It's pretty simple, you can do it through
memory, or through a file, or through a number of other mechanisms.


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

Anyone know of a good HTML Rendering control? I need a control that will
render and display HTML in a Windows form. It doesn't need to pull down
HTML pages from the Web - I'll feed it all the HTML it needs to display.
I've already spent way too much time trying to get the Microsoft
WebBrowser
control to work, and I have too many other things to work on to waste any
more time on it. If you know of any third-party HTML Renderers out
there,
please let me know.

Thanks,
Michael C., MCDBA
 

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