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