Forcing IE to run as IE9 with embedded web browser

If you embed IE in a windows application, you may notice that it runs in IE7 Emulated mode. This is likely NOT what you want.

I’ve added code like below to solve the problem:

string appName = ""; try { appName = Path.GetFileName(Assembly.GetEntryAssembly().Location);

const string IE_EMULATION = @"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";

using (var fbeKey = Registry.CurrentUser.OpenSubKey(IE_EMULATION, true))

{ 

fbeKey.SetValue(appName, 9000, RegistryValueKind.DWord);

}
}

catch(Exception ex) { MessageBox.Show(appName + "\n" + ex.ToString(), "Unexpected error setting browser mode!"); }

There’s a special registry key that must be set before IE9 loads and is navigated … it must be set to the name of your application. Oddly, not the full path to your application, just the name of your executable.

You may want to delete this registry setting when your application exits.