Apr 13, 2015 at 1:35 PM
Edited Apr 14, 2015 at 11:16 AM
I'm trying to integrate HtmlRenderer with an existing project. I have references to HtmlRenderer and to HtmlRenderer.WinForms. Right now I am producing some very simple HTML, for example:
sHtml = "<P>ComputerName</P><P>10.4.59.34</P>";
or slightly more complex, with html and body tags included:
sHtml = "<html><body><P align=right><FONT color=#ff8040 size=5 face=Arial><STRONG>DESKPC</STRONG></FONT></P>\r\n<P align=right><FONT size=2 face=Arial>10.58.4.13<br />10.99.87.1</FONT></P>\r\n<P
align=right><FONT size=2 face=Arial>DOMAIN\Usernasme</FONT></P></body></html>"
I also generate a background Bitmap on which I wish to render the HTML, this is produced using managed code (Graphics object) with various calls:
Bitmap B = new Bitmap (1024,768);
When running in VS.Net, and I attempt to render the text to the Bitmap, I get a crash - specifically, "vshost32-clr2.exe has stopped working". Here's the (sole) call into HtmlRenderer, which looks to me to be exactly like the documented example:
HtmlRender.RenderToImage(B, sHtml, new Point(400, 200));
If I run the code outside of VS.Net, it doesn't seem to work, but it doesn't crash either. I'm a bit lost as to how to proceed!
One other observation:
If I save the file to disk then load it straight back into an Image, no crash, but no rendered output is found:
Image I = Image.FromFile("D:\D1.PNG");
HtmlRender.RenderToImage(I, sHtml, new Point(400, 200));
Edit: Looks like this can be worked around for debugging by forcing to .NET 4 and reinstalling the HtmlRenderer packages. I'm guessing the original NuGet package loaded a 2.0 version to support the 3.5 project, and apparently this crash is a common issue with
mixed .NET versions.