CefSharp Core Runtime dll 格式不正确

问题描述

我得到 System.IO.FileNotFoundException: 'Could not load file or assembly 'CefSharp.Core.Runtime,Version=89.0.170.0,Culture=neutral,PublicKeyToken=40c4b6fc221f4138'. The system cannot find the file specified.' 文件和其他 dll 一起在 bin 目录中。

项目设置:

面向 netcore 3.1 的控制台应用程序使用面向 netcore 2.0 的类库,该类库加载使用具有 CefSharp.Offscreen 89.0.170 的 netcore 应用程序 3.1 构建的驱动程序

单步调试调试器时,我发现无法加载 CefSharp.Core 所依赖的 CefSharp.Core.Runtime.dll。尝试加载带有 incorrect format. (0x8007000B) 的程序。

dll 取自 cef nuget 包的 x64 文件夹,并在 csproj 中反映出来。

C:\Users\{user}\.nuget\packages\cefsharp.common.netcore\89.0.170\runtimes\win-x64\lib\netcoreapp3.1

我不知道是什么导致了这种情况,有没有人对在哪里查看以及可能是什么原因有任何建议?

EDIT 1 -- 代码说明

    private static System.Reflection.Assembly Resolver(object sender,ResolveEventArgs args)
        {
            if (!args.Name.StartsWith("CefSharp.Core.Runtime")) return null;
            string assemblyName = args.Name.Split(new[] {','},2)[0] + ".dll";
            string archSpecificPath = $"E:\\myProject\\bin\\Debug\\netcoreapp3.1\\{assemblyName}";
    
            // this returns true
            var exists = File.Exists(archSpecificPath);
            try
            {
                return System.Reflection.Assembly.LoadFile(archSpecificPath);
            }
            catch(Exception e)
            {
                // e's value: "An attempt was made to load a program with an incorrect format. (0x8007000B)"
                return null;
            }

EDIT 2 - bin 的内容及其来源

packages\cefsharp.common.netcore\89.0.170\runtimes\win-x64\lib\netcoreapp3.1

CefSharp.Core.dll

CefSharp.dll

CefSharp.Core.Runtime.dll

packages\cefsharp.offscreen.netcore\89.0.170\lib\netcoreapp3.1

CefSharp.OffScreen.dll

EDIT 3 - 更新的 bin

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...