首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CefSharp NuGet包,AnyCPU找不到文件

CefSharp NuGet包,AnyCPU找不到文件
EN

Stack Overflow用户
提问于 2017-10-09 13:51:02
回答 1查看 964关注 0票数 0

我目前正在尝试编写一个小服务,它使用CefSharp (v57.0.0)将HTML呈现到一个PDF文件中,并遵循在我的项目(特性请求-添加AnyCPU支持)中使用“任意CPU”的指令。在我的项目中,我使用了以下看似工作良好的程序集解析器(它在初始化期间加载CefSharp.Core.dll、CefSharp.dll ):

代码语言:javascript
复制
// 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的初始化,我设置完全相同的值,如示例中所示:

代码语言:javascript
复制
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);

但是,如果我启动简单的测试,就会得到以下错误代码:

代码语言:javascript
复制
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

有什么想法吗?这里可能会发生什么?如何解决这个问题?

EN

回答 1

Stack Overflow用户

发布于 2017-10-09 15:16:04

消息非常清楚,其他程序集无法加载。

这里有一些关于如何实现的通用说明:

  • 首先用libcef.dll和LoadLibrary加载本地的
  • 看看加载一个托管的主机是否会自动加载它所依赖的其他托管的,否则处理它们(乏味)

您可能对以下用于发现依赖项的工具感兴趣:

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46648118

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档