2016-12-25 142 views
3

我有一個C#控制檯應用程序部署在客戶機上。在客戶機中部署時,我得到System.TypeInitializationException。無法找到所需的Cef/CefSharp依賴關係

在的debug.log,我得到以下錯誤:

Unable to locate required Cef/CefSharp dependencies: 
Missing:CefSharp.BrowserSubprocess.exe 
Missing:CefSharp.BrowserSubprocess.Core.dll 
Missing:CefSharp.Core.dll 
Missing:CefSharp.dll 
Missing:icudtl.dat 
Missing:libcef.dll 
Executing Assembly Path:C:\myapp 

的問題是,所有的文件都存在於C:\ MYAPP目錄(這裏指定)。因此,我不確定爲什麼這些文件沒有被加載。此外msvcp120.dll,msvcr120.dll,vccorlib120.dll包含在c:\ myapp目錄中

+0

請參閱http://stackoverflow.com/help/mcve – amaitland

+0

您可以禁用依賴項檢查,它是Cef.Initialize的一個參數 – amaitland

+0

@amaitland在恢復我的代碼以再次模擬它之後,問題消失,因此可能與環境有關。 – 2017-01-09 05:46:32

回答

1

我有同樣的問題。首先我看到Cef.Initialize()函數只是不工作,所以我能像這樣performDependencyCheck選項:

Cef.Initialize(BrowserSettings, performDependencyCheck: true, browserProcessHandler: null); 

(根據這個例子https://github.com/cefsharp/CefSharp.MinimalExample/blob/master/CefSharp.MinimalExample.OffScreen/Program.cs

,我看到缺少一些文件。

之後,錯誤一直顯示,即使我不會錯過任何東西。所以我禁用了performDependencyCheck選項和它的工作(是這樣的:

Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null); 

希望它會幫助你

+0

55.0.0軟件包具有gitlink支持,因此您可以輕鬆調試開發機器上的源代碼。 https://開頭github上。com/GitTools/GitLink#gitlink – amaitland

+0

我也試圖禁用performDependencyCheck,但後來我意識到我無法在主框架中執行JavaScript。所以我會勸阻這樣做。請參閱我的回答。 –

2

正如許多人,我也跟着在官方Quick Start article設置了「任何CPU」的步驟。配置和我有同樣的問題缺少依賴時performDependencyCheck開始了。

這是因爲文章實際上是不完整的!

對於「任何CPU」的配置工作,你需要遵循所有在Feature Request - Add AnyCPU Support #1714的步驟(特別是最後一個!):

01下面

例如:

[STAThread] 
public static void Main() 
{ 
    var settings = new CefSettings(); 
    settings.BrowserSubprocessPath = @"x86\CefSharp.BrowserSubprocess.exe"; 

    Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null); 

    var browser = new BrowserForm(); 
    Application.Run(browser); 
} 

注:使用此代碼的時候,我還是會建議你使用performDependencyCheck: true,因爲它現在將僅報告真正的錯誤。

+1

我會離開performDependencyCheck在真 –

+1

是的你說得對,performDependencyCheck應該保持「真」。我剛剛引用了票證中的例子。但我會添加一個不是我的答案。謝謝 –

相關問題