473,657 Members | 2,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with IE automation when used in webservice

hi guys,

I have encountered a problem with IE automation (.NET 2.0, C#, mshtml,
SHDocVw). I am writing a class for manipulating specific html pages
with frames. It is supposed to be used from a web service. The
problem is that when I use the InternetExplore r object in web service,
it seems like the underlying IE doesn't support frames. When I try to
access HTMLDocumentCla ss.frames property I get the following exception:

Specified cast is not valid.
at System.RuntimeT ype.ForwardCall ToInvokeMember( String memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData)
at mshtml.HTMLDocu mentClass.get_f rames()
at myclass.mymetho ds()

the code lines, that cause the exception:

ie = new InternetExplore r();
object dummy = null;
ie.Navigate("my url", ref dummy, ref dummy, ref dummy, ref dummy);
// ... omitted code assuring the html document is loaded ...
HTMLDocumentCla ss iedoc = (HTMLDocumentCl ass)ie.Document ;
FramesCollectio n frames = iedoc.frames; // this throws the exception
....

(when the same code is used in a "normal" windows forms application, it
works fine).

Feb 13 '06 #1
4 7926

Johny_W wrote:
hi guys,

I have encountered a problem with IE automation (.NET 2.0, C#, mshtml,
SHDocVw). I am writing a class for manipulating specific html pages
with frames. It is supposed to be used from a web service. The
problem is that when I use the InternetExplore r object in web service,
it seems like the underlying IE doesn't support frames. When I try to
access HTMLDocumentCla ss.frames property I get the following exception:

Specified cast is not valid.
at System.RuntimeT ype.ForwardCall ToInvokeMember( String memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData)
at mshtml.HTMLDocu mentClass.get_f rames()
at myclass.mymetho ds()

the code lines, that cause the exception:

ie = new InternetExplore r();
object dummy = null;
ie.Navigate("my url", ref dummy, ref dummy, ref dummy, ref dummy);
// ... omitted code assuring the html document is loaded ...
HTMLDocumentCla ss iedoc = (HTMLDocumentCl ass)ie.Document ;
FramesCollectio n frames = iedoc.frames; // this throws the exception
...

(when the same code is used in a "normal" windows forms application, it
works fine).


I'm having the same problem. Seems that all HTMLDocumentCla ss
properties that reference UI elements fail to get marshalled by COM
Interop when creating a new instance of the HTMLDocumentCla ss in web
services. Apparently web services execute according to a policy that
restricts the creation of UI elements. I'm trying to get at the
parentWindow property in order to be able to correctly release
resources when I'm done with the HTML parser but no go. When I attempt
to view the parentWindow property in the debugger the property
indicates that a Invalid Cast Exception has occurred. Thanks to this
foolishness I am frequently getting mshtml faults in w3wp.exe after
which time the web service becomes non functional. My guess is that
the windows are getting created but barring a reference to them in the
mshtml RCW wrapper there's not way to correctly release the reference
to the underlying COM object and it's associated resources.

The upshot seems to be that you can't create an HTMLDocumentCla ss
instance without creating several windows at the same time. You'll
notice that in a regular app the parentWindow is initialized correctly
and can be closed along with it's own parent window with a little
trickery. You'll also notice in task manager that memory and handles
get released correctly at the same time. Nevertheless in a web app or
web service it looks like you're screwed. Can't get to those windows.

If only Microsoft had modularized the HTML Parser in mshtml.dll and
made it independent of the UI we could all get a little rest.

Mar 10 '06 #2
OK. I got this to work. Thanks to a reply to another post.

I create a thread and set it's apartment state to STA. I execute the
parsing code in that thread and am able to access the associated
windows objects. I imagine this will for frames as well.

Mar 10 '06 #3
I tried your solution, but I get UnauthorizedAcc essException
immediately when I'm creating InternetExplore r object.

details:
System.Unauthor izedAccessExcep tion: Retrieving the COM class factory
for component with CLSID {0002DF01-0000-0000-C000-000000000046} failed
due to the following error: 80070005. at MyMethod()

In web.config I have set impersonation to my administrator account and
also Full trust. Is it possible that the created thread has weaker
permissions?

Mar 15 '06 #4
Johny,

You might find these links useful:

1) blog.crowe.co.n z/archive/2006/03/02/589.aspx
2) http://support.microsoft.com/default...b;en-us;257757

Hope this helps

Sriram

Mar 28 '06 #5

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

Similar topics

4
9486
by: ramarnath | last post by:
Problem in sending datatime format to the .net webservice from php. description follows. I've created a .net webservice. ..Net Webservice: <WebMethod()> _ Public Function HelloDate(ByVal mydate As DateTime) As String
2
5701
by: Miguel | last post by:
Hi, I'm developing an application in C# with Windows Forms for my company that is similar to the MSN Messenger. This application uses a webservice for registering users, etc... and as 2 webbrowser controls on it. Besides that i'm using the firewall client for isa server 2004 and it seems that the browsers aren't able to pass thru it... if i disable the firewall the browsers work fine, if i don't, the 2 browsers just stay there...
1
1593
by: Smugsboy | last post by:
Hi, I have a problem with a web service proxy written in .NET and used from VS6's C++ as COM object. This proxy works great when used from a .NET application. It does not seem to work when used as COM object for C++ application. What happens is this: I've created a class with the following attribute that inherites from this proxy class. This class is regisered using regasm.exe and installed using
5
2704
by: Dany C. | last post by:
We have install a valid SSL certificate issued to www.mycompany.com on our web server running IIS 6.0 / win2003 SP1. Then we have created a sub domain pointing to the same server for our web services at ws.mycompany.com. We have properly installed the server certificate on the client machine. When the client try to connect to our secure webservice at https:\\ws.mycompany.com we have the foolwing error: System.Net.WebException: The...
5
19581
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was having a problem in the calling program. I searched online and found suggestions that I return an Array instead so I modified my code (below) to return an Array instead of an ArrayList. Now I get the message when I try to run just my webservice...
1
1952
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 accessing the webservice each min. It was working 100% fine. Problem: But now in actual deployment, we have deployed webservice in Win Server 2003 and we have used all the default configurations. Now the clients are accessing that service the same way...
0
1371
by: Rob C | last post by:
I have several methods implemented in a webservice written in C#. The methods execute SQL against a SQL Server 2005 db and returns a Dataset (as XML). I am utilizing the webservice from a VC++ app by adding the web ref to the project which creates the header file for making the calls. I traced through the method call in my app and found the problem in the CAtlHttpClientT<TSocketClasstemplate implementation. The problem is happening in...
0
2675
by: =?Utf-8?B?TWFuaQ==?= | last post by:
Hi All, Problem in deploying my WebService developed using Asp.net WebServices 2005. I have designed simple WebService using Asp.net Webservices 2.0 , The webservice look this , using System; using System.Web; using System.Web.Services; using System.Web.Services.Protocols;
15
5342
by: =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?= | last post by:
Hi All, We are in the process of Upgrade Excel 2003 (Office 2003) to Excel 2007 (Office 2007) for one of web application. This web application is using Excel (Pivot Table) reports. With Excel 2003 application (Reports) works ok. But when Office 2003 is upgraded to Office 2007 Excel reports stops working. It Log the error “Exception from HRESULT: 0x800A03EC.” In database.
0
8407
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8512
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7347
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5638
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2739
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 we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.