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 -
System.InvalidC astException: Unable to cast COM object of type
'mshtml.HTMLBod yClass' to class type ''. COM components that enter the
CLR and do not support IProvideClassIn fo or that do not have any interop
assembly registered will be wrapped in the __ComObject type. Instances
of this type cannot be cast to any other class; however they can be cast
to interfaces as long as the underlying COM component supports
QueryInterface calls for the IID of the interface.
at xxNamespace3.mc FontOrColorsCha nged(Boolean isRefreshText)
...
at xxNamespace1.Ma in()
'-- error till here.
My relevant code:
Public Sub mcFontOrColorsC hanged(ByVal isRefreshText As Boolean)
Dim doc As mshtml.HTMLDocu ment = ...
If (doc Is Nothing) Then Return
If (doc.all.length = 0) Then Return
If (doc.styleSheet s Is Nothing) Then Return
If (doc.styleSheet s.length = 0) Then Return
Dim docStyleSheet As mshtml.IHTMLSty leSheet =
CType(doc.style Sheets.item(0), mshtml.IHTMLSty leSheet)
Dim docStyleRules As mshtml.HTMLStyl eSheetRulesColl ection =
CType(docStyleS heet.rules, mshtml.HTMLStyl eSheetRulesColl ection)
... ' more code
Dim docBody As mshtml.HTMLBody Class = CType(doc.body,
mshtml.HTMLBody Class)
If Not (docBody Is Nothing) Then
... ' more code
'-- code till here.
My questions:
1. Why do I have casting problem only for 'mshtml.HTMLBod yClass' , but
no error for 'mshtml.IHTMLSt yleSheet' casting ?
2. Will it help if I only change 'Microsoft.msht ml.dll' in my exe
directory ?
3. Where can I find 'Microsoft.msht ml.dll' for .Net 2.0 ?
4. Is there a link I can see the difference in MSHTML classes using .Net
2.0 vs. using .Net 1.1 ?
5. Did anyone else tried to run a VS 2003 app using MSHTML with .NET 2.0
? Did you have any problems ?
Thanks,
Atara.
*** Sent via Developersdex
http://www.developersdex.com ***