views:

703

answers:

3

I am using mshtml to parse HTML in my ASP.NET-MVC application. Works great on my development machine, which has VS2008 Professional installed. Works great on my staging machine, which has VS Express 2008/WebDev installed. But it throws a FileNotFoundException when trying to load the COM object on the production server, which has no versions of Visual Studio.

Exception type: FileNotFoundException 
    Exception message: 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.

I don't want to install Visual Studio on the production box. I have read a suggestion that running C:\Program files\Common Files\Merge modules\vs_piaredist.exe solves this problem but this directory does not exist on my production box. How can I use mshtml on the production machine?

A: 

Isn't mshtml IE dependent? What version of IE is installed on the production box? Consider upgrading to atleast 6

Paul U
IE7. The mshtml.dll is sitting in the system32 dir, but for whatever reason, the application cannot see it.
magnifico
A: 

Using vs90_piaredist from the dev machine seems to be the solution. The interop assembly is called Microsoft.mshtml.dll and it lives at C:\Program Files\Microsoft.NET\Primary Interop Assemblies. Running vs90_piaredist created this directory on the production machine, and placed 5 interop dlls in there, including Microsoft.mshtml.dll.

This thread had some good discussion on the issue.

magnifico
A: 

IE is unmanaged code so there needs to be a interop layer to go from managed to unmanaged. The Primary Interop Assembly (PIA) is one that is usually shipped by the vendor. This is why you're being suggested to run the piaredist.exe

ajma