views:

106

answers:

1

I realise it's an early release and unstable. I wouldn't dream of swapping out the default webbrowser control for IE9 in any other project, but in this case I specifically need IE9 to compare alongside other versions.

I'd like to have the .NET WebBrowser control use IE9 instead of the default version of IE on the machine. I have full control of the machine so it's no problem to hack away at system files or whatever else may be necessary.

Normally, this could be achieved by installing the update to IE, but in IE9's case, it installs a separate application, leaving the current version of IE untouched. This means the WebBrowser control continues to use the current version (which makes sense and was a smart move by MS, since IE9 is still under development). But in my (edge) case I need the WebBrowser control to use IE9.

Is it possible to embed IE9 in a .NET forms application?

EDIT

With Hans Passant's help I'm getting a bit further. Something very interesting is happening within IE9's prog files directory. There's a directory called "iepreview.exe.local" which, when removed, makes the IE9 Preview app use IE8 (checked it with the acid3 test).

Not quite what I want, but I'm wondering if this is some kind of redirection that I could exploit for my needs.

EDIT 2

I've tried applying the .local hack to both my copy of iexplore.exe and my .NET app and I've noticed something else interesting - both apps began using IE7 instead of IE8 (my version of IE) or IE9.

Could this be iexplore trying to use IE9 and then falling back onto IE7? Seems strange it would even have IE7 available, but that's the useragent string it starts using.

+3  A: 

The only way IE9 could install side-by-side is when it uses new GUIDs for the interfaces and coclasses. Which means that you cannot use WebBrowser, it has the GUIDs hard-coded.

There's one other option, using the AxHost wrapper. Right-click the toolbox, Choose Items, select the COM Components tab and locate IE9 in the list. No idea what it might be called, the old name was "Microsoft Web Browser", serviced by c:\windows\system32\ieframe.dll

You'll have to make do without the friendly WebBrowser and HtmlDocument wrapper classes.

Hans Passant
I don't have any COM registrations to my IE Platform Preview directory. All the DLLs are in a iepreview.exe.local subdirectory and the mshtml there has DllRegisterServer. So I expect it can be dropped into place, or even just regsvred where it is, but there's probably more to it than that.
Rup
Smells like reg-free COM. That does make sense, but makes your task considerably more difficult. You'd have to copy everything to your project's build directory. And create your own manifest. Brrr.
Hans Passant
I've updated my question with some further info about this.
Matthew Brindley
The .local file is enough to make COM use the local DLLs instead of the ones registered in the Registry. Very cheap reg-free COM. Would work for your program too, but you have to copy all the IE9 DLLs to your build directory. WebBrowser should then work and use IE9. If it isn't too incompatible.
Hans Passant
Aha, cool thanks. I gave this a try and it reverted to IE7 (my browser is IE8) - any ideas? Seems like it might not be compatible.
Matthew Brindley