Cannot run VS 2003 project using MSHTML, with .Net 2.0

A

Atara

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.InvalidCastException: Unable to cast COM object of type
'mshtml.HTMLBodyClass' to class type ''. COM components that enter the
CLR and do not support IProvideClassInfo 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.mcFontOrColorsChanged(Boolean isRefreshText)
...
at xxNamespace1.Main()

'-- error till here.

My relevant code:

Public Sub mcFontOrColorsChanged(ByVal isRefreshText As Boolean)
Dim doc As mshtml.HTMLDocument = ...
If (doc Is Nothing) Then Return
If (doc.all.length = 0) Then Return
If (doc.styleSheets Is Nothing) Then Return
If (doc.styleSheets.length = 0) Then Return
Dim docStyleSheet As mshtml.IHTMLStyleSheet =
CType(doc.styleSheets.item(0), mshtml.IHTMLStyleSheet)
Dim docStyleRules As mshtml.HTMLStyleSheetRulesCollection =
CType(docStyleSheet.rules, mshtml.HTMLStyleSheetRulesCollection)
... ' more code
Dim docBody As mshtml.HTMLBodyClass = CType(doc.body,
mshtml.HTMLBodyClass)
If Not (docBody Is Nothing) Then
... ' more code

'-- code till here.

My questions:
1. Why do I have casting problem only for 'mshtml.HTMLBodyClass' , but
no error for 'mshtml.IHTMLStyleSheet' casting ?
2. Will it help if I only change 'Microsoft.mshtml.dll' in my exe
directory ?
3. Where can I find 'Microsoft.mshtml.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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top