CefSharp in VSTO Addin

前端 未结 1 1617
醉梦人生
醉梦人生 2021-01-15 15:56

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

相关标签:
1条回答
  • 2021-01-15 16:41

    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

    • https://github.com/cefsharp/CefSharp/issues/1191
    • https://github.com/cefsharp/CefSharp/issues/351
    • Cefsharp in ExcelDNA
    • Cannot pass a GCHandle across AppDomains: solution without delegates?
    • https://developercommunity.visualstudio.com/content/problem/169359/ccli-dll-is-initialized-in-wrong-appdomain.html
    0 讨论(0)
提交回复
热议问题