Problem with .NET 2.0 and MSHTML

H

Hans Merkl

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.

"Could not load file or assembly 'Microsoft.mshtml, Version=7.0.3300.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The system cannot find the file specified."

The machine has .NET 2 installed and all the latest patches.

It seems I am using a newer MSHTML version on my development machine. I
wouldn't mind using an older version but I don't know where to get a
typelib for older MSHTML versions.

Has anybody else seen this problem and knows a workaround other than not
using MSHTML?

Thanks

Hans Merkl
 
N

Nicholas Paldino [.NET/C# MVP]

Hans,

If you are using MSHTML, then you might want to consider using the
classes in the System.Windows.Forms namespace which are HTML DOM elements
(HtmlDocument, HtmlElement, and a host of other classes). They should give
you what you need, as well as eliminate that issue with conflicting MSHTML
versions.

Hope this helps.
 
M

Max

That's what I ended up doing. But these classes are quite limited.

For example: Do you know how to create a HtmlDocument object from a file
without using a WebBrowser control? I haven't figured that out.

MSHTML is much more powerful and I know it already.
 
N

Nicholas Paldino [.NET/C# MVP]

Max,

You are right, it is a little limited. In order to do that, you would
have to get the object from the DomDocument property, and cast that to the
IPersistFile interface (you can use the one in the
System.Runtime.InteropServices.ComTypes namespace). Then, you can call the
Load method on the interface, and it should load the contents from disk.

Hope this helps.
 
M

Max

That will cause me to use MSHTML and I will run into my problem again :)

There must be a solution for this. By default VS.NET references an MSHTML
interop from the GAC. I just need to reference another interop assembly.
 
W

Willy Denoyette [MVP]

Hans Merkl said:
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.

"Could not load file or assembly 'Microsoft.mshtml, Version=7.0.3300.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The system cannot find the file specified."

The machine has .NET 2 installed and all the latest patches.

It seems I am using a newer MSHTML version on my development machine. I
wouldn't mind using an older version but I don't know where to get a
typelib for older MSHTML versions.

Has anybody else seen this problem and knows a workaround other than not
using MSHTML?

Thanks

Hans Merkl

'Microsoft.mshtml, Version=7.0.3300.0,......
is a v1.x assembly, I could be wrong, but I don't think it's part of the
v2.0 Framework. Are you sure it's present in the GAC?


Willy.
 
M

Max

'Microsoft.mshtml, Version=7.0.3300.0,......
is a v1.x assembly, I could be wrong, but I don't think it's part of the
v2.0 Framework. Are you sure it's present in the GAC?


Willy.


When I look at the properties of the reference in my project I this is the
file location:
C:\WINDOWS\assembly\GAC\Microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a\Microsoft.mshtml.dll

I had the beta versions of the framework installed (uninsitalled them
before I installed the final version though). Maybe that's the problem?
 
W

Willy Denoyette [MVP]

What I mean is that it should be present in the GAC on the target machine.
If not, you should deploy it with your application, or your should install
the redistributable of the primary interop assemblies (see Program
files\Common Files\Merge modules).

Willy.
 
N

Nicholas Paldino [.NET/C# MVP]

Max,

I don't see how it would. The classes in the System.Windows.Forms
namespace use MSHTML as well under the covers, so it's a matter of your
interop assembly being incorrect.
 
M

Max

You are right. I installed vs_piaredist.exe from the directory "Merge
Modules" and now it works. I guess the name indicates I can redistribute it
wth my app.

I am getting too old for this.....
 
M

Max

Max,

I don't see how it would. The classes in the System.Windows.Forms
namespace use MSHTML as well under the covers, so it's a matter of your
interop assembly being incorrect.

Please see my response to Willy. Running vs_piaredist.exe solved the
problem.
 

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