名称 ChromiumWebBrowser 在命名空间“clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf”中不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39612449/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The name ChromiumWebBrowser does not exist in the namespace "clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
提问by Minkyu Kim
I had followed this linkto implement CefSharp applicaton.
我已按照此链接实施 CefSharp 应用程序。
But I have stuck while coding MainWindow.xaml.
但是我在编码时卡住了MainWindow.xaml。
Blend for VS 2015 said,
Blend for VS 2015 说,
The name ChromiumWebBrowser does not exist in the namespace "clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
名称 ChromiumWebBrowser 在命名空间“clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf”中不存在
But I'm installed CefSharp.Common and CefSharp.Wpf v51.0.0, cef.redist.x64 and cef.redist.x86 v3.2704.1432 with NuGet Package Manager.
但我安装了 CefSharp.Common 和 CefSharp.Wpf v51.0.0、cef.redist.x64 和 cef.redist.x86 v3.2704.1432 和 NuGet 包管理器。
I'm new on developing C# so I don't know how to solve this problem. Please help me to solve this error.
我是开发 C# 的新手,所以我不知道如何解决这个问题。请帮我解决这个错误。
This is my MainWindow.xaml
这是我的 MainWindow.xaml
<Window x:Class="StocktalkBrowser.MainWindow"
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:StocktalkBrowser"
xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<cefSharp:ChromiumWebBrowser Grid.Row="0" Address="https://github.com/cefsharp/CefSharp/wiki/Frequently-asked-questions" />
</Grid>
</Window>
采纳答案by Nawed Nabi Zada
回答by Marko
For me the problem was that the solution platform was set to AnyCPU.
As far as I know, CefSharp does not support AnyCPU. Interestingly the solution ran just fine in Release mode, but in Debug mode I immediately got an error - the invocation of the constructor on type that matches ... the specified binding constraints threw an exception.
对我来说,问题是解决方案平台设置为 AnyCPU。
据我所知,CefSharp 不支持 AnyCPU。有趣的是,该解决方案在 Release 模式下运行良好,但在 Debug 模式下我立即出现错误 -the invocation of the constructor on type that matches ... the specified binding constraints threw an exception.
As soon as I changed the solution platform to be only x64, then the XAML error went away (The name ChromiumWebBrowser does not exist in the namespace “clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf”). And I could run the solution both in Debug and Release mode.
一旦我将解决方案平台更改为仅 x64,XAML 错误就消失了 ( The name ChromiumWebBrowser does not exist in the namespace “clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf”)。我可以在调试和发布模式下运行解决方案。
回答by dovid
its not supported in the XAML desginer, so load it in run time:
XAML 设计器不支持它,因此在运行时加载它:
Remove the element from the XAMl, and instead place any container such as a Border:
<Border x:Name="cefChromeContainer" />in the Constructor code, after
InitializeComponent();call, craete the browser element and place into the container. even better to declare the browser in the class scoop:CefSharp.Wpf.ChromiumWebBrowser browser = new CefSharp.Wpf.ChromiumWebBrowser(); public MainWindow() { InitializeComponent(); cefChromeContainer.Content = browser; browser.Address = "https://stackoverflow.com"; }
从 XAMl 中删除元素,并放置任何容器,例如 Border:
<Border x:Name="cefChromeContainer" />在构造函数代码中,
InitializeComponent();调用后,创建浏览器元素并放入容器中。甚至更好地在类 scoop 中声明浏览器:CefSharp.Wpf.ChromiumWebBrowser browser = new CefSharp.Wpf.ChromiumWebBrowser(); public MainWindow() { InitializeComponent(); cefChromeContainer.Content = browser; browser.Address = "https://stackoverflow.com"; }
回答by tomasofen
I had the same problem and i solve it changing configuration to from "debug" to "release" and using "x64" as platform.
我遇到了同样的问题,我解决了将配置从“调试”更改为“发布”并使用“ x64”作为平台的问题。
But it was not enought to change it from the solution menú, as i usually do. You need to go to visual studio main menú under "Compile > Configuration administration", as you can see in the following link from Microsoft:
但是,像我通常所做的那样,从解决方案菜单中更改它是不够的。您需要转到“编译>配置管理”下的visual studio主菜单,您可以在Microsoft的以下链接中看到:
This solution was in fact in the Readme.txt file for cefsharp, as stated in the "Documentation" link provided by saschadin his answer: https://github.com/cefsharp/CefSharp/blob/cefsharp/69/NuGet/Readme.txt
这个解决方案实际上在 cefsharp 的 Readme.txt 文件中,如saschad在他的回答中提供的“文档”链接中所述:https: //github.com/cefsharp/CefSharp/blob/cefsharp/69/NuGet/Readme 。文本
There you can read it:
在那里你可以阅读它:
- For
x86or x64set your solution target architecture tox86orx64`, just changing the project is currently not enough (See https://msdn.microsoft.com/en-us/library/ms185328.aspx#Anchor_0for details).
- 对于
x86x64set your solution target architecture tox86orx64`,仅更改项目目前还不够(有关详细信息,请参阅 https://msdn.microsoft.com/en-us/library/ms185328.aspx#Anchor_0)。
Now I have it running like a charm :D
现在我让它像魅力一样运行:D
回答by saschad
You can read in the (Documentation) of the NuGet package, it's also necessary to add an app.manifestto your Application.
您可以阅读NuGet 包的(文档),还需要app.manifest向您的应用程序添加一个。


