1

I need the WebBrowser Control in my Windows Forms application to render pages using the latest version of Internet Explorer, or atleast the latest version that is installed on my machine - which is IE 11.

A few weeks ago, before I began working on this project I came across a website called DevDocs.io, and in IE 11 it works. However, even after applying the registry hack I cannot view DevDocs.io in the WebBrowser control because apparently I am using an "Unsupported" browser. It then goes on to say that I need to use either Firefox, Chrome or IE 10+. I thought I was using IE 10+ since I had added the DWORD to the registry.

I've come across many websites that just don't display or behave normally due to the fact that the WebBrowser control still isn't rendering in IE11, or 10, or 9...

There are two things I would like to know:

  • Is there a method or class that exposes the rendering engine being used by the WebBrowser Control?
  • Why isn't the DWORD Registry hack working, and how do I get it to work?

To be clear, I have gone to the Registry, and looked up: HKEY LOCAL MACHINE > SOFTWARE > MICROSOFT > INTERNET EXPLORER > MAIN > FEATURE CONTROL > FEATURE_BROWSER_EMULATION and added a DWORD with values myApp.exe and 11000.

The 11000 is to get it to render using IE11, as per http://msdn.microsoft.com/en-us/library/ee330730%28VS.85%29.aspx#browser_emulation.

spike.y
  • 379
  • 5
  • 16

2 Answers2

3

You need to add your registry key under both the main (64bit) node and the 32bit node, HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl

You should then visit http://webdbg.com/ua.aspx to verify the document mode and UA string.

EricLaw
  • 54,427
  • 7
  • 140
  • 182
  • That did it! Thank you @EricLaw. I had given up on this project until your answer came along. Thanks! – spike.y May 05 '14 at 16:28
2

Here the method that I usually use and works for me (both for 32 bit and 64 bit applications):

    [STAThread]
    static void Main()
    {
        if (!mutex.WaitOne(TimeSpan.FromSeconds(2), false))
        {
            //another application instance is running
            return;
        }
        try
        {

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var targetApplication = Process.GetCurrentProcess().ProcessName  + ".exe";
            int ie_emulation = 10000;
            try
            {
                string tmp = Properties.Settings.Default.ie_emulation;
                ie_emulation = int.Parse(tmp);
            }
            catch { }
            SetIEVersioneKeyforWebBrowserControl(targetApplication, ie_emulation);

            m_webLoader = new FormMain();

            Application.Run(m_webLoader);
        }
        finally
        {
            mutex.ReleaseMutex();
        }
    }

    private static void SetIEVersioneKeyforWebBrowserControl(string appName, int ieval)
    {
        RegistryKey Regkey = null;
        try
        {


            Regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);

            //If the path is not correct or 
            //If user't have priviledges to access registry 
            if (Regkey == null)
            {
                YukLoggerObj.logWarnMsg("Application FEATURE_BROWSER_EMULATION Failed - Registry key Not found");
                return;
            }

            string FindAppkey = Convert.ToString(Regkey.GetValue(appName));

            //Check if key is already present 
            if (FindAppkey == "" + ieval)
            {
                YukLoggerObj.logInfoMsg("Application FEATURE_BROWSER_EMULATION already set to " + ieval);
                Regkey.Close();
                return;
            }

            //If key is not present or different from desired, add/modify the key , key value 
            Regkey.SetValue(appName, unchecked((int)ieval), RegistryValueKind.DWord);

            //check for the key after adding 
            FindAppkey = Convert.ToString(Regkey.GetValue(appName));

            if (FindAppkey == "" + ieval)
                YukLoggerObj.logInfoMsg("Application FEATURE_BROWSER_EMULATION changed to " + ieval + "; changes will be visible at application restart");
            else
                YukLoggerObj.logWarnMsg("Application FEATURE_BROWSER_EMULATION setting failed; current value is  " + ieval);



        }
        catch (Exception ex)
        {
            YukLoggerObj.logWarnMsg("Application FEATURE_BROWSER_EMULATION setting failed; " + ex.Message);

        }
        finally
        {
            //Close the Registry 
            if (Regkey != null)
                Regkey.Close();
        }


    }
Luca Manzo
  • 2,771
  • 2
  • 13
  • 9