[英]Adding a Usercontrol with CefSharp to a WinForms app
我正在尝试使用CefSharp创建一个用户控件,以使其具有具有自定义属性的Web浏览器。 控件工作正常,除了当我尝试使用图形设计器将控件添加到WebForms应用程序时,每次尝试以图形方式添加控件时,都会遇到相同的错误:
无法创建组件“ MyComponent”
System.IO.FilenotFoundException: Could not load file or assembly 'CefSharp.Core, Version=65.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxx' or one of its dependencies. the system cannot find the file specified.
我在用户控件和WebFormsApp上都添加了CefSharp.Core作为参考。
(请注意,如果以编程方式添加该控件,则该控件将起作用。)
有人知道我想念什么吗?
编辑1:
这是我创建的用户控件的代码:
using System;
using System.Windows.Forms;
using CefSharp.WinForms;
using CefSharp;
namespace ControlTest
{
public partial class UserControl1: UserControl
{
public ChromiumWebBrowser browser;
public UserControl1()
{
InitializeComponent();
}
private void UserControl1_Load(object sender, EventArgs e)
{
CefSettings settings = new CefSettings();
Cef.Initialize();
browser = new ChromiumWebBrowser("www.google.com");
this.panel1.Controls.Add(browser);
}
}
}
最后,感谢amaitland,我弄清楚了如何使其工作。 我只需要避免在设计时创建组件,所以检查了我是否在设计时:
if (LicenseManager.UsageMode != LicenseUsageMode.Designtime)
InitializeComponent();
这样,仅在运行时才创建组件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.