The name ChromiumWebBrowser does not exist in the namespace "clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
Asked Answered
V

5

9

I had followed this link to implement CefSharp applicaton.

But I have stuck while coding MainWindow.xaml.

Blend for VS 2015 said,

The name ChromiumWebBrowser does not exist in the namespace "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.

I'm new on developing C# so I don't know how to solve this problem. Please help me to solve this error.

This is my 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>

Venatic answered 21/9, 2016 at 9:21 Comment(6)
Does it just say it as info, or it doesn't compile ? Sometimes the designer is really stupid and just tell you things, but the project will compile without any problem. Perhaps Clean your project and rebuild. Sometimes that also helpsJeminah
@NawedNabiZada I tired it many times, but it doesn't matter.Venatic
Does it compile ?Jeminah
@NawedNabiZada Would you tell me where is defined clr namespaces?Venatic
@NawedNabiZada no, It doen't.Venatic
@NawedNabiZada Oh Sorry, it compiles but when I run output file, it stops.Venatic
J
6

I just tried the link, and as I mentioned in the comments it compiles without any problem.

It is shown as error,  but you can ignore it Can be ignored.

No Preview available And the preview is not available as well, I learned to live with it.

Compiles No errors when compiling

Program starts And the program starts up. No problem

Jeminah answered 21/9, 2016 at 9:53 Comment(1)
I don't know why, but it is running well now ! Thank youVenatic
M
2

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.

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.

Monohydroxy answered 23/4, 2017 at 12:50 Comment(1)
Thanks for your answer. But I retired using CdefSharp and moved to Electron. I'll try it again when I have time enough. Thank you MarkoVenatic
B
0

its not supported in the XAML desginer, so load it in run time:

  1. Remove the element from the XAMl, and instead place any container such as a Border:

    <Border x:Name="cefChromeContainer" />
    
  2. 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";
    }
    
Bumbailiff answered 31/10, 2017 at 9:15 Comment(1)
Thanks a lot! but we chose Electron insteat.Venatic
I
0

I had the same problem and i solve it changing configuration to from "debug" to "release" and using "x64" as platform.

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:

https://learn.microsoft.com/es-es/visualstudio/ide/how-to-configure-projects-to-target-platforms?view=vs-2015&redirectedfrom=MSDN#Anchor_0

This solution was in fact in the Readme.txt file for cefsharp, as stated in the "Documentation" link provided by saschad in his answer: https://github.com/cefsharp/CefSharp/blob/cefsharp/69/NuGet/Readme.txt

There you can read it:

Now I have it running like a charm :D

Imaginary answered 22/4, 2020 at 17:7 Comment(0)
T
-1

You can read in the (Documentation) of the NuGet package, it's also necessary to add an app.manifest to your Application.

Torque answered 8/1, 2019 at 9:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.