我目前正在嘗試編寫一個小服務,它使用CefSharp(v57.0.0)將HTML呈現爲PDF文件,並按照說明在我的項目中使用「任何CPU」 Feature Request - Add AnyCPU Support)。 在我的項目我用下面的程序集解析器,似乎工作罰款(它初始化時加載CefSharp.Core.dll,CefSharp.dll):CefSharp NuGet包,AnyCPU找不到文件
// Will attempt to load missing assembly from either x86 or x64 subdir
private static Assembly Resolver(object sender, ResolveEventArgs args)
{
if (args.Name.StartsWith("CefSharp", StringComparison.Ordinal))
{
string assemblyName = args.Name.Split(new[] { ',' }, 2)[0] + ".dll";
string archSpecificPath = Path.Combine(
AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
Environment.Is64BitProcess ? "x64" : "x86",
assemblyName);
var outputAssembly = File.Exists(archSpecificPath) ? Assembly.LoadFile(archSpecificPath) : null;
return outputAssembly;
}
return null;
}
對於CefSharp的初始化我設置完全一樣的相同的值在例如:
var settings = new CefSettings()
{
// By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache")
};
// Perform dependency check to make sure all relevant resources are in our output directory.
Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
但是,如果我開始我的簡單的測試,我得到以下錯誤代碼:
Message: System.Exception : 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:D:\projects\CefService\bin\Debug\x86
任何想法可能是什麼Happe的寧在這裏以及如何解決這個問題?
小更新:我已經改變了我的項目中使用「86」或「64」的目標,現在(像上面鏈接的描述),如果我這工作從主程序調用轉換方法。 但是,如果我從NUnit調用它,程序將崩潰。 – Octoate
另一個更新:在與CefSharp玩了兩天後,我們決定跳過它並使用商業工具。它在箱子外面運作,我在不到一個小時內就可以實現所需的功能。 – Octoate