Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在web浏览器桌面应用程序中访问注册表时出错_C# - Fatal编程技术网

C# 在web浏览器桌面应用程序中访问注册表时出错

C# 在web浏览器桌面应用程序中访问注册表时出错,c#,C#,我正在开发web浏览器应用程序。许多网站运行正常,但其中一些网站会更新flipkart.com网站等浏览器。因此,我在最新的ie浏览器中为工作网站创建注册表项,但在该错误中显示“访问注册表时出错”。请帮我解决这个错误。这是我的密码 private void Form1_Load(object sender, EventArgs e) { Helper.SetBrowserEmulation(AppDomain.CurrentDomain.FriendlyName, IE.IE10); }

我正在开发web浏览器应用程序。许多网站运行正常,但其中一些网站会更新flipkart.com网站等浏览器。因此,我在最新的ie浏览器中为工作网站创建注册表项,但在该错误中显示“访问注册表时出错”。请帮我解决这个错误。这是我的密码

private void Form1_Load(object sender, EventArgs e)
{
   Helper.SetBrowserEmulation(AppDomain.CurrentDomain.FriendlyName, IE.IE10);
}

internal class Helper
{
   public static void SetBrowserEmulation(
   string programName, IE browserVersion)
   {
      programName = AppDomain.CurrentDomain.FriendlyName;
      RegistryKey regKey = Registry.CurrentUser.OpenSubKey(
      "Software\\Microsoft\\Internet Explorer\\Main" +
      "\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
      if (regKey != null)
      {
        try
        {
          regKey.SetValue(programName, browserVersion,
          RegistryValueKind.DWord);
        }
        catch (Exception ex)
        {
          throw new Exception("Error writing to the registry", ex);
        }
     }
     else
     {
       try
       {
         regKey = Registry.CurrentUser.OpenSubKey("Software" +
         "\\Microsoft\\Internet Explorer\\Main" +
         "\\FeatureControl", true);
         regKey.CreateSubKey("FEATURE_BROWSER_EMULATION");
         regKey.SetValue(programName, browserVersion,
         RegistryValueKind.DWord);
       }
       catch (Exception ex)
       {
         throw new Exception("Error accessing the registry", ex);
       }
     }
   }
 }

internal enum IE
{
  IE7 = 7000,
  IE8 = 8000,
  IE8StandardsMode = 8888,
  IE9 = 9000,
  IE9StandardsMode = 9999,
  IE10 = 10000,
  IE10StandardsMode = 10001
}

private void GoButton_Click(object sender, EventArgs e)
{
  string WebPage = UrlTextBox.Text.Trim();
  webBrowser1.Navigate(WebPage);
}