0

I've been making an application in C#. It was working until recently where I decided to place the InitialiseChromium() void in another class, to find I couldn't add controls to the mdtTab TabPage. So, I undid my changes, but now my app hangs at mdtTab.Controls.Add(browser);

browser2 is added to another TabPage, but my app never gets that far.

My code is below:

    public void InitialiseChromium()
    {
        CefSettings settings = new CefSettings
        {
            CachePath = DataPath,
            //publicly declared as DataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\WinMDT"
            BrowserSubprocessPath = @"x86\CefSharp.BrowserSubprocess.exe",
            PersistSessionCookies = true
        };
        // everything is good so far...

        // init cef with settings
        Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);            

        string mdtLink;

        using (WebClient wb = new WebClient())
        {
            mdtLink = wb.DownloadString("LINK REDACTED"); 
            //It downloads the url from a pastebin raw url so i can update the url it links to without updating the entire app
        }
        //everything still working fine...

        //create browser
        browser = new ChromiumWebBrowser(mdtLink); 

        //i added a breakpoint below and that was triggered, but not the one on the line below it
        mdtTab.Controls.Add(browser); // << Breakpoint triggers, but it hangs here
        browser.Dock = DockStyle.Fill; //<< Breakpoint is never triggered...

        //create browser
        browser2 = new ChromiumWebBrowser("www.google.co.uk");

        outsideWorldTab.Controls.Add(browser2);
        browser2.Dock = DockStyle.Fill;

        browser.BrowserSettings.ApplicationCache = CefState.Enabled;
        browser2.BrowserSettings.ApplicationCache = CefState.Enabled;
    }

1 Answers1

0

Turns out I fixed the problem by debugging in the Any CPU platform as I accidentally changed to x86.

Note that debugging on the AnyCPU platform requires you to add some code to your project files if using CefSharp!