Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Fri, 22 Jul 2005 13:02:45 +0530,    group: microsoft.public.inetsdk.programming.html_objmodel        back       


MSHTML in C#   
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.
date: Fri, 22 Jul 2005 13:02:45 +0530   author:   NG

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us