【发布时间】:2018-08-22 19:32:42
【问题描述】:
我正在尝试使用 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.
我在 Usercontrol 和 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 我已经看到了这个问题,现在我可以通过从构造函数中删除
InitializeComponent()来加载控件,但是随后控件没有加载并且我无法使用它,所以它对我不起作用:( -
没有看到你的代码,我只是在猜测。如果你还没有,你需要阅读stackoverflow.com/help/mcve
-
@amaitland 感谢您的建议,我在这里很新手...现在我要更新问题。
-
只在非设计模式下创建和添加浏览器,见stackoverflow.com/a/4346899/4583726
标签: c# user-controls chromium-embedded cefsharp