您無法更改WebBrowser使用哪種瀏覽器。然而,也有一些其他的解決方案:
1.使用其他Web瀏覽器
我會建議CefSharp。它使用鉻,它非常適合您的項目。
更多CefSharp:here
2.強制web瀏覽器運行IE11
默認情況下,Internet Explorer 7中由web瀏覽器使用。幸運的是,你可能會強迫它選擇一個更新的版本。
加載表單之前,先運行createRegistry()。你可以在Program.cs中調用它。如果要恢復註冊表,請運行removeRegistry()。
public static void createRegistry()
{
string filename = Process.GetCurrentProcess().MainModule.FileName;
filename = filename.Substring(filename.LastIndexOf('\\') + 1, filename.Length - filename.LastIndexOf('\\') - 1);
if (filename.Contains("vhost"))
filename = filename.Substring(0, filename.IndexOf('.') + 1) + "exe";
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true).SetValue(filename, 11001, RegistryValueKind.DWord);
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BEHAVIORS", true).SetValue(filename, 11001, RegistryValueKind.DWord);
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true).SetValue(filename, 11001, RegistryValueKind.DWord);
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BEHAVIORS", true).SetValue(filename, 11001, RegistryValueKind.DWord);
}
public static void removeRegistry()
{
string filename = Process.GetCurrentProcess().MainModule.FileName;
filename = filename.Substring(filename.LastIndexOf('\\') + 1, filename.Length - filename.LastIndexOf('\\') - 1);
if (filename.Contains("vhost"))
filename = filename.Substring(0, filename.IndexOf('.') + 1) + "exe";
try
{
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true).DeleteValue(filename);
}
catch
{
}
try
{
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BEHAVIORS", true).DeleteValue(filename);
}
catch
{
}
try
{
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true).DeleteValue(filename);
}
catch
{
}
try
{
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BEHAVIORS", true).DeleteValue(filename);
}
catch
{
}
}
思維導圖根本無法用於ie11。將嘗試使用cef# – nina
使用cefsharp並不像web瀏覽器那麼容易。由於版權問題,Cef的唯一缺點是無法播放MP3,MP4。無論如何,祝你好運! –
我的要求只是從特定的網址截圖。是否有其他出路,以便我只能使用c#代碼,而不必使用cef# – nina