Browser.GetRemoteDebuggingURL() 的 DotNetBrowser returns string.Empty

Browser.GetRemoteDebuggingURL() of DotNetBrowser returns string.Empty

我使用 DotNetBrowserControl

设置了一个 Winform 应用程序(将来会是 WPF)
BrowserView browserView = new 
    WinFormsBrowserView(BrowserFactory.Create(BrowserType.HEAVYWEIGHT));
Controls.Add((Control)m_BrowserView);
string remoteDebuggingUrl = m_BrowserView.Browser.GetRemoteDebuggingURL();

注意 remoteDebuggingUrlstring.Empty

DotNetBrowserVersion/DotNetBrowserChromium - Version:1.8.3.0 .NetFramework: 4.5.2

来自documentation

DotNetBrowser provides functionality that allows you to use the Chrome Developer Tools remote debugging feature. To enable this feature you must define the remote-debugging-port Chromium switch by calling the BrowserPreferences.SetChromiumSwitches(String...) method before creating any Browser instance.

Once you configured DotNetBrowser to use a specified remote debugging port, you can get a remote DevTools URL by calling the Browser.GetRemoteDebuggingURL() method:

Sample:

BrowserPreferences.SetChromiumSwitches("--remote-debugging-port=9222");
InitializeComponent();
browserView.Browser.LoadURL("http://www.google.com");
string remoteDebuggingURL = browserView.Browser.GetRemoteDebuggingURL();

感谢 stuartd,

这正是需要做的。

但实际上我找出了我的错。

BrowserPreferences.SetChromiumSwitches("--remote-debugging-port=9222")

http://dotnetbrowser-support.teamdev.com/documentation/chromium-switches

在这里你看到,SetChromiumSwitches 接受字符串或字符串参数数组

我的开关字符串一直是这样的"--switchOne --switchTwo", 所以它只是一个字符串而不是一个数组。

一般的问题是,它在早期是这样工作的。 因为我现在切换到 string[] 它工作正常