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 2017.
I'm getting FileNotFoundException: 'Could not load file or assembly 'CefSharp, Version=75.1.142.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138' or one of its dependencies. The system cannot find the file specified.' on the below code execution.
public void InitBrowser()
{
var cefSettings = new CefSettings();
cefSettings.MultiThreadedMessageLoop = true;
// I'm setting current directory to D:\\CEF\\cefsharp\\ExcelWinform\\ExcelWinformAddIn\\bin\\x64\\Debug\\ where all the CefSharp dlls and dependencies are present.
cefSettings.BrowserSubprocessPath = "D:\\CEF\\cefsharp\\ExcelWinform\\ExcelWinformAddIn\\bin\\x64\\Debug\\CefSharp.BrowserSubprocess.exe";
if (!Cef.Initialize(cefSettings, performDependencyCheck: true, browserProcessHandler: null))
{
throw new Exception("Unable to Initialize Cef");
}
browser = new ChromiumWebBrowser("http://www.google.com");
{
Dock = DockStyle.Fill;
}
BrowserSettings browserSettings = new BrowserSettings();
//browserSettings.FileAccessFromFileUrls = CefState.Enabled;
//browserSettings.UniversalAccessFromFileUrls = CefState.Enabled;
browserSettings.BackgroundColor = 0xFFFF00;
browserSettings.LocalStorage = CefState.Enabled;// enable Local access
browser.BrowserSettings = browserSettings;
this.Controls.Add(browser);
browser.Dock = DockStyle.Fill;
}
If instead of VSTO Excel addin, I just create a simple WindowFrom application then the abve code is working fine.