2016-12-01 13 views
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 

しかし、私は手動でアプリを実行するとうまくいきます。 ありがとう!

+0

レジストリにスタートアップキーの作業ディレクトリを設定していないためです。 –

+0

@AliBahraminezhadそしてあなたは私を助けることができますか? - どこに勤務先を置くことができますか? – Fori

+1

私は解決策を見つけました: 'Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);' - berfore初期化を追加します。ありがとう@AliBahraminezhad – Fori

答えて

0

working directoryはアプリケーションのbinディレクトリではありません。

Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); 
key.SetValue(Assembly.GetExecutingAssembly().GetName().Name, Assembly.GetExecutingAssembly().Location); 

現在のディレクトリをアプリのbinパスに変更する方法はたくさんあります。最も簡単な方法は、あなたのコード内のカレントディレクトリを変更することです(あなたの提案どおり)。

Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain‌​.BaseDirectory);