Use ChromiumWebBrowser from Inventor

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:

ChromiumBackgroundProcess

And the Chromium browser component seems to work fine:

InventorChromium

-Adam


Comments

2 responses to “Use ChromiumWebBrowser from Inventor”

  1. You legend! Thank you very much. I actually ditched CefSharp last night and got it working with ChromiumFx. I had exactly the same problem and only found info on the BrowserSubProcess requirement really late. I didn’t realize it was the same in CefSharp. I prefer CefSharp so I think I’ll go back to it. Thanks again for figuring this out!
    Gavin

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading