ChromiumWebBrowser enables you to have a browser component in your app with Chrome capabilities. It requires an external process as well called CefSharp.BrowserSubprocess.exe, which is generated as part of your output by the CefSharp.WinForms NuGet component that you need to add to your project.
In case of having a standalone application the default settings are good enough because all the components will be created in the same output path next to your project’s exe. However, in case of an Inventor add-in (or any other add-in for that matter) the add-in files will be located somewhere other than the main exe (in this case Inventor.exe), so you need to adjust the CefSettings accordingly.
private void InitializeChromium()
{
CefSettings settings = new CefSettings();
// Get the folder path of the add-in dll
string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
settings.BrowserSubprocessPath = Path.Combine(assemblyFolder, "CefSharp.BrowserSubprocess.exe");
Cef.Initialize(settings);
ChromeWebBrowser = new ChromiumWebBrowser("http://www.google.com");
ChromeWebBrowser.LoadError += ChromeWebBrowser_LoadError;
this.Controls.Add(ChromeWebBrowser);
ChromeWebBrowser.Dock = DockStyle.Fill;
}
In this case you’ll see that the sub-process gets started successfully:
And the Chromium browser component seems to work fine:
-Adam



Leave a Reply