【发布时间】:2014-09-19 21:11:58
【问题描述】:
我用 VS2012 创建了一个新的 Wpf 项目。我右键单击项目并选择“管理 NuGet 包”。然后我为 Wpf 安装了 CefSharp 包。
然后我使用了这个“指南”:https://github.com/cefsharp/CefSharp/blob/master/README.WPF.md
遗憾的是,我遇到了 4 个错误,但我不知道如何摆脱它们!
这些是我得到的错误(我用“文件路径”取出了项目的路径):
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
我的主窗口 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>
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;
}
}
}
}
MainWindow 的 XAML 和代码与 README.MD 中的代码几乎完全相同
我还手动将这两个文件(libcef.dll 和 icudt.dll)从 github 的 0.25.7 二进制包复制到 bin\Debug 和 bin\Release 文件夹。
我做错了什么?
【问题讨论】:
-
我通过将目标框架设置为 4.0 并将平台目标设置为 x64 将其降低为 1 个错误。仍然认为这个错误:错误3名称“WebView”在命名空间“clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf”中不存在。 “文件路径”\Chromium\MainWindow.xaml 6 9 Chromium
-
嗯,我意识到这是几个月前的事了,它看起来就像您应用的指南和代码是用于 CefSharp1 代码分支的。
标签: wpf xaml c#-4.0 visual-studio-2012 cefsharp