CEFSHARP-发布:无法加载文件或汇编' cefsharp.core.runtime.dll'

发布于 2025-01-19 02:12:42 字数 3589 浏览 2 评论 0原文

使用 CefSharp.WinForms(NuGet 下载)版本:99.2.140

我已更新 .csproj 文件以包含

<CefSharpAnyCpuSupport>true</CefSharpAnyCpuSupport>

并将 App.config 文件更新为包含:

<runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <probing privatePath="x86"/>
      </assemblyBinding>
</runtime>

使用:Microsoft Visual C++ 2015-2022 Redistributable (x86) - 14.31.31103 使用:Microsoft Visual C++ 2015-2022 可再发行组件 (x64) - 14.31.31103 (我已将构建设置为明确的 x86 和 x64,它们具有相同的结果。)

我使用 CefSharp 构建了几个解决方案,它们都有相同的问题。它们可以从 Visual Studio 完美运行(调试或发布模式)。但是,一旦我发布它。巴姆.. “无法加载文件或程序集'CefSharp.Core.Runtime.dll'...”

呃,我被卡住了:( 真挚地; 亚历克斯.

附言。这是我当前在类程序中的代码。 '无法加载文件... Build | 时会出现“CefSharp.Core.Runtime..”平台目标:AnyCPU 或 x64。如果平台目标设置为 x86 它将起作用

static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    public static int Main(string[] args)
    {
        CefRuntime.SubscribeAnyCpuAssemblyResolver();
        //For Windows 7 and above, best to include relevant app.manifest entries as well
        Cef.EnableHighDPISupport();
        var exitCode = CefSharp.BrowserSubprocess.SelfHost.Main(args);

        if (exitCode >= 0)
        {
            return exitCode;
        }

        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"),
            BrowserSubprocessPath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
        };

        //Example of setting a command line argument
        //Enables WebRTC
        // - CEF Doesn't currently support permissions on a per browser basis see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access
        // - CEF Doesn't currently support displaying a UI for media access permissions
        //
        //NOTE: WebRTC Device Id's aren't persisted as they are in Chrome see https://bitbucket.org/chromiumembedded/cef/issues/2064/persist-webrtc-deviceids-across-restart
        settings.CefCommandLineArgs.Add("enable-media-stream");
        //https://peter.sh/experiments/chromium-command-line-switches/#use-fake-ui-for-media-stream
        settings.CefCommandLineArgs.Add("use-fake-ui-for-media-stream");
        //For screen sharing add (see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access#comment-58677180)
        settings.CefCommandLineArgs.Add("enable-usermedia-screen-capturing");

        //Perform dependency check to make sure all relevant resources are in our output directory.
        //IMPORTANT: MUST set performDependencyCheck false
        Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new MainForm());

        return 0;
    }
}

我收到以下 .NET 运行时错误

应用程序:InventoryDB.exe 框架版本:v4.0.30319 描述:由于未处理的异常,进程被终止。 异常信息:System.IO.FileNotFoundException 位于 CefSharp.Cef.EnableHighDPISupport() 在 InventoryDB.Program.Main(System.String[])

在此处输入图像描述

Using CefSharp.WinForms (NuGet Download) Version: 99.2.140

I've updated .csproj file to include

<CefSharpAnyCpuSupport>true</CefSharpAnyCpuSupport>

And updated the App.config file to inlcude:

<runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <probing privatePath="x86"/>
      </assemblyBinding>
</runtime>

Using: Microsoft Visual C++ 2015-2022 Redistributable (x86) - 14.31.31103
Using: Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.31.31103
(I've set the build to be explicity x86 & x64 which had the same results.)

I've built a couple of Solutions using CefSharp and they both have the same issue. They run perfectly from Visual Studios (Debug OR Release Mode). But, once I publish it. Bam..
"Could not load file or assembly 'CefSharp.Core.Runtime.dll'..."

Ughh, I'm stuck :(
Sincerely;
Alex.

PS. Here's my current Code in class Program. A 'Could not load file...
'CefSharp.Core.Runtime.. ' will occur when Build | Platform target: AnyCPU or x64. It will work if Platform targe set to x86

static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    public static int Main(string[] args)
    {
        CefRuntime.SubscribeAnyCpuAssemblyResolver();
        //For Windows 7 and above, best to include relevant app.manifest entries as well
        Cef.EnableHighDPISupport();
        var exitCode = CefSharp.BrowserSubprocess.SelfHost.Main(args);

        if (exitCode >= 0)
        {
            return exitCode;
        }

        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"),
            BrowserSubprocessPath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
        };

        //Example of setting a command line argument
        //Enables WebRTC
        // - CEF Doesn't currently support permissions on a per browser basis see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access
        // - CEF Doesn't currently support displaying a UI for media access permissions
        //
        //NOTE: WebRTC Device Id's aren't persisted as they are in Chrome see https://bitbucket.org/chromiumembedded/cef/issues/2064/persist-webrtc-deviceids-across-restart
        settings.CefCommandLineArgs.Add("enable-media-stream");
        //https://peter.sh/experiments/chromium-command-line-switches/#use-fake-ui-for-media-stream
        settings.CefCommandLineArgs.Add("use-fake-ui-for-media-stream");
        //For screen sharing add (see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access#comment-58677180)
        settings.CefCommandLineArgs.Add("enable-usermedia-screen-capturing");

        //Perform dependency check to make sure all relevant resources are in our output directory.
        //IMPORTANT: MUST set performDependencyCheck false
        Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new MainForm());

        return 0;
    }
}

I get the following.NET Runtime error

Application: InventoryDB.exe Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException at
CefSharp.Cef.EnableHighDPISupport() at
InventoryDB.Program.Main(System.String[])

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文