Hi All,
I had posted this question earlier but I could not find a solution to my
problem hence reframing my question.
GOAL: I want to use the MSHTML to access a HTML page, access the DOM tree,
do some modifications in the DOM tree and save changed DOM tree to a local
HTML file. However, I do not want to use the WebBrowser control. It seems
I am not declaring the interface correctly as I am new to .NET. Any help is
very much appreciated.
Best regards
Nitesh
THIS IS WHAT I TRIED DOING:
-----------------------------------
<IPersistStreamInit.cs>
using System.Runtime.InteropServices;
[Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"),
InterfaceType(ComInterfaceType.InterfaceIsDual)]
interface IPersistStreamInit // cannot list any base interfaces here
{
void GetClassID(System.Guid pClassID);
[PreserveSig] int IsDirty();
[PreserveSig] int Load([In] UCOMIStream pstm);
[PreserveSig] int Save([In] UCOMIStream pstm, [In] bool ClearDirty);
[PreserveSig] int GetSizeMax([In, Out, MarshalAs(UnmanagedType.U8)] ref long
pcbSize);
[PreserveSig] int InitNew();
}
</IPersistStreamInit.cs>
The following code is written in a button click event of a form:
--------------------------------------------------------------
using mshtml;
HTMLDocument oDoc=new HTMLDocument();
IPersistStreamInit ips;
ips=(IPersistStreamInit) oDoc;
ips.InitNew();
IHTMLDocument2 iDoc2=oDoc.createDocumentFromUrl(txtURL.Text, "");
ERROR ENCOUNTERED:
---------------------------
An unhandled exception of type 'System.NullReferenceException' occurred in
mscorlib.dll
Additional information: Object reference not set to an instance of an
object.