无法创建浏览器错误(访问被拒绝)

时间:2018-01-08 02:22:00

标签: wpf dotnetbrowser

我得到"无法创建浏览器"使用我的应用程序的多个实例时出错。 我建议每个实例使用不同的文件夹。

错误: 无法创建浏览器。 System.ComponentModel.Win32Exception(0x80004005):访问被拒绝    在System.Diagnostics.ProcessManager.OpenProcess(Int32 processId,Int32 access,Boolean throwIfExited)    在System.Diagnostics.Process.GetProcessHandle(Int32访问,布尔throwIfExited)    在System.Diagnostics.Process.GetProcessTimes()    在System.Diagnostics.Process.get_StartTime()    在。 (Int32)    在. ()    在......( ,BrowserType)    在。 ( ,BrowserContext,BrowserType)    在。 (BrowserContext,Int32,BrowserType)    在DotNetBrowser.BrowserFactory.Create(BrowserContext browserContext,BrowserType browserType)    在DotNetBrowser.BrowserFactory.Create(BrowserContext browserContext,BrowserType browserType)    在DotNetBrowser.BrowserFactory.Create(BrowserContext browserContext)

我的代码:

private void Application_Startup(object sender, StartupEventArgs e)
    {
        if (e.Args[0] == "brow1") Test.MainWindow.browserCtx = "brow1")
        else if (e.Args[0] == "brow2") Test.MainWindow.browserCtx = "brow2")
        else Test.MainWindow.browserCtx = "brow3") 

        Test.MainWindow.site = e.Args[1];
    }

programPath = System.AppDomain.CurrentDomain.BaseDirectory;
BrowserPreferences.SandboxEnabled = true;
BrowserPreferences.ChromiumDirName = programPath + "Browser";
BrowserPreferences.CrashDumpDir = programPath + "Browser\\CrashDump\\";

browser = BrowserFactory.Create(new BrowserContext(new BrowserContextParams(programPath + "Browser\\Cache\\" + browserCtx)));

webView = new WPFBrowserView(browser);

var defaulDialogtHandler = webView.Browser.DialogHandler;
webView.Browser.DialogHandler = new CustomDialogHandler(defaulDialogtHandler);    

webView.Browser.PopupHandler = new CustomPopupHandler(webView);
webView.Browser.LoadHandler = new CustomLoadHandler();
browser.ContextMenuHandler = new CustomMenuHandler((FrameworkElement)webView, true);
browser.Preferences.WebRTCIPHandlingPolicy = BrowserPreferences.WebRTCIPHandlingPolicyEnum.DisableNonProxiedUdp;

mainLayout.Children.Add(webView);

browser.Preferences.AllowDisplayingInsecureContent = true;
browser.Preferences.FireKeyboardEventsEnabled = false;
browser.Preferences.FireMouseEventsEnabled = false;        
browser.Preferences.JavaScriptEnabled = true;
browser.Preferences.JavaScriptCanAccessClipboard = false;   
browser.Preferences.LocalStorageEnabled = true;         
browser.Preferences.PluginsEnabled = true;  
browser.Preferences.WebAudioEnabled = false; 

browser.FinishLoadingFrameEvent += Browser_FinishLoadingFrameEvent;    

browser.LoadURL(site);

0 个答案:

没有答案