473,465 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MSHTML in C#

NG
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.




Nov 17 '05 #1
1 2492
Hi Nitesh,

Have a look at http://www.itwriting.com/htmleditor/...iki:htmleditor

This may help you in the right direction.

Regards
Joubert
"NG" <x@y.com> wrote in message
news:%2******************@TK2MSFTNGP15.phx.gbl...
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.



Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dean Hallman | last post by:
I need to ensure client machine has Microsoft.mshtml installed in the GAC. And if not, deploy it. My app is a Browser Helper Object and depends on mshtml. Initially, I thought I could take care...
4
by: David Pendrey | last post by:
Hello all, I am using the WebBrowser control to browse a webpage containing frames and am having difficulties accessing the 'frames' property of a document object. Bellow is my code and the error...
10
by: Hans Merkl | last post by:
Hi, I have written an pap with .NET 2.0 and c# that uses MSHTML. It works fine on my development machine but on machines I deploy it to I get the following exception when ever I call MSHTML. ...
2
by: DotNetShadow | last post by:
Hi Guys, I have been reading heaps of information in regards to MSHTML object being used in .NET applications, windows and UI-less. I have read the walkall samples and tried various techniques...
4
by: Lars-Erik Aabech | last post by:
Hi! I've been walking in extacy since reading the article about test automation with IE in the latest MSDN mag. (http://msdn.microsoft.com/msdnmag/issues/05/10/TestRun/default.aspx) After a...
3
by: DotNetShadow | last post by:
Hi Guys, I have been reading heaps of information in regards to MSHTML object being used in .NET applications, windows and UI-less. I have read the walkall samples and tried various techniques...
5
by: Atara | last post by:
I am trying to convert the following code to VB .Net, I still have some gaps (the lines that are marked with (*)) and also I need an ending condition for the while loop. any help would be...
0
by: Atara | last post by:
Our application was build with VS 2003. I have tried to run it on a computer with .Net 2.0 (but without .Net 1.1 , as it should be used) and I got the following error - ...
11
by: Lucky | last post by:
hi guys, i need to parse html data that i've got from "Inet" object in vb6. now i want to prase the html data. here i got 2 options. one is MSXML and other is MSHTML. i tried both of them but i...
5
by: Jason | last post by:
Hi, I'm developing an HTML Editor Control using VB.Net 2003 for an application that used to use the DHTML Editor Control that is no longer supported. Well, it's been fun but I've hit a wall with...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.