I\'m trying to use CefSharp WindowForm Control in the VSTO Excel Addin. The CefSharp.WinForms version is 75.1.142 and I\'m making an addin on Excel 2013 (64 Bit) through VS
Using CefSharp
directly in an Office VSTO
plugin/addin is not supported.
If multiple VSTO Add-ins are installed for an application, each VSTO Add-in is loaded in a different application domain.
As per https://docs.microsoft.com/en-us/visualstudio/vsto/architecture-of-vsto-add-ins?view=vs-2019 Office VSTO
will load your add-in
using as AppDomain
(I believe even if you only load a single add-in the non-default appdomain will be used).
CefSharp
is built using VC++
which cannot be loaded in the non-default AppDomain
. The error you are seeing is related to the plugin being unable to load libcef.dll
, you could resolve this issue, only to be faced with Cannot pass a GCHandle across AppDomains
.
You can run CefSharp
out of process, for which there is an example. It's a little outdated, the fundamentals should still be relevant. See https://github.com/stever/AppHostCefSharp
My personal recommendation is to use CefGlue or ChromiumFx. Both are P/Invoke
based so use a fundamentally different approach to interacting with the unmanaged libcef.dll
.
See also