Kaz*_*oka 6 wpf xaml c#-4.0 visual-studio-2012 cefsharp
我用 VS2012 创建了一个新的 Wpf 项目。我右键单击该项目并选择“管理 NuGet 包”。然后我安装了 Wpf 的 CefSharp 包。
然后我使用了这个“指南”:https://github.com/cefsharp/CefSharp/blob/master/README.WPF.md
遗憾的是我遇到了 4 个错误,但我不知道如何消除它们!
这些是我得到的错误(我用“filepath”取出了项目的路径):
Error 5 The type 'cefSharp:WebView' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. "filepath"\Chromium\MainWindow.xaml 6 10 Chromium
Error 3 The name "WebView" does not exist in the namespace "clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf". "filepath"\Chromium\MainWindow.xaml 6 9 Chromium
Error 6 The name 'Cef' does not exist in the current context "filepath"\Chromium\MainWindow.xaml.cs 28 13 Chromium
Error 4 Assembly 'CefSharp.Wpf' was not found. Verify that you are not missing an assembly reference. Also, verify that your project and all referenced assemblies have been built. "filepath"\Chromium\MainWindow.xaml 4 22 Chromium
Run Code Online (Sandbox Code Playgroud)
我的主窗口 XAML:
<Window x:Class="Chromium.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf" Title="MainWindow" Height="350" Width="525">
<Grid>
<cefSharp:WebView x:Name="WebView" />
</Grid>
Run Code Online (Sandbox Code Playgroud)
MainWindow.cs 的隐藏代码:
using System.ComponentModel;
using System.Windows;
using CefSharp;
namespace Chromium
{
public partial class MainWindow
{
public MainWindow()
{
InitializeComponent();
WebView.PropertyChanged += OnWebViewPropertyChanged;
Cef.Initialize(new Settings());
}
private void OnWebViewPropertyChanged(object sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case "IsBrowserInitialized":
if (WebView.IsBrowserInitialized)
{
WebView.Load("http://10.211.55.2:42000");
}
break;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
MainWindow 的 XAML 和后台代码与 README.MD 中的几乎完全相同
我还手动将 0.25.7 二进制包中的这 2 个文件(libcef.dll 和 icudt.dll)从 github 复制到 bin\Debug 和 bin\Release 文件夹。
我究竟做错了什么?
嗯,我意识到这是几个月前的事了,看起来您应用的指南和代码是针对 CefSharp1 代码分支的(据我所知,该版本仅支持 x86)。请注意, CefSharp1 和当前的 WPF 控件master有很大不同。
随着 CefSharp 33.0.0 刚刚发布,我建议您尝试使用该版本的 NuGet ,并首先使用WPF 示例开始运行所有内容CefSharp.MinimalExample。我认为从那时起您使用的指南已经发生了一些变化。但不确定它是否已经准备好迎接黄金时段。
最后,最近 CefSharp Google Group 上有一篇关于“MinimalExample DIY 版本”的精彩文章。阅读前两篇文章,我认为它们仍然适用。
| 归档时间: |
|
| 查看次数: |
28600 次 |
| 最近记录: |