tags:

views:

371

answers:

2

Is there any way to force a C# application to use a specific version of the MSHTML DLL?

I'm trying to write an application that uses the different versions of the IE rendering engine to help web designers test their creations for backwards compatibility with IE6, IE7 etc...

As far as I understand so far, the SHDOCVW DLL 'hosts' or 'runs' the MSHTML DLL (http://msdn.microsoft.com/en-us/library/aa741313%28VS.85%29.aspx).

I have been able to create a Microsoft Web Browser (COM Component version 1.1) on the application form by dragging the version 6.0.2900.2877 SHDOCVW.DLL onto the Toolbox in Visual C# 2008 Express Edition as well as create a standard WebBrowser .NET component in the hope that the COM Component would use v6 of MSHTML (located in the same folder as the v6 SHDOCVW DLL)... however both components seem to use the same (perhaps the system?) version of MSHTML.

I've run the app in XP SP2 with IE6 and XP SP3 with IE7.

In SP2 with IE6 both browser components report $_SERVER['HTTP_USER_AGENT'] as MSIE 6.0 and in SP3 with IE7 both browser components report $_SERVER['HTTP_USER_AGENT'] as MSIE 7.0.

Does anyone know if it is possible to force use of a particular version of the MSHTML DLL? And if so, how?

+1  A: 

You could use the Type.GetTypeFromProgId method in order to resolve the ProgId string for the specific version of MSHTML that you want to use. Then use Activator.CreateInstance() to create an instance of the web browser control. After that you can cast the result to the respective interface you want to use, like in the following example (unfortunately, I do not know the correct ProgId of MSHTML):

string progId = "MyProgIdValue";
Type type = Type.GetTypeFromProgID(progId);
object mshtml = Activator.CreateInstance(type);
EFrank
+1  A: 

Can't help with the code but this program already does what you're trying to acomplish

IETester

Seems to be down atm though

George