Lutz Roeder HTML Writer only returns 2 characters in SaveHtml () method

I downloaded Lutz Roeder Html Writer for use in a .NET WinForms application to avoid IE dependency issues mentioned in other threads here on SO.

The SaveHtml () method of the HtmlControl class seems to only return the first two characters, which (unsurprisingly) always "

Currently, I have implemented a workaround by adding a method to the HtmlControl class that simply returns the internal Document object.

public string HtmlBodyInnerHtml {
  get { return this.site.Document.GetBody().GetInnerHTML(); }
}

      

This is working now, but I'm wondering if anyone else has similar problems. I would like to continue using the control, but if I have any problems with it that I will continue to work with, I would know better now.

Alternatively, I might be using it incorrectly - is SaveHtml () not an appropriate calling method to retrieve the HTML source?

+2


source to share


1 answer


So I figured it out. Lutz HTML Writer misbehaves when executed in 64-bit mode. I think you plan on "any processor" when compiling, as I do. Some of the Windows API calls made by Writer did not work as expected when called from 64-bit code. This is due to the resizing of pointers, which Lutz did not seem to advocate. Compiling for target x86-only might be an acceptable solution for you. If not, you can change the first member of the STATSTG structure in NativeMethods.cs from:

[MarshalAs(UnmanagedType.I4)]
public int pwcsName;

      

To a more correct one:



[MarshalAs(UnmanagedType.LPTStr)]
public string pwcsName;

      

And the problem with SaveHtml () should be fixed. I ran into some other errors in the Writer.exe application in x64 mode, so keep in mind that you might have to track down other pInvoke related errors if you must support x64.

+1


source







All Articles