1

I'm getting "Failed to create Browser" error when using multiple instances of my app. I use different folders for each instance as advised.

Error: Failed to create Browser. System.ComponentModel.Win32Exception (0x80004005): Access is denied at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited) at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean throwIfExited) at System.Diagnostics.Process.GetProcessTimes() at System.Diagnostics.Process.get_StartTime() at ‪‍‫‍‫‬‎‫‬‭‭‎‌‭‭‮‎​​‪‭‍‎‏‫‬‬‮.‍‪​‪‪‬‌​‎‪‎‬‍‬‬‌‍‎‮‌‎‎‭‮(Int32 ) at ​‏‪‍‫‭‮‌‬‏‫‫‭‭​‍‫‭‌‭‬‌‍‮.‌‭‮‫​‏‎‪‪‫‬​‭‬‪‮‏‭‏‮‮() at ‪‬​‭‎​​‬‫‫‭‬‍‪‬‏​‭‌‌‮‪‫‮..ctor(‍‏‭‬‏‎‍‭‮‫‮‭‬‪‭‎‪​‌​‪‌‭‫‏‌‍‮ , BrowserType ) at ‍‎​‫‬‬‪​‭‪‪‬‍‪‬‭‭‪‏‪‎‭‎‍‫‬‮.‏‌‏‬‎‬‌‭‎‎‫‎​‌‬‪‬‮‎‫‏‌‎‌‌‏‌‏‮(‍‮​​‍‮‎‭‌‌‏‍‪‭‎‫‫‪‮‮ , BrowserContext , BrowserType ) at ‍‎​‫‬‬‪​‭‪‪‬‍‪‬‭‭‪‏‪‎‭‎‍‫‬‮.‏‌‏‬‎‬‌‭‎‎‫‎​‌‬‪‬‮‎‫‏‌‎‌‌‏‌‏‮(BrowserContext , Int32 , BrowserType ) at DotNetBrowser.BrowserFactory.Create(BrowserContext browserContext, BrowserType browserType) at DotNetBrowser.BrowserFactory.Create(BrowserContext browserContext, BrowserType browserType) at DotNetBrowser.BrowserFactory.Create(BrowserContext browserContext)

My code:

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);
Samuel
  • 35
  • 4
  • Could you please provide the DotNetBrowser logging? Here is the link how to enable it: https://dotnetbrowser.support.teamdev.com/support/solutions/articles/9000110288-logging – Vladyslav Tsvek Jan 09 '18 at 15:54
  • I enabled logging and solved the problem, it was a SQLite error (database is locked). I believe that I killed the process at one point when the browser was accessing the cache/history database and the the browser was not properly disposed so the database remained locked. I deleted the cache folder and now it works.) Error https://pastebin.com/nJeDVbd5 – Samuel Jan 09 '18 at 19:45
  • @Cœur thank you for the link. I read it. – Vladyslav Tsvek Jan 16 '18 at 11:02

0 Answers0