我有一个包含多个项目的解决方案。 主要项目是一个引用WPF项目的WinFormsApplication。我尝试使用ElementHost在表单中包含一个包含CefSharp ChromiumWebBrowser的WPF UserControl(在WPF项目中定义)。
public partial class WebForm : Form
{
private ElementHost elementHostWeb;
public WebForm()
{
InitializeComponent();
elementHostWeb = new ElementHost();
elementHostWeb.Height = this.Height;
elementHostWeb.Width = this.Width;
elementHostWeb.Child = new WebWPFUserControl();
}
}
WPF UserControl:
<UserControl x:Class="WpfApplication.WebWPFUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication"
xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
mc:Ignorable="d"
Title="WebWPFUserControl" Height="350" Width="525">
<Grid>
<cefSharp:ChromiumWebBrowser Grid.Row="0"
Address="https://github.com/cefsharp/CefSharp/wiki/Frequently-asked-questions" />
</Grid>
当我托盘打开表单时,我收到以下错误: