我用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 ChromiumMy XAML for the MainWindow:
<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文件夹中。
我做错了什么?
发布于 2014-10-12 02:22:33
嗯,我意识到这是几个月前的事了,看起来你应用的指南和代码是针对CefSharp1代码分支的(那个版本确实只支持x86)。注释 CefSharp1的WPF控件和当前的master有很大的不同。
对于刚刚发布的CefSharp 33.0.0,我建议您尝试使用该版本的NuGet,并首先使用WPF example of CefSharp.MinimalExample开始运行一切。我认为你使用的指南在那之后有了一些改变。不过,我还不确定它是否已经准备好了。
最后,在CefSharp谷歌小组和a good write-up on the "DIY version of MinimalExample"上有一篇最近的文章。请阅读前两篇文章,我认为这两篇文章仍然适用。
https://stackoverflow.com/questions/24999355
复制相似问题