WebBrowser control to use IE9
I want that the WebBrowser control to use IE9. IE9 is installed on the computer, but the WebBrowser control is still using IE8.
I verified with http://www.whatbrowser.org/en/. I try to make some changes to the registry (found开发者_运维问答 a solution here) but is not working.
I think it is the user agent string that is being passed to the site. It is misidentifying it as IE8 as it might not be meeting the requirements in their logic to match as IE9. I can see the same thing happen on my box as well. You could specify the user agent string to use if you want. Add this to your project
In your using statements add ...
using System.Runtime.InteropServices;
Within your form class add ....
[DllImport("urlmon.dll", CharSet = CharSet.Ansi)]
private static extern int UrlMkSetSessionOption(int dwOption, string pBuffer, int dwBufferLength, int dwReserved);
const int URLMON_OPTION_USERAGENT = 0x10000001;
public void ChangeUserAgent(String Agent)
{
UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, Agent, Agent.Length, 0);
}
Then just call it somewhere in your code ... maybe the constructor, or the form_load event.
ChangeUserAgent("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
Browsers lie about their "user agent" to give web sites a break. You're running 9, you cannot have 8 and 9 installed at the same time unless you used the beta version. See this blog post for details about the user agent string.
If you want to make sure then look at the DLL version that gets loaded. Project + Properties, Debug, tick "Unmanaged code debugging". Start your program, Debug + Break All. Debug + Windows + Modules and locate ieframe.dll in the list. The version number column should tell you. I'm getting "8.00.7600.16385 (win7_rtm.090713-1255)", the Win7 release version. I don't have IE9 installed yet.
Use this in the HTML head:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Otherwise:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION\yourexename.exe - REG_DWORD = 9000 (decimal)
You can try to add registry value that informs your WebBrowser control witch version of IE you would like to run for your application.
I had similar problem - more here
It seems it might be your page detection script. Try this site (http://www.whatismybrowser.com/). I know other sites gave me the wrong information, but this site correctly identified the browser as the version of IE that was installed on my machine.
精彩评论