473,324 Members | 2,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Problem Accessing HTMLElementCollection

I developed a C# application to automate input to elements of a web page
displayed in an AxWebBrowser control. The app calls GetEnumerator() on the
HTMLDocument's HTMLElementCollection (i.e. HTMLDocument.all) to walk
elements of the document.

This works perfectly on my development system with both Debug and Release
builds, however, when I deploy the app to a client system running Windows XP
Professional, it doesn't work.

I added logging to the app to find out what was happening on the client
system and found that GetType() returns '__ComObject' for all elements with
the exception of the HTMLBodyClass element.

I have checked IE settings and the versions of the DLLs my app uses on my
development system and the client system and can find no differences except
Microsoft.mshtml running on my development system is located in the GAC
while it is running from my installation directory on the client.

What do I need to do to get the client installation to work?

Thanks,
Tom
Nov 17 '05 #1
13 7195
Tom,

You haven't said how it doesn't work on these other machines.

BTW, GetType is returning the correct type when you check the type of
these objects. This is what is returned by ToString for any type deriving
from System.__ComObject (which is what you are using when you use the
interop assemblies for MSHTML).

What are the details of the exception you are getting?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tom Bean" <tb***@newsgroup.nospam> wrote in message
news:uh**************@TK2MSFTNGP10.phx.gbl...
I developed a C# application to automate input to elements of a web page
displayed in an AxWebBrowser control. The app calls GetEnumerator() on the
HTMLDocument's HTMLElementCollection (i.e. HTMLDocument.all) to walk
elements of the document.

This works perfectly on my development system with both Debug and Release
builds, however, when I deploy the app to a client system running Windows
XP Professional, it doesn't work.

I added logging to the app to find out what was happening on the client
system and found that GetType() returns '__ComObject' for all elements
with the exception of the HTMLBodyClass element.

I have checked IE settings and the versions of the DLLs my app uses on my
development system and the client system and can find no differences
except Microsoft.mshtml running on my development system is located in the
GAC while it is running from my installation directory on the client.

What do I need to do to get the client installation to work?

Thanks,
Tom

Nov 17 '05 #2
Nicholas,

On my development system, GetType().Name returns the type of the element,
for example, "HTMLInputElement" but on the client systems GetType().Name is
always "__ComObject".

I don't get any exception but when I make the comparison, if
(element.GetType().Name == "HTMLInputElement"), it always fails because
"__ComObject" is being returned as the type name.

Tom

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:e3**************@TK2MSFTNGP09.phx.gbl...
Tom,

You haven't said how it doesn't work on these other machines.

BTW, GetType is returning the correct type when you check the type of
these objects. This is what is returned by ToString for any type deriving
from System.__ComObject (which is what you are using when you use the
interop assemblies for MSHTML).

What are the details of the exception you are getting?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tom Bean" <tb***@newsgroup.nospam> wrote in message
news:uh**************@TK2MSFTNGP10.phx.gbl...
I developed a C# application to automate input to elements of a web page
displayed in an AxWebBrowser control. The app calls GetEnumerator() on
the HTMLDocument's HTMLElementCollection (i.e. HTMLDocument.all) to walk
elements of the document.

This works perfectly on my development system with both Debug and Release
builds, however, when I deploy the app to a client system running Windows
XP Professional, it doesn't work.

I added logging to the app to find out what was happening on the client
system and found that GetType() returns '__ComObject' for all elements
with the exception of the HTMLBodyClass element.

I have checked IE settings and the versions of the DLLs my app uses on my
development system and the client system and can find no differences
except Microsoft.mshtml running on my development system is located in
the GAC while it is running from my installation directory on the client.

What do I need to do to get the client installation to work?

Thanks,
Tom


Nov 17 '05 #3
Tom,

Have you distributed the interop libraries as well that you are using to
access the HTML document model?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tom Bean" <tb***@newsgroup.nospam> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Nicholas,

On my development system, GetType().Name returns the type of the element,
for example, "HTMLInputElement" but on the client systems GetType().Name
is always "__ComObject".

I don't get any exception but when I make the comparison, if
(element.GetType().Name == "HTMLInputElement"), it always fails because
"__ComObject" is being returned as the type name.

Tom

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:e3**************@TK2MSFTNGP09.phx.gbl...
Tom,

You haven't said how it doesn't work on these other machines.

BTW, GetType is returning the correct type when you check the type of
these objects. This is what is returned by ToString for any type
deriving from System.__ComObject (which is what you are using when you
use the interop assemblies for MSHTML).

What are the details of the exception you are getting?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tom Bean" <tb***@newsgroup.nospam> wrote in message
news:uh**************@TK2MSFTNGP10.phx.gbl...
I developed a C# application to automate input to elements of a web page
displayed in an AxWebBrowser control. The app calls GetEnumerator() on
the HTMLDocument's HTMLElementCollection (i.e. HTMLDocument.all) to walk
elements of the document.

This works perfectly on my development system with both Debug and
Release builds, however, when I deploy the app to a client system
running Windows XP Professional, it doesn't work.

I added logging to the app to find out what was happening on the client
system and found that GetType() returns '__ComObject' for all elements
with the exception of the HTMLBodyClass element.

I have checked IE settings and the versions of the DLLs my app uses on
my development system and the client system and can find no differences
except Microsoft.mshtml running on my development system is located in
the GAC while it is running from my installation directory on the
client.

What do I need to do to get the client installation to work?

Thanks,
Tom



Nov 17 '05 #4
Nicholas,

I am distributing: AxInterop.SHDocVw.dll, Interop.SHDocVw.dll, and
Microsoft.mshtml.dll.

Tom

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:ux**************@TK2MSFTNGP12.phx.gbl...
Tom,

Have you distributed the interop libraries as well that you are using
to access the HTML document model?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tom Bean" <tb***@newsgroup.nospam> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Nicholas,

On my development system, GetType().Name returns the type of the element,
for example, "HTMLInputElement" but on the client systems GetType().Name
is always "__ComObject".

I don't get any exception but when I make the comparison, if
(element.GetType().Name == "HTMLInputElement"), it always fails because
"__ComObject" is being returned as the type name.

Tom

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:e3**************@TK2MSFTNGP09.phx.gbl...
Tom,

You haven't said how it doesn't work on these other machines.

BTW, GetType is returning the correct type when you check the type of
these objects. This is what is returned by ToString for any type
deriving from System.__ComObject (which is what you are using when you
use the interop assemblies for MSHTML).

What are the details of the exception you are getting?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tom Bean" <tb***@newsgroup.nospam> wrote in message
news:uh**************@TK2MSFTNGP10.phx.gbl...
I developed a C# application to automate input to elements of a web page
displayed in an AxWebBrowser control. The app calls GetEnumerator() on
the HTMLDocument's HTMLElementCollection (i.e. HTMLDocument.all) to walk
elements of the document.

This works perfectly on my development system with both Debug and
Release builds, however, when I deploy the app to a client system
running Windows XP Professional, it doesn't work.

I added logging to the app to find out what was happening on the client
system and found that GetType() returns '__ComObject' for all elements
with the exception of the HTMLBodyClass element.

I have checked IE settings and the versions of the DLLs my app uses on
my development system and the client system and can find no differences
except Microsoft.mshtml running on my development system is located in
the GAC while it is running from my installation directory on the
client.

What do I need to do to get the client installation to work?

Thanks,
Tom



Nov 17 '05 #5
Hi

If you include the mshtml in your project, and the .NET setup project will
check the dependency to including the mshtml.dll.
And you can set to deploy the mshtml into GAC and check the register to
true to make sure the mshtml is deployed correctly in the GAC.

Deploying an Interop Application
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpcondeployinginteropapplication.asp

Here is a general link about deploy .net application.
Deploying Applications
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconDeployingNETFrameworkApplications.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 17 '05 #6
Peter,

I already have Microsoft.mshtml in my project, however, I did the following
to add mshtml to the project also.

I added a reference to mshtml to my project by selecting "Microsoft HTML
Object Library" from the COM tab of the "Add Reference" dialog, however, it
just points to Microsoft.mshtml, which I already have a reference to,
installed in the GAC. As a consequence of adding it again, I got a lot of
warnings about various mshtml elements being defined in multiple places.

I also tried adding a reference to C::\Windows\System32\mshtml.dll but got
an error message saying "A reference ti 'C::\Windows\System32\mshtml.dll'
could not be added. This is not a valid assembly or COM component. Only
assemblies with extension 'dll' and COM components can be referenced.
Please make sure that the file is accessible, and that it is a valid
assembly or COM component."

I checked the GAC on my development system and there is no reference to
mshtml other than Microsoft.mshtml installed in it. I aslo used GACUtil to
add Microsoft.mshtml to the GAC on a client system but it still sees all the
HTMLElements as __COMObjects.

The client system has Internet Explorer installed and has the same version
of mshtml.dll installed in C::\Windows\System32 as I do on my development
system. I also installed my app on another system with Visual Studio
installed and it works as expected.

Are you talking about some other mshtml that I need to add to my project?
Is there something I missed or have done incorrectly while adding mshtml?

Thanks,
Tom

""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:7L**************@TK2MSFTNGXA01.phx.gbl...
Hi

If you include the mshtml in your project, and the .NET setup project will
check the dependency to including the mshtml.dll.
And you can set to deploy the mshtml into GAC and check the register to
true to make sure the mshtml is deployed correctly in the GAC.

Deploying an Interop Application
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpcondeployinginteropapplication.asp

Here is a general link about deploy .net application.
Deploying Applications
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconDeployingNETFrameworkApplications.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 17 '05 #7
Hi

Based on my test with the simple code below, the setup project will works
on a non VS.NET installed machine.
You may try the simple sample first to see if that works for you.

private void Form1_Load(object sender, System.EventArgs e)
{
this.axWebBrowser1.Navigate("www.google.com");
}

private void button1_Click(object sender, System.EventArgs e)
{
mshtml.HTMLDocument doc= (mshtml.HTMLDocument)axWebBrowser1.Document;
MessageBox.Show(doc.title);
}

Also mshtml.dll will be shipped with IE, you may try to update the client
with the newest IE to fresh the mshtml.dll.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 17 '05 #8
Peter,

When the problem showed up, I checked the version of IE on the client and it
is the same as on my development system, the latest.

The problem isn't with accessing the HTMLDocument. It just happens when my
app enumerates the HTMLElementCollection returned by
HTMLDocument.all.GetEnumerator(). The element types are always
'__COMObject'.

Tom

""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:oz***************@TK2MSFTNGXA01.phx.gbl...
Hi

Based on my test with the simple code below, the setup project will works
on a non VS.NET installed machine.
You may try the simple sample first to see if that works for you.

private void Form1_Load(object sender, System.EventArgs e)
{
this.axWebBrowser1.Navigate("www.google.com");
}

private void button1_Click(object sender, System.EventArgs e)
{
mshtml.HTMLDocument doc= (mshtml.HTMLDocument)axWebBrowser1.Document;
MessageBox.Show(doc.title);
}

Also mshtml.dll will be shipped with IE, you may try to update the client
with the newest IE to fresh the mshtml.dll.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 17 '05 #9
Hi

Thanks for your quickly reply!
Unfortunately, I still can not reproduce the problem.

Here is my test code.
private void Form1_Load(object sender, System.EventArgs e)
{
this.axWebBrowser1.Navigate("www.google.com");
}

private void button1_Click(object sender, System.EventArgs e)
{
mshtml.HTMLDocument doc= (mshtml.HTMLDocument)axWebBrowser1.Document;
foreach(object o in doc.all)
Console.WriteLine(o.GetType().Name);
}

The code will print out the type name, even if after I installed into a
windows xp+.NET 1.1 without visual studio installed.
You may try the code above, if the problem persists, I think the problem
may need create dump or live debugging which is provided by MSPSS.
You may reach MSPSS via the link below.
http://support.microsoft.com

BTW: if you have no concern, I suggest you reinstall the .NET framework to
see if that works.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 17 '05 #10
Hi

Thanks for your quickly reply!
Unfortunately, I still can not reproduce the problem.

Here is my test code.
private void Form1_Load(object sender, System.EventArgs e)
{
this.axWebBrowser1.Navigate("www.google.com");
}

private void button1_Click(object sender, System.EventArgs e)
{
mshtml.HTMLDocument doc= (mshtml.HTMLDocument)axWebBrowser1.Document;
foreach(object o in doc.all)
Console.WriteLine(o.GetType().Name);
}

The code will print out the type name, even if after I installed into a
windows xp+.NET 1.1 without visual studio installed.
You may try the code above, if the problem persists, I think the problem
may need create dump or live debugging which is provided by MSPSS.
You may reach MSPSS via the link below.
http://support.microsoft.com

BTW: if you have no concern, I suggest you reinstall the .NET framework to
see if that works.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 17 '05 #11

Was this problem even got resolve? Now I am having the same problem.

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Jun 8 '06 #12


is this problem even got resolve? I am having the same issue here.

thanks

*** Sent via Developersdex http://www.developersdex.com ***
Jun 8 '06 #13

Hi,

How you resolved finally this issue? I am facing same problem. Please
help me out.

Thanks,
Hitesh.

*** Sent via Developersdex http://www.developersdex.com ***
Aug 22 '06 #14

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

Similar topics

0
by: Achim Domma (Procoders) | last post by:
Hi, I have a problem with a DCOM server written in python. Here is my minimal test object: class TestObject: _reg_clsid_ = "{ECDBB3BC-F0BF-4eef-87C0-D179A928DAB5}" _reg_progid_ =...
4
by: Jaydeep | last post by:
Hello, I am facing a strange problem. Problem accessing remote database from ASP using COM+ server application having VB components (ActiveX DLL) installed. Tier 1 : ASP front End (IIS 5.0) Tire...
1
by: Eirik Brattbakk | last post by:
Hi I have some problems accessing a soap service made in c# using an ATL/MFC client over SSL. I have tried both CSoapMSXMLInetClient and CSoapWininetClient as template arguments with my stub...
21
by: Gary | last post by:
When using an ASPX page for a DefaultRedirect it does not work if the ASPX page has any code in it. If I put ... If Not IsPostBack Then lblMessage.Text = Server.GetLastError.Message End If ...
39
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
1
by: Mahesh Devjibhai Dhola | last post by:
Hi, Scenario: The webservice was developed on windows 2000 Pro and deployed previously on windows XP pro for testing. We have tested for many days. The client for that service was 30+ and...
3
by: judy.j.miller | last post by:
Does anyone know why i can't access a form element value using dot notation in firefox, when i'm in a function. Works ok in the body. I'm trying to do this: var FarTemp = faren.temp.value; I...
5
by: weidongtom | last post by:
Hi, I tried to implement the Universal Machine as described in http://www.boundvariable.org/task.shtml, and I managed to get one implemented (After looking at what other's have done.) But when I...
4
by: Jon | last post by:
I wrote a VS 2005 C# express programme that accesses a web service. It works fine when there's a direct connection to the internet, but on two different PCs with internet access via a proxy, I get...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.