469,963 Members | 1,971 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,963 developers. It's quick & easy.

HTML Renderer

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
Nov 16 '05 #1
27 8136
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]
- mv*@spam.guard.caspershouse.com

"Michael C" <mi*******@optonline.net> wrote in message
news:uF**************@TK2MSFTNGP09.phx.gbl...
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

Nov 16 '05 #2
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]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Michael C" <mi*******@optonline.net> wrote in message
news:uF**************@TK2MSFTNGP09.phx.gbl...
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


Nov 16 '05 #3
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]
- mv*@spam.guard.caspershouse.com

"Michael C" <mi*******@optonline.net> wrote in message
news:OU**************@TK2MSFTNGP09.phx.gbl...
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]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Michael C" <mi*******@optonline.net> wrote in message
news:uF**************@TK2MSFTNGP09.phx.gbl...
> 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
>
>



Nov 16 '05 #4
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Michael C" <mi*******@optonline.net> wrote in message
news:OU**************@TK2MSFTNGP09.phx.gbl...
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]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Michael C" <mi*******@optonline.net> wrote in message
news:uF**************@TK2MSFTNGP09.phx.gbl...
> 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
>
>



Nov 16 '05 #5
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?
Nov 16 '05 #6
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]
- mv*@spam.guard.caspershouse.com

"Michael C" <mi*******@optonline.net> wrote in message
news:u6**************@TK2MSFTNGP15.phx.gbl...
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Michael C" <mi*******@optonline.net> wrote in message
news:OU**************@TK2MSFTNGP09.phx.gbl...
> 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]" <mv*@spam.guard.caspershouse.com>
> wrote
> in
> message news:%2****************@TK2MSFTNGP11.phx.gbl...
>> 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]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Michael C" <mi*******@optonline.net> wrote in message
>> news:uF**************@TK2MSFTNGP09.phx.gbl...
>> > 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
>> >
>> >
>>
>>
>
>



Nov 16 '05 #7
Does the WindowClosing event fire? Perhaps the following is relevant:

"http://www.kbcafe.com/iBLOGthere4iM/?guid=20040501150250"?


Nov 16 '05 #8
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eV**************@TK2MSFTNGP15.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Michael C" <mi*******@optonline.net> wrote in message
news:u6**************@TK2MSFTNGP15.phx.gbl...
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Michael C" <mi*******@optonline.net> wrote in message
news:OU**************@TK2MSFTNGP09.phx.gbl...
> 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]" <mv*@spam.guard.caspershouse.com>
> wrote
> in
> message news:%2****************@TK2MSFTNGP11.phx.gbl...
>> 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]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Michael C" <mi*******@optonline.net> wrote in message
>> news:uF**************@TK2MSFTNGP09.phx.gbl...
>> > 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
>> >
>> >
>>
>>
>
>



Nov 16 '05 #9
Exactly.

Thanks,
Michael C., MCDBA

"Joep" <St***@DeStoep.nl> wrote in message
news:41***********************@news.xs4all.nl...
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?

Nov 16 '05 #10
Now we're cooking! I'm trying this out now, will get back to you ASAP!

Thanks!
Michael C., MCDBA

"Joep" <St***@DeStoep.nl> wrote in message
news:41***********************@news.xs4all.nl...
Does the WindowClosing event fire? Perhaps the following is relevant:

"http://www.kbcafe.com/iBLOGthere4iM/?guid=20040501150250"?

Nov 16 '05 #11
That didn't work, but I definitely think we're on the right track with this.

Thanks,
Michael C., MCDBA

"Michael C" <mi*******@optonline.net> wrote in message
news:uF**************@TK2MSFTNGP10.phx.gbl...
Now we're cooking! I'm trying this out now, will get back to you ASAP!

Thanks!
Michael C., MCDBA

"Joep" <St***@DeStoep.nl> wrote in message
news:41***********************@news.xs4all.nl...
Does the WindowClosing event fire? Perhaps the following is relevant:

"http://www.kbcafe.com/iBLOGthere4iM/?guid=20040501150250"?


Nov 16 '05 #12
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

Nov 16 '05 #13
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

"Joep" <St***@DeStoep.nl> wrote in message
news:41***********************@news.xs4all.nl...
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

Nov 16 '05 #14
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

"Joep" <St***@DeStoep.nl> wrote in message
news:41***********************@news.xs4all.nl...
Does the WindowClosing event fire? Perhaps the following is relevant:

"http://www.kbcafe.com/iBLOGthere4iM/?guid=20040501150250"?

Nov 16 '05 #15
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Michael C" <mi*******@optonline.net> wrote in message
news:uF**************@TK2MSFTNGP09.phx.gbl...
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


Nov 16 '05 #16
You're welcome. I am glad the probelm is fixed now.
Nov 16 '05 #17
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" <jo*********@pursca.com> wrote in message
news:u%****************@TK2MSFTNGP09.phx.gbl...
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Michael C" <mi*******@optonline.net> wrote in message
news:uF**************@TK2MSFTNGP09.phx.gbl...
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



Nov 16 '05 #18
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" <mi*******@optonline.net> wrote in message
news:uc**************@TK2MSFTNGP10.phx.gbl...
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" <jo*********@pursca.com> wrote in message
news:u%****************@TK2MSFTNGP09.phx.gbl...
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote

in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Michael C" <mi*******@optonline.net> wrote in message
news:uF**************@TK2MSFTNGP09.phx.gbl...
> 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
>
>



Nov 16 '05 #19
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" <mi*******@optonline.net> wrote in message
news:uc**************@TK2MSFTNGP10.phx.gbl...
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" <jo*********@pursca.com> wrote in message
news:u%****************@TK2MSFTNGP09.phx.gbl...
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote

in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
> 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]
> - mv*@spam.guard.caspershouse.com
>
> "Michael C" <mi*******@optonline.net> wrote in message
> news:uF**************@TK2MSFTNGP09.phx.gbl...
>> 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
>>
>>
>
>



Nov 16 '05 #20
Interesting. That method was taken largely from an example on the MS
website... Guess they need to fix their samples and use their methods in a
more correct fashion. Got any examples of code using IPersistMemory? Noah
Coad published a WebBrowser wrapper control that exposes properties to
assign the HTML directly. His code is at
http://www.devhood.com/tutorials/tut...utorial_id=312. I
don't believe he defines IPersistMemory either.

Thanks,
Michael C., MCDBA
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:O9**************@TK2MSFTNGP09.phx.gbl...
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" <mi*******@optonline.net> wrote in message
news:uc**************@TK2MSFTNGP10.phx.gbl...
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" <jo*********@pursca.com> wrote in message
news:u%****************@TK2MSFTNGP09.phx.gbl...
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
> 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]
> - mv*@spam.guard.caspershouse.com
>
> "Michael C" <mi*******@optonline.net> wrote in message
> news:uF**************@TK2MSFTNGP09.phx.gbl...
>> 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
>>
>>
>
>



Nov 16 '05 #21
Michael,

You know, I could have sworn that IPersistMemory was on MSHTML.
Apparently, it is not.

I still wouldn't use the writeln function though (although for a quick
fix, I can't say don't use it).

The solution I use (a long time ago) was to fake a moniker and pass it
to the IPersistMoniker interface (the moniker implementation would say that
it is from http://www.somesite.com or something like that while the actual
content came from memory.

Sorry for the confusion.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Michael C" <mi*******@optonline.net> wrote in message
news:ed**************@TK2MSFTNGP12.phx.gbl...
Interesting. That method was taken largely from an example on the MS
website... Guess they need to fix their samples and use their methods in
a
more correct fashion. Got any examples of code using IPersistMemory?
Noah
Coad published a WebBrowser wrapper control that exposes properties to
assign the HTML directly. His code is at
http://www.devhood.com/tutorials/tut...utorial_id=312. I
don't believe he defines IPersistMemory either.

Thanks,
Michael C., MCDBA
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:O9**************@TK2MSFTNGP09.phx.gbl...
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" <mi*******@optonline.net> wrote in message
news:uc**************@TK2MSFTNGP10.phx.gbl...
>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" <jo*********@pursca.com> wrote in message
> news:u%****************@TK2MSFTNGP09.phx.gbl...
>> 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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote > in
>> message news:%2****************@TK2MSFTNGP11.phx.gbl...
>> > 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]
>> > - mv*@spam.guard.caspershouse.com
>> >
>> > "Michael C" <mi*******@optonline.net> wrote in message
>> > news:uF**************@TK2MSFTNGP09.phx.gbl...
>> >> 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
>> >>
>> >>
>> >
>> >
>>
>>
>
>



Nov 16 '05 #22
Hi Nicholas,
You know, I could have sworn that IPersistMemory was on MSHTML.
Apparently, it is not.
IPersistStreamInit with a stream created with CreateStreamOnHGlobal
sounds like you solution.
I still wouldn't use the writeln function though (although for a quick
fix, I can't say don't use it).

The solution I use (a long time ago) was to fake a moniker and pass it
to the IPersistMoniker interface (the moniker implementation would say that
it is from http://www.somesite.com or something like that while the actual
content came from memory.


That's the recommended way, AFIK.

Using IPersistStreamInit and/or IHTMLDocument2.writeln with
a browser initialized from about:blank will put the browser
in the INTERNET_ZONE (or some other zone != LOCAL_MACHINE,
I cannot recall).
Starting such an app on a Win 2003 server leads to a nasty
security message. Even IInternetSecurityManager doesn't help.

bye
Rob
Nov 16 '05 #23
Code talks, gentlemen.

In Noah Coad's example, he sets the axWebBrowser.Document.body.innerHTML
property for the browser. Is this acceptable? If not, do you have any
examples of acceptable code that you can share?

Thank you,
Michael C., MCDBA

"Robert Jordan" <ro*****@gmx.net> wrote in message
news:ck*************@news.t-online.com...
Hi Nicholas,
You know, I could have sworn that IPersistMemory was on MSHTML.
Apparently, it is not.


IPersistStreamInit with a stream created with CreateStreamOnHGlobal
sounds like you solution.
I still wouldn't use the writeln function though (although for a quick fix, I can't say don't use it).

The solution I use (a long time ago) was to fake a moniker and pass it to the IPersistMoniker interface (the moniker implementation would say that it is from http://www.somesite.com or something like that while the actual content came from memory.


That's the recommended way, AFIK.

Using IPersistStreamInit and/or IHTMLDocument2.writeln with
a browser initialized from about:blank will put the browser
in the INTERNET_ZONE (or some other zone != LOCAL_MACHINE,
I cannot recall).
Starting such an app on a Win 2003 server leads to a nasty
security message. Even IInternetSecurityManager doesn't help.

bye
Rob

Nov 16 '05 #24
Hi Michael,
In Noah Coad's example, he sets the axWebBrowser.Document.body.innerHTML
property for the browser. Is this acceptable? If not, do you have any
examples of acceptable code that you can share?


body.innerHTML sets, well, only the inner HTML of the body.
If cannot change the HEAD, for example.

The IPersistStreamInit solution:

void Load(string htmlText)
{
IntPtr hMem = Marshal.StringToHGlobalUni(htmlText);
UCOMIStream s;
CreateStreamOnHGlobal(hMem, true, out s);
s.Seek(0, 0, IntPtr.Zero);
IPersistStreamInit p = (IPersistStreamInit)axWebBrowser.Document;
p.InitNew();
p.Load(s);
}

[DllImport("ole32.dll", PreserveSig=false)]
static extern void CreateStreamOnHGlobal(IntPtr hGlobal, bool
fDeleteOnRelease, [Out] out UCOMIStream pStream);

[ComImport]
[Guid("7FD52380-4E07-101B-AE2D-08002B2EC713")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown )]
public interface IPersistStreamInit
{
void GetClassID([In, Out] ref Guid pClassID);
[return: MarshalAs(UnmanagedType.I4)][PreserveSig] int IsDirty();
void Load([In] UCOMIStream pstm);
void Save([In] UCOMIStream pstm, bool fClearDirty);
void GetSizeMax([Out] long pcbSize);
void InitNew();
}

Anyway, the following warning still applies. I don't have
a IPersistMoniker implementation because I decided to
use local files after I've seen the nasty security message
of the Windows 2003 server ;-)
Using IPersistStreamInit and/or IHTMLDocument2.writeln with
a browser initialized from about:blank will put the browser
in the INTERNET_ZONE (or some other zone != LOCAL_MACHINE,
I cannot recall).
Starting such an app on a Win 2003 server leads to a nasty
security message. Even IInternetSecurityManager doesn't help.


bye
Rob
Nov 16 '05 #25
For a simple solution, as long as you're not trying to define anything
special in the header, the innerHTML method should be sufficient (assuming
it's not Ratchety[tm]). In fact, you should be able to define JavaScript
functions and CSS StyleSheets inline using the innerHTML. The only reason I
can think of for needing to modify the HEAD is to change the TITLE or if you
have very unique requirements that can only go in the header (i.e., !DOCTYPE
declaration, etc)... Fortunately for my purposes the HEAD, etc., doesn't
really matter :) I like your solution, but there's got to be a way around
the security issues... Is there a way to make the WebBrowser realize it's
coming from the local computer (assuming the local computer is in the
Trusted Zone of course...)? You have me intrigued, and I'm off to research
the IPersistStreamInit solution further. Surprising that they didn't expose
any methods to just set the gosh-darn HTML and be done with it...

Thanks,
Michael C., MCDBA

"Robert Jordan" <ro*****@gmx.net> wrote in message
news:ck*************@news.t-online.com...
Hi Michael,
In Noah Coad's example, he sets the axWebBrowser.Document.body.innerHTML
property for the browser. Is this acceptable? If not, do you have any
examples of acceptable code that you can share?


body.innerHTML sets, well, only the inner HTML of the body.
If cannot change the HEAD, for example.

The IPersistStreamInit solution:

void Load(string htmlText)
{
IntPtr hMem = Marshal.StringToHGlobalUni(htmlText);
UCOMIStream s;
CreateStreamOnHGlobal(hMem, true, out s);
s.Seek(0, 0, IntPtr.Zero);
IPersistStreamInit p = (IPersistStreamInit)axWebBrowser.Document;
p.InitNew();
p.Load(s);
}

[DllImport("ole32.dll", PreserveSig=false)]
static extern void CreateStreamOnHGlobal(IntPtr hGlobal, bool
fDeleteOnRelease, [Out] out UCOMIStream pStream);

[ComImport]
[Guid("7FD52380-4E07-101B-AE2D-08002B2EC713")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown )]
public interface IPersistStreamInit
{
void GetClassID([In, Out] ref Guid pClassID);
[return: MarshalAs(UnmanagedType.I4)][PreserveSig] int IsDirty();
void Load([In] UCOMIStream pstm);
void Save([In] UCOMIStream pstm, bool fClearDirty);
void GetSizeMax([Out] long pcbSize);
void InitNew();
}

Anyway, the following warning still applies. I don't have
a IPersistMoniker implementation because I decided to
use local files after I've seen the nasty security message
of the Windows 2003 server ;-)
Using IPersistStreamInit and/or IHTMLDocument2.writeln with
a browser initialized from about:blank will put the browser
in the INTERNET_ZONE (or some other zone != LOCAL_MACHINE,
I cannot recall).
Starting such an app on a Win 2003 server leads to a nasty
security message. Even IInternetSecurityManager doesn't help.


bye
Rob

Nov 16 '05 #26
Hi Michael,
For a simple solution, as long as you're not trying to define anything
special in the header, the innerHTML method should be sufficient (assuming
it's not Ratchety[tm]). In fact, you should be able to define JavaScript
functions and CSS StyleSheets inline using the innerHTML. The only reason I
can think of for needing to modify the HEAD is to change the TITLE or if you
have very unique requirements that can only go in the header (i.e., !DOCTYPE
declaration, etc)... Fortunately for my purposes the HEAD, etc., doesn't


Another drawback of about:blank + innerHTML: you have to use
absolute paths for embedded elements (img, etc.) because
you cannot set up the BASE-element, which has to be adjusted,
otherwise relative paths would by looked up relatively
to about:blank.

IPersistStreamInit has the same limitation but you can
adjust the BASE element, either by injecting the base
into the html string or by injecting an empty base ([base href=""])
and setting it up using the DOM.

bye
Rob
Nov 16 '05 #27
If you go the route that I specified before, with an implementation of
IMoniker, you can set the base through that. When an implementation of
IMoniker is passed to IPersistMoniker, it uses the value returned from
IMoniker::GetDisplayName as the base for all relative urls.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Robert Jordan" <ro*****@gmx.net> wrote in message
news:ck*************@news.t-online.com...
Hi Michael,
For a simple solution, as long as you're not trying to define anything
special in the header, the innerHTML method should be sufficient
(assuming it's not Ratchety[tm]). In fact, you should be able to define
JavaScript functions and CSS StyleSheets inline using the innerHTML. The
only reason I can think of for needing to modify the HEAD is to change
the TITLE or if you have very unique requirements that can only go in the
header (i.e., !DOCTYPE declaration, etc)... Fortunately for my purposes
the HEAD, etc., doesn't


Another drawback of about:blank + innerHTML: you have to use
absolute paths for embedded elements (img, etc.) because
you cannot set up the BASE-element, which has to be adjusted,
otherwise relative paths would by looked up relatively
to about:blank.

IPersistStreamInit has the same limitation but you can
adjust the BASE element, either by injecting the base
into the html string or by injecting an empty base ([base href=""])
and setting it up using the DOM.

bye
Rob

Nov 16 '05 #28

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Michele Simionato | last post: by
reply views Thread by Ian Bicking | last post: by
8 posts views Thread by Frank Ratzlow | last post: by
6 posts views Thread by Michael C | last post: by
28 posts views Thread by Christopher Benson-Manica | last post: by
6 posts views Thread by robert_marquardt | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.