1
我有使用CefSharp與初始化設置緩存路徑簡單的WPF應用程序:C#CefSharp WPF着定位依賴條件
try
{
var settings = new CefSettings();
settings.CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Cache");
Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
它運作良好,但我使用此代碼,以便啓動時,系統啓動:
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
key.SetValue(Assembly.GetExecutingAssembly().GetName().Name, Assembly.GetExecutingAssembly().Location);
如果應用程序是由系統啓動時啓動我得到這個錯誤在catch塊:
System.Exception: Unable to lacte requred Cef/CefSharp dependencies:
Missing:CefSharp.BrowserSubprocess.exe
Missing:CefSharp.BrowserSubProcess.Core.dll
Missing:CefSharp.Core.dll
Missing:icudtl.dat
Missing:libcef.dll
但是,當我運行應用程序manualy它效果很好。 謝謝!
這是因爲您尚未在註冊表中設置啓動密鑰的工作目錄。 –
@AliBahraminezhad你能幫我嗎? - 我可以在哪裏設置工作目錄? – Fori
所以我找到解決方案:'Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);' - 添加berfore初始化。謝謝@AliBahraminezhad – Fori