0
votes

I have an application that is using the .NET WebBrowser control. It is loading a page that uses a javascript feature that requires at least IE 10. By default the WebBrowser control uses IE 7.

The page does contain the meta tag <meta http-equiv="X-UA-Compatible" content="IE=edge">.

When running the application on a physical machine running Windows 7 or Windows 10 the page loads just fine so I know the meta tag is effective.

However running on a VDI/VM environment with Windows Server 2012 the page doesn't fully load. The background color is loaded from the CSS but nothing else because of a javacript error.

Is there anything about a VDI/VM environment that could interfere with javascript running in a .NET WebBrowser control or cause it to not observe the meta tag?

1

1 Answers

0
votes

Try this code in the form load event

        int BrowserVer, RegVal;

        // get the installed IE version
        using (WebBrowser Wb = new WebBrowser())
            BrowserVer = Wb.Version.Major;

        // set the appropriate IE version
        if (BrowserVer >= 11)
            RegVal = 11001;
        else if (BrowserVer == 10)
            RegVal = 10001;
        else if (BrowserVer == 9)
            RegVal = 9999;
        else if (BrowserVer == 8)
            RegVal = 8888;
        else
            RegVal = 7000;

        // set the actual key
        using (RegistryKey Key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", RegistryKeyPermissionCheck.ReadWriteSubTree))
            if (Key.GetValue(System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe") == null)
                Key.SetValue(System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe", RegVal, RegistryValueKind.DWord);