将控件添加到 tabview 页面时应用程序挂起
Application hangs when adding a control to a tabview page
我一直在用 C# 开发应用程序。直到最近我决定将 InitialiseChromium()
void 放在另一个 class 中时它才起作用,我发现我无法将控件添加到 mdtTab
TabPage。所以,我撤消了我的更改,但现在我的应用程序挂在 mdtTab.Controls.Add(browser);
browser2
被添加到另一个 TabPage
,但我的应用程序永远不会那么远。
我的代码如下:
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;
}
结果我通过在 Any CPU
平台中调试解决了这个问题,因为我不小心更改为 x86
。
Note that debugging on the AnyCPU
platform requires you to add some code to your project files if using CefSharp!
我一直在用 C# 开发应用程序。直到最近我决定将 InitialiseChromium()
void 放在另一个 class 中时它才起作用,我发现我无法将控件添加到 mdtTab
TabPage。所以,我撤消了我的更改,但现在我的应用程序挂在 mdtTab.Controls.Add(browser);
browser2
被添加到另一个 TabPage
,但我的应用程序永远不会那么远。
我的代码如下:
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;
}
结果我通过在 Any CPU
平台中调试解决了这个问题,因为我不小心更改为 x86
。
Note that debugging on the
AnyCPU
platform requires you to add some code to your project files if using CefSharp!