首页 文章

C#WebBrowser控件增强保护模式

提问于
浏览
1

我试图通过WebBrowser控件访问一个网页(不在我的控制之下),即allscripts sandbox . 我的计算机的Internet Explorer正确设置为所述网页(在可信站点中添加,允许并安装所有active-x插件,在兼容模式下运行等) .

webbrowser控件显示以下错误:

此网页要运行“某些ActiveX控件”,这与Internet Explorer的增强安全功能不兼容 . 如果您信任此站点,则可以为此站点禁用Enchanced保护模式并允许控件运行 .

我没有启用(据我所知)增强的保护模式 .

还试图忽略错误并继续登录显示消息

Centricity的基于.NET页面的容器无法初始化 . 确保您的.NET环境配置为向本网站授予完全信任 .

以上在默认IE上也是一个错误,直到我运行命令 %WINDIR%\Microsoft.NET\Framework\v2.0.50727\caspol -q -m -cg Trusted_Zone FullTrust .

我尝试了各种注册表项,但似乎都没有 .
我还尝试实现一个自定义的IInternetSecurityManager,它将所有URL映射到区域Trusted,并在所有ProcessUrlAction调用上返回URLPOLICY_ALLOW .

任何建议将不胜感激 .

2 回答

  • 0

    问题可能是webbrowser默认使用IE的旧版本 . 看看Use latest version of Internet Explorer in the webbrowser control

  • 0

    web浏览器控件是用一个com包装器包装的,该包装器将ie11压缩到ie7模式 . 那里没有其他很多东西可以想象会导致你的问题 .

    因为当你在外部运行ie11时这个页面适合你,那么最可能的解释似乎是你试图强制控制进入ie11模式就是问题所在 . 我建议你在这里试试Mentor的代码:

    Set WPF webbrowser control to use IE10 mode

    这将自动将正在运行的程序的名称添加到注册表 .

    var pricipal = new System.Security.Principal.WindowsPrincipal(
     System.Security.Principal.WindowsIdentity.GetCurrent());
     if(pricipal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator)) {
        RegistryKey registrybrowser = Registry.LocalMachine.OpenSubKey
         (@"Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
    string myProgramName = Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location);
    var currentValue = registrybrowser.GetValue(myProgramName);
    if (currentValue == null || (int)currentValue != 0x00002af9)
        registrybrowser.SetValue(myProgramName, 0x00002af9, RegistryValueKind.DWord);
    }
    else
    this.Title += " ( Первый раз запускать с правами админа )";
    

相关问题