简体   繁体   English

.NET WebBrowser控件是否可以使用IE9?

[英]Is it possible for the .NET WebBrowser control to use IE9?

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. 我不会梦想在任何其他项目中换掉IE9的默认webbrowser控件,但在这种情况下我特别需要IE9与其他版本进行比较。

I'd like to have the .NET WebBrowser control use IE9 instead of the default version of IE on the machine. 我想让.NET WebBrowser控件使用IE9而不是机器上的默认IE版本。 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. 通常,这可以通过将更新安装到IE来实现,但在IE9的情况下,它会安装一个单独的应用程序,使IE的当前版本保持不变。 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). 这意味着WebBrowser控件继续使用当前版本(这很有意义并且是MS的智能举措,因为IE9仍处于开发阶段)。 But in my (edge) case I need the WebBrowser control to use IE9. 但在我的(边缘)情况下,我需要WebBrowser控件来使用IE9。

Is it possible to embed IE9 in a .NET forms application? 是否可以在.NET表单应用程序中嵌入IE9?

EDIT 编辑

With Hans Passant's help I'm getting a bit further. Hans Passant的帮助下,我得到了更多。 Something very interesting is happening within IE9's prog files directory. 在IE9的prog文件目录中发生了一些非常有趣的事情。 There's a directory called "iepreview.exe.local" which, when removed, makes the IE9 Preview app use IE8 (checked it with the acid3 test). 有一个名为“iepreview.exe.local”的目录,当删除时,会使IE9预览应用程序使用IE8(使用acid3测试检查)。

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 编辑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. 我已经尝试将.local hack应用于我的iexplore.exe和我的.NET应用程序的副本,我注意到其他有趣的东西 - 两个应用程序都开始使用IE7而不是IE8(我的IE版本)或IE9。

Could this be iexplore trying to use IE9 and then falling back onto IE7? 这可能是iexplore试图使用IE9然后再回到IE7? Seems strange it would even have IE7 available, but that's the useragent string it starts using. 看起来很奇怪它甚至可以使用IE7,但这是它开始使用的useragent字符串。

Actually, you can modify your registry to force your program to use IE9 rendering. 实际上,您可以修改注册表以强制程序使用IE9呈现。 Go to HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION and add a new DWORD value named your program name (with .exe) and a decimal value set to 9999. 转到HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft \\ Internet Explorer \\ MAIN \\ FeatureControl \\ FEATURE_BROWSER_EMULATION并添加一个名为程序名称(带.exe)的新DWORD值和十进制值设置为9999。


You can also modify your registry to force your program to use IE9 GPU Rendering. 您还可以修改注册表以强制程序使用IE9 GPU渲染。 Go to HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_GPU_RENDERING and add a new DWORD value named your program name (with .exe) and a hexadecimal value set to 1. 转到HKEY_CURRENT_USER \\ Software \\ Microsoft \\ Internet Explorer \\ Main \\ FeatureControl \\ FEATURE_GPU_RENDERING并添加一个名为程序名称(带.exe)的新DWORD值和十六进制值设置为1。


THIS ONLY WORKS IF YOU ACTUALLY HAVE IE9! 如果您实际上有IE9,这只能工作! You must download IE9 first, before you do this, or it will not work . 在执行此操作之前,必须首先下载IE9,否则它将无法运行 If you want to render the pages with IE8 just change the 9999 to 8888. 如果要使用IE8渲染页面,只需将9999更改为8888即可。

Note: GPU Rendering is only available in IE9 注意: GPU渲染仅适用于IE9

The only way IE9 could install side-by-side is when it uses new GUIDs for the interfaces and coclasses. IE9可以并排安装的唯一方法是它为接口和coclasses使用新的GUID。 Which means that you cannot use WebBrowser, it has the GUIDs hard-coded. 这意味着您无法使用WebBrowser,它具有硬编码的GUID。

There's one other option, using the AxHost wrapper. 还有另外一个选项,使用AxHost包装器。 Right-click the toolbox, Choose Items, select the COM Components tab and locate IE9 in the list. 右键单击工具箱,选择Items,选择COM Components选项卡,然后在列表中找到IE9。 No idea what it might be called, the old name was "Microsoft Web Browser", serviced by c:\\windows\\system32\\ieframe.dll 不知道它叫什么,旧名称是“Microsoft Web Browser”,由c:\\ windows \\ system32 \\ ieframe.dll提供服务

You'll have to make do without the friendly WebBrowser and HtmlDocument wrapper classes. 如果没有友好的WebBrowser和HtmlDocument包装类,您将不得不这样做。

After a lot of Google-ing I have discovered that there are two different sets of keys for FEATURE_BROWSER_EMULATION for 32 bit and 64 bit applications. 经过大量的Google-ing后,我发现对于32位和64位应用程序, FEATURE_BROWSER_EMULATION有两组不同的密钥。 You need to set yours in the right place depending on the machine you are running. 您需要根据您运行的机器将您的设置放在正确的位置。 Also you need to make sure you install the correct version of the browser you want to emulate. 此外,您需要确保安装要模拟的正确版本的浏览器。

32 bit: 32位:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\**FEATURE_BROWSER_EMULATION**

Value Key: (DWORD) yourapplication.exe

64 bit: 64位:

HKEY_LOCAL_MACHINE\SOFTWARE\**Wow6432Node**\Microsoft\Internet Explorer\MAIN\FeatureControl\**FEATURE_BROWSER_EMULATION**

Value Key: (DWORD) yourapplication.exe 

The value to set this key to is (taken from MSDN here) as decimal values: 将此键设置为的值(取自此处的MSDN)为十进制值:

9999 (0x270F) Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive. 9999(0x270F) Internet Explorer 9.无论!DOCTYPE指令如何,网页都以IE9标准模式显示。

9000 (0x2328) Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. 9000(0x2328) Internet Explorer 9.包含基于标准的网页!DOCTYPE指令以IE9模式显示。

8888 (0x22B8) Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive. 8888(0x22B8)网页以IE8标准模式显示,与!DOCTYPE指令无关。

8000 (0x1F40) Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. 8000(0x1F40)包含基于标准的网页!DOCTYPE指令以IE8模式显示。

7000 (0x1B58) Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. 7000(0x1B58)包含基于标准的网页!DOCTYPE指令以IE7标准模式显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM