只是为了进一步参考需要这个的其他人:
首先:感谢Boo和Lex Li
帮助我找到问题的答案。
您必须将某个注册表设置为正确的值:
32 位和 64 位应用程序有两组不同的密钥。
32位:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
Value Key: yourapplication.exe
64位:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
Value Key: yourapplication.exe
将此键设置为的值(此处取自 MSDN)为十进制值:
9999 (0x270F)
Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.
9000 (0x2328)
Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.
8888 (0x22B8)
Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.
8000 (0x1F40)
Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode.
7000 (0x1B58)
Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.
即使是强硬的 MSDN 也声称 9000 是自动分配的值。显然,这根本不是真的。
您可以在下面找到如何将这些密钥添加到注册表的代码。请注意,您的应用程序在调试时具有不同的进程名称。
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true);
if (key != null)
{
key.SetValue("YourApplicationName.exe", 9000, RegistryValueKind.DWord);
}
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true);
if (key != null)
{
key.SetValue("YourApplicationName.exe", 9000, RegistryValueKind.DWord);
}
所以谢谢大家,祝你好运
编辑:应该关闭用户帐户控制以使此代码正常工作。