0

代码运行良好,但发布后无法打开。我创建了一个页面来测试图形,但是由于 webbrowser C# 不起作用,因为它在 IE 中启动我尝试使用 Cefsharp 但它也不行,出现在我看来的错误是 Cefsharp.Core.Runtime.dll,我使用的cefsharp 版本是94.4.11。但问题是,当我通过 Visual Studio 2022 使用它时,它可以工作,但是当我进行编译并发布它以生成可执行文件时,它不仅会给出错误,甚至不会打开

using CefSharp;
using CefSharp.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace cefteste
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            criarcef(panel1,p);
        }

        ChromiumWebBrowser p;

        private void Form1_Load(object sender, EventArgs e)
        {

        }
        private void criarcef(Panel panel, ChromiumWebBrowser chromium)
        {
            /*CefSettings settings = new CefSettings();
            settings.CachePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/GPMDP";
            settings.WindowlessRenderingEnabled = true;
            settings.CefCommandLineArgs.Add("enable-smooth-scrolling", "1");
            settings.CefCommandLineArgs.Add("enable-overlay-scrollbar", "1");
            settings.CefCommandLineArgs.Add("enable-npapi", "1");
            CefSharp.Cef.Initialize(settings);*/
            chromium = new ChromiumWebBrowser("C:/Users/Bill/Downloads/index(1).html");
            chromium.LoadingStateChanged += (sender, args) => {
                if (args.IsLoading == false)
                    chromium.ExecuteScriptAsync("document.oncontextmenu = function() { return false; };");
            };
            panel.Controls.Add(chromium);
            chromium.Dock = DockStyle.Fill;
        }
    }
}
4

0 回答 0